CLKDEV: return from clk_find as soon as we get maching clk
PATCH 1/1 CLKDEV: return from clk_find as soon as we get maching clk
clk_find function looks for clock with matching dev_id and con_id. We should return from clk_find as soon as we get a clock with matching dev_id and con_id. This can be done by comparing variable "match" with 3.
--- arch/arm/common/clkdev.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/common/clkdev.c +3 -0
@@ -55,6 +55,9 @@ static struct clk *clk_find(const char *dev_id, const char *con_id)if (match ==0 )continue ; +if (match ==3 ) +return p->clk; +if (match > best) { clk = p->clk; best = match;
Signature · 1 line
1.6.0.2
PATCH 1/1 CLKDEV: return from clk_find as soon as we get maching clk
Quoted 3 lines · Viresh KUMAR
clk_findfunction looks for clock with matchingdev_idandcon_id. We should return fromclk_findas soon as we get a clock with matchingdev_idandcon_id. This can be done by comparing variable "match" with 3.
This breaks the semantics function. Please look again at the code you're modifying, and ascertain whether you're changing the semantics of it, particularly with respect to what happens _in addition_ to returning the struct clk.
Hint: "return p->clk" is insufficient.
PATCH 1/1 CLKDEV: return from clk_find as soon as we get maching clk
Hello,
Quoted 11 lines · Russell King - ARM Linux
Quoted 3 lines · Viresh KUMAR
clk_findfunction looks for clock with matchingdev_idandcon_id. We should return fromclk_findas soon as we get a clock with matchingdev_idandcon_id. This can be done by comparing variable "match" with 3.This breaks the semantics function. Please look again at the code you're modifying, and ascertain whether you're changing the semantics of it, particularly with respect to what happens
_inaddition_to returning the struct clk.Hint: "return
p->clk" is insufficient.
I starred a the code a bit, but I don't see the problem here. match is always <= 3 so if it is 3 in one iteration best increases to 3 and clk isn't touched anymore. The other statements in the loop have no side effects either.
Apart from that a while back I thought about removing
if (match == 0) continue;
as if match is 0 the next if condition is false. I don't remember why I didn't do it. Maybe I checked the generated code and it made no difference.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 CLKDEV: return from clk_find as soon as we get maching clk
Quoted 4 lines · Uwe Kleine-K?nig
I starred a the code a bit, but I don't see the problem here. match is always <= 3 so if it is 3 in one iteration best increases to 3 and clk isn't touched anymore. The other statements in the loop have no side effects either.
Yes, you're right - I thought there was some additional code at the end of the function - was thinking of a previous revision of the code.
I'd still prefer the conditional code to be a 'clk = p->clk; break;' though, to keep the flow of the code the same.