cpufreq: powernow-k6: Fix incorrect comparison with max_multipler
authorSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Mon, 28 Apr 2014 18:54:27 +0000 (00:24 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 28 Apr 2014 23:22:53 +0000 (01:22 +0200)
The value of 'max_multiplier' is meant to be used for comparison with
clock_ratio[index].driver_data, not the index itself! Fix the code in
powernow_k6_cpu_exit() that has this bug.

Also, while at it, make the for-loop condition look for CPUFREQ_TABLE_END,
instead of hard-coding the loop count to 8.

Reported-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/powernow-k6.c

index 49f120e1bc7be0ecb879f184424d1dc56ee63981..695a68cfdcd4236d8d8bc79db66a49711033a723 100644 (file)
@@ -227,8 +227,9 @@ have_busfreq:
 static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
 {
        unsigned int i;
-       for (i = 0; i < 8; i++) {
-               if (i == max_multiplier)
+
+       for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
+               if (clock_ratio[i].driver_data == max_multiplier)
                        powernow_k6_target(policy, i);
        }
        return 0;