Skip to content

Commit

Permalink
cpufreq: Move ->get callback check outside of __cpufreq_get()
Browse files Browse the repository at this point in the history
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>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Yue Hu authored and Rafael J. Wysocki committed Apr 23, 2019
1 parent b23aa31 commit 4db7c34
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,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);
Expand Down Expand Up @@ -1623,7 +1623,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);
Expand Down

0 comments on commit 4db7c34

Please sign in to comment.