clk: vt8500: several forever loops
Subsystems (2)
PATCH 1/1 clk: vt8500: several forever loops
This does a bunch of looping like this:
for (div2 = 7; div2 >= 0; div2--)
But unsigned values are always greater than or equal to zero so it just loops and loops. Really "mul", "div1" and "div2" should all be declared as int for cleanliness sake.
---
Static checker stuff.
drivers/clk/clk-vt8500.c +3 -3
@@ -363,7 +363,7 @@ static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,static void wm8650_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;
@@ -431,7 +431,7 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)static void wm8750_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *filter,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;
@@ -475,7 +475,7 @@ static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,static void wm8850_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;
This patch is still needed in linux-next. It was Acked by Tony Prisk in a private email.
regards,
dan carpenter
Quoted 43 lines · Dan Carpenter
This does a bunch of looping like this:
for (div2 = 7; div2 >= 0; div2--)But unsigned values are always greater than or equal to zero so it just loops and loops. Really "mul", "div1" and "div2" should all be declared as int for cleanliness sake.
Signed-off-by Dan Carpenter <[email protected]>---
Static checker stuff.drivers/clk/clk-vt8500.c +3
-3@@ -363,7 +363,7 @@ static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,static void wm8650_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;@@ -431,7 +431,7 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)static void wm8750_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *filter,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;@@ -475,7 +475,7 @@ static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,static void wm8850_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;
Quoted 17 lines · Dan Carpenter
This patch is still needed in linux-next. It was Acked by Tony Prisk in a private email.
Acked-by Tony Prisk <[email protected]>regards,
dan carpenterQuoted 8 lines · Dan Carpenter
This does a bunch of looping like this:
for (div2 = 7; div2 >= 0; div2--)But unsigned values are always greater than or equal to zero so it just loops and loops. Really "mul", "div1" and "div2" should all be declared as int for cleanliness sake.
Apologies if this is a silly question from someone who is utterly uninformed, but are values = 0 even legal for divisors? It seems that, at least in some cases, 'div - 1' is or'ed into a register value (WM8850_BITS_TO_VAL), and I don't think you are expecting negative values there.
So perhaps instead, change the test to '> 0' ??
Regards,
Ard.
Quoted 40 lines
Quoted 27 lines
Signed-off-by Dan Carpenter <[email protected]>---
Static checker stuff.drivers/clk/clk-vt8500.c +2
-2@@ -363,7 +363,7 @@ static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,static void wm8650_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;@@ -431,7 +431,7 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)static void wm8750_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *filter,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;drivers/clk/clk-vt8500.c static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate, · line 481
Quoted 8 lines
drivers/clk/clk-vt8500.c +1
-1@@ -475,7 +475,7 @@ static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,static void wm8850_find_pll_bits (unsigned long rate,unsigned long parent_rate,u32 *multiplier,u32 *divisor1,u32 *divisor2) { -u32 mul, div1, div2; +int mul, div1, div2;u32 best_mul, best_div1, best_div2;unsigned long tclk, rate_err, best_err;_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 19 lines · Ard Biesheuvel
Quoted 17 lines · Dan Carpenter
This patch is still needed in linux-next. It was Acked by Tony Prisk in a private email.
Acked-by Tony Prisk <[email protected]>regards,
dan carpenterQuoted 8 lines · Dan Carpenter
This does a bunch of looping like this:
for (div2 = 7; div2 >= 0; div2--)But unsigned values are always greater than or equal to zero so it just loops and loops. Really "mul", "div1" and "div2" should all be declared as int for cleanliness sake.
Quoted 6 lines
Apologies if this is a silly question from someone who is utterly uninformed, but are values = 0 even legal for divisors? It seems that, at least in some cases, 'div - 1' is or'ed into a register value (
WM8850_BITS_TO_VAL), and I don't think you are expecting negative values there.
So perhaps instead, change the test to '> 0' ??
Those seem like totally valid points. The truth is that I almost am "utterly uninformed" about this code. Perhaps someone who knows more than the both of us could take a look?
Please give Ard and me reported by tags when you fix this.
regards,
dan carpenter