diff mbox

[2/2] cpufreq: cpu0: Handle regulator_get_voltage() failure

Message ID 1412454365-17804-3-git-send-email-stefan.wahren@i2se.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Stefan Wahren Oct. 4, 2014, 8:26 p.m. UTC
In error cases regulator_get_voltage() returns a negative value.
So take care of it.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/cpufreq/cpufreq-cpu0.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Viresh Kumar Oct. 6, 2014, 5:15 a.m. UTC | #1
On 5 October 2014 01:56, Stefan Wahren <stefan.wahren@i2se.com> wrote:
> In error cases regulator_get_voltage() returns a negative value.
> So take care of it.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  drivers/cpufreq/cpufreq-cpu0.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
> index ef3d618..6aa2104 100644
> --- a/drivers/cpufreq/cpufreq-cpu0.c
> +++ b/drivers/cpufreq/cpufreq-cpu0.c
> @@ -77,7 +77,7 @@ static int cpu0_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 */
> @@ -93,7 +93,7 @@ static int cpu0_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;
>         }

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index ef3d618..6aa2104 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -77,7 +77,7 @@  static int cpu0_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 */
@@ -93,7 +93,7 @@  static int cpu0_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;
 	}