Skip to contentSkip to conversation

CLKDEV: return from clk_find as soon as we get maching clk

PATCH Superseded Viresh KUMAR 3 participants 4 messages Mar 2, 2010 – Mar 3, 2010 Arm (32-bit)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index aae5bc0..736dfba 100644
@@ -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
#1 lore raw

PATCH 1/1 CLKDEV: return from clk_find as soon as we get maching clk

Quoted 3 lines · Viresh KUMAR

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.

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.

#2 lore raw

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_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.

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.

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/  |
#3 lore raw

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.