]> git.karo-electronics.de Git - linux-beck.git/commitdiff
cpufreq: cpufreq-dt: Handle regulator_get_voltage() failure
authorStefan Wahren <stefan.wahren@i2se.com>
Fri, 17 Oct 2014 22:09:49 +0000 (22:09 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 6 Nov 2014 00:28:59 +0000 (01:28 +0100)
In error cases regulator_get_voltage() returns a negative value.
So take care of it.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq-dt.c

index 725fb1d86578d50d63254467b8b5cbc4d6cb35b1..8cba13df5f289d0e8fb0b5744944d665b4e2c692 100644 (file)
@@ -78,7 +78,7 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
        }
 
        dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
-               old_freq / 1000, volt_old ? volt_old / 1000 : -1,
+               old_freq / 1000, (volt_old > 0) ? volt_old / 1000 : -1,
                new_freq / 1000, volt ? volt / 1000 : -1);
 
        /* scaling up?  scale voltage before frequency */
@@ -94,7 +94,7 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
        ret = clk_set_rate(cpu_clk, freq_exact);
        if (ret) {
                dev_err(cpu_dev, "failed to set clock rate: %d\n", ret);
-               if (!IS_ERR(cpu_reg))
+               if (!IS_ERR(cpu_reg) && volt_old > 0)
                        regulator_set_voltage_tol(cpu_reg, volt_old, tol);
                return ret;
        }