All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] CLKDEV: return from clk_find as soon as we get maching clk
@ 2010-03-02 11:05 Viresh KUMAR
  2010-03-02 20:39 ` Russell King - ARM Linux
  0 siblings, 1 reply; 4+ messages in thread
From: Viresh KUMAR @ 2010-03-02 11:05 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 arch/arm/common/clkdev.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/common/clkdev.c b/arch/arm/common/clkdev.c
index aae5bc0..736dfba 100644
--- a/arch/arm/common/clkdev.c
+++ b/arch/arm/common/clkdev.c
@@ -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;
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] CLKDEV: return from clk_find as soon as we get maching clk
  2010-03-02 11:05 [PATCH] CLKDEV: return from clk_find as soon as we get maching clk Viresh KUMAR
@ 2010-03-02 20:39 ` Russell King - ARM Linux
  2010-03-02 21:01   ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2010-03-02 20:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Mar 02, 2010 at 04:35:54PM +0530, Viresh KUMAR wrote:
> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] CLKDEV: return from clk_find as soon as we get maching clk
  2010-03-02 20:39 ` Russell King - ARM Linux
@ 2010-03-02 21:01   ` Uwe Kleine-König
  2010-03-03 19:44     ` Russell King - ARM Linux
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2010-03-02 21:01 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Tue, Mar 02, 2010 at 08:39:11PM +0000, Russell King - ARM Linux wrote:
> On Tue, Mar 02, 2010 at 04:35:54PM +0530, Viresh KUMAR wrote:
> > 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

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] CLKDEV: return from clk_find as soon as we get maching clk
  2010-03-02 21:01   ` Uwe Kleine-König
@ 2010-03-03 19:44     ` Russell King - ARM Linux
  0 siblings, 0 replies; 4+ messages in thread
From: Russell King - ARM Linux @ 2010-03-03 19:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Mar 02, 2010 at 10:01:38PM +0100, Uwe Kleine-K?nig wrote:
> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-03 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-02 11:05 [PATCH] CLKDEV: return from clk_find as soon as we get maching clk Viresh KUMAR
2010-03-02 20:39 ` Russell King - ARM Linux
2010-03-02 21:01   ` Uwe Kleine-König
2010-03-03 19:44     ` Russell King - ARM Linux

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.