Skip to content

Commit c5258d3

Browse files
Shyam Sundar S Kjwrdegoede
authored andcommitted
platform/x86/amd/pmf: Add helper routine to update SPS thermals
Add helper routine to update the static slider information and remove the duplicate code occurrences after this change. Signed-off-by: Shyam Sundar S K <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 1bc5d81 commit c5258d3

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

drivers/platform/x86/amd/pmf/auto-mode.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,8 @@ int amd_pmf_reset_amt(struct amd_pmf_dev *dev)
275275
*/
276276

277277
if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) {
278-
int mode = amd_pmf_get_pprof_modes(dev);
279-
280-
if (mode < 0)
281-
return mode;
282-
283278
dev_dbg(dev->dev, "resetting AMT thermals\n");
284-
amd_pmf_update_slider(dev, SLIDER_OP_SET, mode, NULL);
279+
amd_pmf_set_sps_power_limits(dev);
285280
}
286281
return 0;
287282
}

drivers/platform/x86/amd/pmf/cnqf.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,9 @@ static ssize_t cnqf_enable_store(struct device *dev,
307307
const char *buf, size_t count)
308308
{
309309
struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
310-
int mode, result, src;
310+
int result, src;
311311
bool input;
312312

313-
mode = amd_pmf_get_pprof_modes(pdev);
314-
if (mode < 0)
315-
return mode;
316-
317313
result = kstrtobool(buf, &input);
318314
if (result)
319315
return result;
@@ -325,7 +321,7 @@ static ssize_t cnqf_enable_store(struct device *dev,
325321
amd_pmf_set_cnqf(pdev, src, config_store.current_mode, NULL);
326322
} else {
327323
if (is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
328-
amd_pmf_update_slider(pdev, SLIDER_OP_SET, mode, NULL);
324+
amd_pmf_set_sps_power_limits(pdev);
329325
}
330326

331327
dev_dbg(pdev->dev, "Received CnQF %s\n", input ? "on" : "off");

drivers/platform/x86/amd/pmf/pmf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
394394

395395

396396
int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
397+
int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf);
397398

398399
/* Auto Mode Layer */
399400
int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data);

drivers/platform/x86/amd/pmf/sps.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
7070
}
7171
}
7272

73+
int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
74+
{
75+
int mode;
76+
77+
mode = amd_pmf_get_pprof_modes(pmf);
78+
if (mode < 0)
79+
return mode;
80+
81+
amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL);
82+
83+
return 0;
84+
}
85+
7386
static int amd_pmf_profile_get(struct platform_profile_handler *pprof,
7487
enum platform_profile_option *profile)
7588
{
@@ -105,15 +118,10 @@ static int amd_pmf_profile_set(struct platform_profile_handler *pprof,
105118
enum platform_profile_option profile)
106119
{
107120
struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof);
108-
int mode;
109121

110122
pmf->current_profile = profile;
111-
mode = amd_pmf_get_pprof_modes(pmf);
112-
if (mode < 0)
113-
return mode;
114123

115-
amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL);
116-
return 0;
124+
return amd_pmf_set_sps_power_limits(pmf);
117125
}
118126

119127
int amd_pmf_init_sps(struct amd_pmf_dev *dev)

0 commit comments

Comments
 (0)