cpufreq: cpufreq-cpu0: Call CPUFREQ_POSTCHANGE notifier for failure cases too
authorViresh Kumar <viresh.kumar@linaro.org>
Mon, 1 Apr 2013 12:57:44 +0000 (12:57 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 2 Apr 2013 13:10:48 +0000 (15:10 +0200)
Currently we are simply returning from target() if we encounter some error after
broadcasting CPUFREQ_PRECHANGE notifier. Which looks to be wrong as others might
depend on POSTCHANGE notifier for their functioning.

So, better broadcast CPUFREQ_POSTCHANGE notifier for these failure cases too,
but with old frequency.

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

index 4c5a4cf..a7e51bd 100644 (file)
@@ -77,7 +77,9 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
                if (IS_ERR(opp)) {
                        rcu_read_unlock();
                        pr_err("failed to find OPP for %ld\n", freq_Hz);
-                       return PTR_ERR(opp);
+                       freqs.new = freqs.old;
+                       ret = PTR_ERR(opp);
+                       goto post_notify;
                }
                volt = opp_get_voltage(opp);
                rcu_read_unlock();
@@ -95,7 +97,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
                if (ret) {
                        pr_err("failed to scale voltage up: %d\n", ret);
                        freqs.new = freqs.old;
-                       return ret;
+                       goto post_notify;
                }
        }
 
@@ -104,7 +106,8 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
                pr_err("failed to set clock rate: %d\n", ret);
                if (cpu_reg)
                        regulator_set_voltage_tol(cpu_reg, volt_old, tol);
-               return ret;
+               freqs.new = freqs.old;
+               goto post_notify;
        }
 
        /* scaling down?  scale voltage after frequency */
@@ -114,16 +117,16 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
                        pr_err("failed to scale voltage down: %d\n", ret);
                        clk_set_rate(cpu_clk, freqs.old * 1000);
                        freqs.new = freqs.old;
-                       return ret;
                }
        }
 
+post_notify:
        for_each_online_cpu(cpu) {
                freqs.cpu = cpu;
                cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
        }
 
-       return 0;
+       return ret;
 }
 
 static int cpu0_cpufreq_init(struct cpufreq_policy *policy)