cpufreq: return early from __cpufreq_driver_getavg()
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 24 Oct 2012 21:39:48 +0000 (23:39 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 14 Nov 2012 23:33:07 +0000 (00:33 +0100)
There is no need to do cpufreq_get_cpu() and cpufreq_put_cpu() for drivers that
don't support getavg() routine.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c

index 85df5387bc61f2c1b5ff15e9807b8d0484421e72..f552d5fe0f8fa2c68daa9c78ef6780baf3834a32 100644 (file)
@@ -1511,12 +1511,14 @@ int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu)
 {
        int ret = 0;
 
+       if (!(cpu_online(cpu) && cpufreq_driver->getavg))
+               return 0;
+
        policy = cpufreq_cpu_get(policy->cpu);
        if (!policy)
                return -EINVAL;
 
-       if (cpu_online(cpu) && cpufreq_driver->getavg)
-               ret = cpufreq_driver->getavg(policy, cpu);
+       ret = cpufreq_driver->getavg(policy, cpu);
 
        cpufreq_cpu_put(policy);
        return ret;