* [PATCH] cpufreq-dt: fix handling regulator_get_voltage result
@ 2015-12-30 11:18 Andrzej Hajda
2016-01-04 5:28 ` Viresh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Andrzej Hajda @ 2015-12-30 11:18 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
open list:CPU FREQUENCY DRIVERS, open list
The function can return negative values so it should be assigned
to signed type.
The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
drivers/cpufreq/cpufreq-dt.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 1ceece9..9bc37c4 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -50,7 +50,8 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
struct private_data *priv = policy->driver_data;
struct device *cpu_dev = priv->cpu_dev;
struct regulator *cpu_reg = priv->cpu_reg;
- unsigned long volt = 0, volt_old = 0, tol = 0;
+ unsigned long volt = 0, tol = 0;
+ int volt_old = 0;
unsigned int old_freq, new_freq;
long freq_Hz, freq_exact;
int ret;
@@ -83,7 +84,7 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
opp_freq / 1000, volt);
}
- dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
+ dev_dbg(cpu_dev, "%u MHz, %d mV --> %u MHz, %ld mV\n",
old_freq / 1000, (volt_old > 0) ? volt_old / 1000 : -1,
new_freq / 1000, volt ? volt / 1000 : -1);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq-dt: fix handling regulator_get_voltage result
2015-12-30 11:18 [PATCH] cpufreq-dt: fix handling regulator_get_voltage result Andrzej Hajda
@ 2016-01-04 5:28 ` Viresh Kumar
2016-01-05 13:03 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2016-01-04 5:28 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Rafael J. Wysocki, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
open list:CPU FREQUENCY DRIVERS, open list
On 30-12-15, 12:18, Andrzej Hajda wrote:
> The function can return negative values so it should be assigned
> to signed type.
>
> The problem has been detected using proposed semantic patch
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> drivers/cpufreq/cpufreq-dt.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq-dt: fix handling regulator_get_voltage result
2016-01-04 5:28 ` Viresh Kumar
@ 2016-01-05 13:03 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2016-01-05 13:03 UTC (permalink / raw)
To: Viresh Kumar, Andrzej Hajda
Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski,
open list:CPU FREQUENCY DRIVERS, open list
On Monday, January 04, 2016 10:58:56 AM Viresh Kumar wrote:
> On 30-12-15, 12:18, Andrzej Hajda wrote:
> > The function can return negative values so it should be assigned
> > to signed type.
> >
> > The problem has been detected using proposed semantic patch
> > scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
> >
> > [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
> >
> > Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> > ---
> > drivers/cpufreq/cpufreq-dt.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Applied, thanks!
Rafael
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-05 12:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-30 11:18 [PATCH] cpufreq-dt: fix handling regulator_get_voltage result Andrzej Hajda
2016-01-04 5:28 ` Viresh Kumar
2016-01-05 13:03 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).