* [PATCH] cpufreq: cpufreq-cpu0: NULL is a valid regulator
@ 2013-08-09 18:06 Mark Brown
2013-08-12 5:19 ` Viresh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2013-08-09 18:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar; +Cc: cpufreq, linaro-kernel, Mark Brown
From: Mark Brown <broonie@linaro.org>
Since NULL could in theory be a valid regulator we ought to check for
IS_ERR() rather than for NULL. In practice this is unlikely to be an
issue but it's better for neatness.
Signed-off-by: Mark Brown <broonie@linaro.org>
---
drivers/cpufreq/cpufreq-cpu0.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index ad1fde2..09cd3a7 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -69,7 +69,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
- if (cpu_reg) {
+ if (!IS_ERR(cpu_reg)) {
rcu_read_lock();
opp = opp_find_freq_ceil(cpu_dev, &freq_Hz);
if (IS_ERR(opp)) {
@@ -90,7 +90,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
freqs.new / 1000, volt ? volt / 1000 : -1);
/* scaling up? scale voltage before frequency */
- if (cpu_reg && freqs.new > freqs.old) {
+ if (!IS_ERR(cpu_reg) && freqs.new > freqs.old) {
ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
if (ret) {
pr_err("failed to scale voltage up: %d\n", ret);
@@ -102,14 +102,14 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
ret = clk_set_rate(cpu_clk, freq_exact);
if (ret) {
pr_err("failed to set clock rate: %d\n", ret);
- if (cpu_reg)
+ if (!IS_ERR(cpu_reg))
regulator_set_voltage_tol(cpu_reg, volt_old, tol);
freqs.new = freqs.old;
goto post_notify;
}
/* scaling down? scale voltage after frequency */
- if (cpu_reg && freqs.new < freqs.old) {
+ if (!IS_ERR(cpu_reg) && freqs.new < freqs.old) {
ret = regulator_set_voltage_tol(cpu_reg, volt, tol);
if (ret) {
pr_err("failed to scale voltage down: %d\n", ret);
@@ -210,7 +210,6 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
}
pr_warn("failed to get cpu0 regulator: %ld\n",
PTR_ERR(cpu_reg));
- cpu_reg = NULL;
}
cpu_clk = devm_clk_get(cpu_dev, NULL);
--
1.8.4.rc1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: cpufreq-cpu0: NULL is a valid regulator
2013-08-09 18:06 [PATCH] cpufreq: cpufreq-cpu0: NULL is a valid regulator Mark Brown
@ 2013-08-12 5:19 ` Viresh Kumar
2013-08-13 13:09 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2013-08-12 5:19 UTC (permalink / raw)
To: Mark Brown; +Cc: Rafael J. Wysocki, cpufreq, linaro-kernel, Mark Brown
On 9 August 2013 23:36, Mark Brown <broonie@kernel.org> wrote:
> From: Mark Brown <broonie@linaro.org>
>
> Since NULL could in theory be a valid regulator we ought to check for
> IS_ERR() rather than for NULL. In practice this is unlikely to be an
> issue but it's better for neatness.
>
> Signed-off-by: Mark Brown <broonie@linaro.org>
> ---
> drivers/cpufreq/cpufreq-cpu0.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
Makes sense.
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: cpufreq-cpu0: NULL is a valid regulator
2013-08-12 5:19 ` Viresh Kumar
@ 2013-08-13 13:09 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2013-08-13 13:09 UTC (permalink / raw)
To: Viresh Kumar; +Cc: Mark Brown, cpufreq, linaro-kernel, Mark Brown
On Monday, August 12, 2013 10:49:46 AM Viresh Kumar wrote:
> On 9 August 2013 23:36, Mark Brown <broonie@kernel.org> wrote:
> > From: Mark Brown <broonie@linaro.org>
> >
> > Since NULL could in theory be a valid regulator we ought to check for
> > IS_ERR() rather than for NULL. In practice this is unlikely to be an
> > issue but it's better for neatness.
> >
> > Signed-off-by: Mark Brown <broonie@linaro.org>
> > ---
> > drivers/cpufreq/cpufreq-cpu0.c | 9 ++++-----
> > 1 file changed, 4 insertions(+), 5 deletions(-)
>
> Makes sense.
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Queued up for 3.12.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-13 13:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-09 18:06 [PATCH] cpufreq: cpufreq-cpu0: NULL is a valid regulator Mark Brown
2013-08-12 5:19 ` Viresh Kumar
2013-08-13 13:09 ` Rafael J. Wysocki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.