Skip to content

Commit 929ca89

Browse files
Andrzej Hajdarafaeljw
authored andcommitted
cpufreq-dt: fix handling regulator_get_voltage() result
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. Link: http://permalink.gmane.org/gmane.linux.kernel/2038576 Signed-off-by: Andrzej Hajda <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 0df3502 commit 929ca89

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/cpufreq/cpufreq-dt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
5050
struct private_data *priv = policy->driver_data;
5151
struct device *cpu_dev = priv->cpu_dev;
5252
struct regulator *cpu_reg = priv->cpu_reg;
53-
unsigned long volt = 0, volt_old = 0, tol = 0;
53+
unsigned long volt = 0, tol = 0;
54+
int volt_old = 0;
5455
unsigned int old_freq, new_freq;
5556
long freq_Hz, freq_exact;
5657
int ret;
@@ -83,7 +84,7 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
8384
opp_freq / 1000, volt);
8485
}
8586

86-
dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
87+
dev_dbg(cpu_dev, "%u MHz, %d mV --> %u MHz, %ld mV\n",
8788
old_freq / 1000, (volt_old > 0) ? volt_old / 1000 : -1,
8889
new_freq / 1000, volt ? volt / 1000 : -1);
8990

0 commit comments

Comments
 (0)