Skip to contentSkip to conversation

arm: tegra: fix error check in tegra2_clocks.c

PATCH In review Nicolas Kaiser 2 participants 2 messages Mar 30, 2011 – Apr 1, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: tegra: fix error check in tegra2_clocks.c

Checking 'rate < 0' doesn't work because 'rate' is unsigned.

---
Untested.

 arch/arm/mach-tegra/tegra2_clocks.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/mach-tegra/tegra2_clocks.c +5 -4
index 6d7c4ee..4459470 100644
@@ -1362,14 +1362,15 @@ static int tegra_clk_shared_bus_set_rate(struct clk *c, unsigned long rate)
 {
 	unsigned long flags;
 	int ret;
+	long new_rate = rate;
 
-	rate = clk_round_rate(c->parent, rate);
-	if (rate < 0)
-		return rate;
+	new_rate = clk_round_rate(c->parent, new_rate);
+	if (new_rate < 0)
+		return new_rate;
 
 	spin_lock_irqsave(&c->parent->spinlock, flags);
 
-	c->u.shared_bus_user.rate = rate;
+	c->u.shared_bus_user.rate = new_rate;
 	ret = tegra_clk_shared_bus_update(c->parent);
 
 	spin_unlock_irqrestore(&c->parent->spinlock, flags);
Signature · 1 line
1.7.3.4
Acked-by on v1 1/1
#1 lore raw
Quoted 34 lines · Nicolas Kaiser

Checking 'rate < 0' doesn't work because 'rate' is unsigned.

---
Untested.

?arch/arm/mach-tegra/tegra2_clocks.c | ? ?9 +++++---- ?1 files changed, 5 insertions(+), 4 deletions(-)

arch/arm/mach-tegra/tegra2_clocks.c +5 -5
index 6d7c4ee..4459470 100644
@@ -1362,14 +1362,15 @@ static int tegra_clk_shared_bus_set_rate(struct clk *c, unsigned long rate)
 ?{
 ? ? ? ?unsigned long flags;
 ? ? ? ?int ret;
+ ? ? ? long new_rate = rate;
 
- ? ? ? rate = clk_round_rate(c->parent, rate);
- ? ? ? if (rate < 0)
- ? ? ? ? ? ? ? return rate;
+ ? ? ? new_rate = clk_round_rate(c->parent, new_rate);
+ ? ? ? if (new_rate < 0)
+ ? ? ? ? ? ? ? return new_rate;
 
 ? ? ? ?spin_lock_irqsave(&c->parent->spinlock, flags);
 
- ? ? ? c->u.shared_bus_user.rate = rate;
+ ? ? ? c->u.shared_bus_user.rate = new_rate;
 ? ? ? ?ret = tegra_clk_shared_bus_update(c->parent);
 
 ? ? ? ?spin_unlock_irqrestore(&c->parent->spinlock, flags);
--
Quoted 2 lines

1.7.3.4