cpufreq: Move ->get callback check outside of __cpufreq_get()
diff mbox series

Message ID 20190419062759.8524-1-zbestahu@gmail.com
State Awaiting Upstream
Delegated to: Rafael Wysocki
Headers show
Series
  • cpufreq: Move ->get callback check outside of __cpufreq_get()
Related show

Commit Message

Yue Hu April 19, 2019, 6:27 a.m. UTC
From: Yue Hu <huyue2@yulong.com>

Currenly, __cpufreq_get() called by show_cpuinfo_cur_freq() will check
->get callback. That is needless since cpuinfo_cur_freq attribute will
not be created if ->get is not set. So let's drop it in __cpufreq_get().
Also keep this check in cpufreq_get().

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 drivers/cpufreq/cpufreq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Viresh Kumar April 22, 2019, 8:19 a.m. UTC | #1
On 19-04-19, 14:27, Yue Hu wrote:
> From: Yue Hu <huyue2@yulong.com>
> 
> Currenly, __cpufreq_get() called by show_cpuinfo_cur_freq() will check
> ->get callback. That is needless since cpuinfo_cur_freq attribute will
> not be created if ->get is not set. So let's drop it in __cpufreq_get().
> Also keep this check in cpufreq_get().
> 
> Signed-off-by: Yue Hu <huyue2@yulong.com>
> ---
>  drivers/cpufreq/cpufreq.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 047662b..c6187f1 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1548,7 +1548,7 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
>  {
>  	unsigned int ret_freq = 0;
>  
> -	if (unlikely(policy_is_inactive(policy)) || !cpufreq_driver->get)
> +	if (unlikely(policy_is_inactive(policy)))
>  		return ret_freq;
>  
>  	ret_freq = cpufreq_driver->get(policy->cpu);
> @@ -1586,7 +1586,8 @@ unsigned int cpufreq_get(unsigned int cpu)
>  
>  	if (policy) {
>  		down_read(&policy->rwsem);
> -		ret_freq = __cpufreq_get(policy);
> +		if (cpufreq_driver->get)
> +			ret_freq = __cpufreq_get(policy);
>  		up_read(&policy->rwsem);
>  
>  		cpufreq_cpu_put(policy);

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Rafael J. Wysocki May 1, 2019, 10:39 a.m. UTC | #2
On Monday, April 22, 2019 10:19:02 AM CEST Viresh Kumar wrote:
> On 19-04-19, 14:27, Yue Hu wrote:
> > From: Yue Hu <huyue2@yulong.com>
> > 
> > Currenly, __cpufreq_get() called by show_cpuinfo_cur_freq() will check
> > ->get callback. That is needless since cpuinfo_cur_freq attribute will
> > not be created if ->get is not set. So let's drop it in __cpufreq_get().
> > Also keep this check in cpufreq_get().
> > 
> > Signed-off-by: Yue Hu <huyue2@yulong.com>
> > ---
> >  drivers/cpufreq/cpufreq.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index 047662b..c6187f1 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -1548,7 +1548,7 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
> >  {
> >  	unsigned int ret_freq = 0;
> >  
> > -	if (unlikely(policy_is_inactive(policy)) || !cpufreq_driver->get)
> > +	if (unlikely(policy_is_inactive(policy)))
> >  		return ret_freq;
> >  
> >  	ret_freq = cpufreq_driver->get(policy->cpu);
> > @@ -1586,7 +1586,8 @@ unsigned int cpufreq_get(unsigned int cpu)
> >  
> >  	if (policy) {
> >  		down_read(&policy->rwsem);
> > -		ret_freq = __cpufreq_get(policy);
> > +		if (cpufreq_driver->get)
> > +			ret_freq = __cpufreq_get(policy);
> >  		up_read(&policy->rwsem);
> >  
> >  		cpufreq_cpu_put(policy);
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Patch applied, thanks!

Patch
diff mbox series

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 047662b..c6187f1 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1548,7 +1548,7 @@  static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
 {
 	unsigned int ret_freq = 0;
 
-	if (unlikely(policy_is_inactive(policy)) || !cpufreq_driver->get)
+	if (unlikely(policy_is_inactive(policy)))
 		return ret_freq;
 
 	ret_freq = cpufreq_driver->get(policy->cpu);
@@ -1586,7 +1586,8 @@  unsigned int cpufreq_get(unsigned int cpu)
 
 	if (policy) {
 		down_read(&policy->rwsem);
-		ret_freq = __cpufreq_get(policy);
+		if (cpufreq_driver->get)
+			ret_freq = __cpufreq_get(policy);
 		up_read(&policy->rwsem);
 
 		cpufreq_cpu_put(policy);