[15/27] cpufreq: powerenv: Don't validate the frequency table twice

Message ID 3120e4db4ae3bc014d198a206f46be1305ec65e8.1519620578.git.viresh.kumar@linaro.org
State Superseded
Headers show
Series
  • cpufreq: Stop validating cpufreq table in drivers
Related show

Commit Message

Viresh Kumar Feb. 26, 2018, 5:08 a.m.
The cpufreq core is already validating the CPU frequency table after
calling the ->init() callback of the cpufreq drivers and the drivers
don't need to do the same anymore. Though they need to set the
policy->freq_table field directly from the ->init() callback now.

Stop validating the frequency table from powerenv driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

---
 drivers/cpufreq/powernv-cpufreq.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

-- 
2.15.0.194.g9af6a3dea062

Comments

Michael Ellerman Feb. 26, 2018, 11:53 a.m. | #1
Viresh Kumar <viresh.kumar@linaro.org> writes:
> Subject: Re: [PATCH 15/27] cpufreq: powerenv: Don't validate the frequency table twice

                                           ^
                                      powernv

> The cpufreq core is already validating the CPU frequency table after

> calling the ->init() callback of the cpufreq drivers and the drivers

> don't need to do the same anymore. Though they need to set the

> policy->freq_table field directly from the ->init() callback now.

>

> Stop validating the frequency table from powerenv driver.

>

> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

> ---

>  drivers/cpufreq/powernv-cpufreq.c | 11 +++--------

>  1 file changed, 3 insertions(+), 8 deletions(-)

>

> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c

> index 29cdec198657..0591874856d3 100644

> --- a/drivers/cpufreq/powernv-cpufreq.c

> +++ b/drivers/cpufreq/powernv-cpufreq.c

> @@ -812,7 +812,7 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,

>  

>  static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)

>  {

> -	int base, i, ret;

> +	int base, i;

>  	struct kernfs_node *kn;

>  	struct global_pstate_info *gpstates;


Confusingly this function has two variables called ret, but the other
one is declared inside an if block below in context not shown.

So this hunk is correct.

> @@ -848,15 +848,10 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)

>  	gpstates->timer.expires = jiffies +

>  				msecs_to_jiffies(GPSTATE_TIMER_INTERVAL);

>  	spin_lock_init(&gpstates->gpstate_lock);

> -	ret = cpufreq_table_validate_and_show(policy, powernv_freqs);

> -

> -	if (ret < 0) {

> -		kfree(policy->driver_data);

> -		return ret;

> -	}

>  

> +	policy->freq_table = powernv_freqs;

>  	policy->fast_switch_possible = true;

> -	return ret;

> +	return 0;

>  }


LGTM.

cheers
Viresh Kumar Feb. 27, 2018, 3:45 a.m. | #2
On 26-02-18, 22:53, Michael Ellerman wrote:
> Viresh Kumar <viresh.kumar@linaro.org> writes:

> > Subject: Re: [PATCH 15/27] cpufreq: powerenv: Don't validate the frequency table twice

>                                            ^

>                                       powernv

> 

> > The cpufreq core is already validating the CPU frequency table after

> > calling the ->init() callback of the cpufreq drivers and the drivers

> > don't need to do the same anymore. Though they need to set the

> > policy->freq_table field directly from the ->init() callback now.

> >

> > Stop validating the frequency table from powerenv driver.


                                             powernv :)

Will fix both of them.

-- 
viresh
Michael Ellerman Feb. 28, 2018, 10:45 a.m. | #3
Viresh Kumar <viresh.kumar@linaro.org> writes:

> On 26-02-18, 22:53, Michael Ellerman wrote:

>> Viresh Kumar <viresh.kumar@linaro.org> writes:

>> > Subject: Re: [PATCH 15/27] cpufreq: powerenv: Don't validate the frequency table twice

>>                                            ^

>>                                       powernv

>> 

>> > The cpufreq core is already validating the CPU frequency table after

>> > calling the ->init() callback of the cpufreq drivers and the drivers

>> > don't need to do the same anymore. Though they need to set the

>> > policy->freq_table field directly from the ->init() callback now.

>> >

>> > Stop validating the frequency table from powerenv driver.

>

>                                              powernv :)

>

> Will fix both of them.


Thanks :)

cheers

Patch

diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 29cdec198657..0591874856d3 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -812,7 +812,7 @@  static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
 
 static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 {
-	int base, i, ret;
+	int base, i;
 	struct kernfs_node *kn;
 	struct global_pstate_info *gpstates;
 
@@ -848,15 +848,10 @@  static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	gpstates->timer.expires = jiffies +
 				msecs_to_jiffies(GPSTATE_TIMER_INTERVAL);
 	spin_lock_init(&gpstates->gpstate_lock);
-	ret = cpufreq_table_validate_and_show(policy, powernv_freqs);
-
-	if (ret < 0) {
-		kfree(policy->driver_data);
-		return ret;
-	}
 
+	policy->freq_table = powernv_freqs;
 	policy->fast_switch_possible = true;
-	return ret;
+	return 0;
 }
 
 static int powernv_cpufreq_cpu_exit(struct cpufreq_policy *policy)