diff mbox series

[v9,4/8] cpufreq: amd-pstate: Remove amd_get_{min,max,nominal,lowest_nonlinear}_freq()

Message ID a7fafd1a6af77329e943403705c10e3c141864e0.1710836407.git.perry.yuan@amd.com
State Superseded
Headers show
Series [v9,1/8] cpufreq: amd-pstate: Document *_limit_* fields in struct amd_cpudata | expand

Commit Message

Yuan, Perry March 19, 2024, 8:28 a.m. UTC
From: "Gautham R. Shenoy" <gautham.shenoy@amd.com>

amd_get_{min,max,nominal,lowest_nonlinear}_freq() functions merely
return cpudata->{min,max,nominal,lowest_nonlinear}_freq values.

There is no loss in readability in replacing their invocations by
accesses to the corresponding members of cpudata.

Do so and remove these helper functions.

Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Signed-off-by: Perry Yuan <perry.yuan@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 40 +++++++++---------------------------
 1 file changed, 10 insertions(+), 30 deletions(-)

Comments

Meng, Li (Jassmine) March 22, 2024, 6:41 a.m. UTC | #1
[AMD Official Use Only - General]

> -----Original Message-----
> From: Yuan, Perry <Perry.Yuan@amd.com>
> Sent: Tuesday, March 19, 2024 4:29 PM
> To: rafael.j.wysocki@intel.com; Limonciello, Mario
> <Mario.Limonciello@amd.com>; viresh.kumar@linaro.org; Shenoy, Gautham
> Ranjal <gautham.shenoy@amd.com>; Petkov, Borislav
> <Borislav.Petkov@amd.com>; Huang, Ray <Ray.Huang@amd.com>
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Huang, Shimmer
> <Shimmer.Huang@amd.com>; oleksandr@natalenko.name; Du, Xiaojian
> <Xiaojian.Du@amd.com>; Meng, Li (Jassmine) <Li.Meng@amd.com>; linux-
> pm@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH v9 4/8] cpufreq: amd-pstate: Remove
> amd_get_{min,max,nominal,lowest_nonlinear}_freq()
>
> From: "Gautham R. Shenoy" <gautham.shenoy@amd.com>
>
> amd_get_{min,max,nominal,lowest_nonlinear}_freq() functions merely
> return cpudata->{min,max,nominal,lowest_nonlinear}_freq values.
>
> There is no loss in readability in replacing their invocations by accesses to the
> corresponding members of cpudata.
>
> Do so and remove these helper functions.
>
> Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> Signed-off-by: Perry Yuan <perry.yuan@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 40 +++++++++---------------------------
>  1 file changed, 10 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index ba1baa6733e6..132330b4942f 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -604,26 +604,6 @@ static void amd_pstate_adjust_perf(unsigned int
> cpu,
>       cpufreq_cpu_put(policy);
>  }
>
> -static int amd_get_min_freq(struct amd_cpudata *cpudata) -{
> -     return READ_ONCE(cpudata->min_freq);
> -}
> -
> -static int amd_get_max_freq(struct amd_cpudata *cpudata) -{
> -     return READ_ONCE(cpudata->max_freq);
> -}
> -
> -static int amd_get_nominal_freq(struct amd_cpudata *cpudata) -{
> -     return READ_ONCE(cpudata->nominal_freq);
> -}
> -
> -static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) -{
> -     return READ_ONCE(cpudata->lowest_nonlinear_freq);
> -}
> -
>  static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)  {
>       struct amd_cpudata *cpudata = policy->driver_data; @@ -854,10
> +834,10 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
>       if (ret)
>               goto free_cpudata1;
>
> -     min_freq = amd_get_min_freq(cpudata);
> -     max_freq = amd_get_max_freq(cpudata);
> -     nominal_freq = amd_get_nominal_freq(cpudata);
> -     lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata);
> +     min_freq = READ_ONCE(cpudata->min_freq);
> +     max_freq = READ_ONCE(cpudata->max_freq);
> +     nominal_freq = READ_ONCE(cpudata->nominal_freq);
> +     lowest_nonlinear_freq = READ_ONCE(cpudata-
> >lowest_nonlinear_freq);
>
>       if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) {
>               dev_err(dev, "min_freq(%d) or max_freq(%d) value is
> incorrect\n", @@ -960,7 +940,7 @@ static ssize_t
> show_amd_pstate_max_freq(struct cpufreq_policy *policy,
>       int max_freq;
>       struct amd_cpudata *cpudata = policy->driver_data;
>
> -     max_freq = amd_get_max_freq(cpudata);
> +     max_freq = READ_ONCE(cpudata->max_freq);
>       if (max_freq < 0)
>               return max_freq;
>
> @@ -973,7 +953,7 @@ static ssize_t
> show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli
>       int freq;
>       struct amd_cpudata *cpudata = policy->driver_data;
>
> -     freq = amd_get_lowest_nonlinear_freq(cpudata);
> +     freq = READ_ONCE(cpudata->lowest_nonlinear_freq);
>       if (freq < 0)
>               return freq;
>
> @@ -1315,10 +1295,10 @@ static int amd_pstate_epp_cpu_init(struct
> cpufreq_policy *policy)
>       if (ret)
>               goto free_cpudata1;
>
> -     min_freq = amd_get_min_freq(cpudata);
> -     max_freq = amd_get_max_freq(cpudata);
> -     nominal_freq = amd_get_nominal_freq(cpudata);
> -     lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata);
> +     min_freq = READ_ONCE(cpudata->min_freq);
> +     max_freq = READ_ONCE(cpudata->max_freq);
> +     nominal_freq = READ_ONCE(cpudata->nominal_freq);
> +     lowest_nonlinear_freq = READ_ONCE(cpudata-
> >lowest_nonlinear_freq);
>       if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) {
>               dev_err(dev, "min_freq(%d) or max_freq(%d) value is
> incorrect\n",
>                               min_freq, max_freq);
> --
> 2.34.1
[Meng, Li (Jassmine)]
Reviewed-by: Li Meng < li.meng@amd.com>
diff mbox series

Patch

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index ba1baa6733e6..132330b4942f 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -604,26 +604,6 @@  static void amd_pstate_adjust_perf(unsigned int cpu,
 	cpufreq_cpu_put(policy);
 }
 
-static int amd_get_min_freq(struct amd_cpudata *cpudata)
-{
-	return READ_ONCE(cpudata->min_freq);
-}
-
-static int amd_get_max_freq(struct amd_cpudata *cpudata)
-{
-	return READ_ONCE(cpudata->max_freq);
-}
-
-static int amd_get_nominal_freq(struct amd_cpudata *cpudata)
-{
-	return READ_ONCE(cpudata->nominal_freq);
-}
-
-static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata)
-{
-	return READ_ONCE(cpudata->lowest_nonlinear_freq);
-}
-
 static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
 {
 	struct amd_cpudata *cpudata = policy->driver_data;
@@ -854,10 +834,10 @@  static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
 	if (ret)
 		goto free_cpudata1;
 
-	min_freq = amd_get_min_freq(cpudata);
-	max_freq = amd_get_max_freq(cpudata);
-	nominal_freq = amd_get_nominal_freq(cpudata);
-	lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata);
+	min_freq = READ_ONCE(cpudata->min_freq);
+	max_freq = READ_ONCE(cpudata->max_freq);
+	nominal_freq = READ_ONCE(cpudata->nominal_freq);
+	lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq);
 
 	if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) {
 		dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n",
@@ -960,7 +940,7 @@  static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy,
 	int max_freq;
 	struct amd_cpudata *cpudata = policy->driver_data;
 
-	max_freq = amd_get_max_freq(cpudata);
+	max_freq = READ_ONCE(cpudata->max_freq);
 	if (max_freq < 0)
 		return max_freq;
 
@@ -973,7 +953,7 @@  static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli
 	int freq;
 	struct amd_cpudata *cpudata = policy->driver_data;
 
-	freq = amd_get_lowest_nonlinear_freq(cpudata);
+	freq = READ_ONCE(cpudata->lowest_nonlinear_freq);
 	if (freq < 0)
 		return freq;
 
@@ -1315,10 +1295,10 @@  static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
 	if (ret)
 		goto free_cpudata1;
 
-	min_freq = amd_get_min_freq(cpudata);
-	max_freq = amd_get_max_freq(cpudata);
-	nominal_freq = amd_get_nominal_freq(cpudata);
-	lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata);
+	min_freq = READ_ONCE(cpudata->min_freq);
+	max_freq = READ_ONCE(cpudata->max_freq);
+	nominal_freq = READ_ONCE(cpudata->nominal_freq);
+	lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq);
 	if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) {
 		dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n",
 				min_freq, max_freq);