diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-02-17 05:35:15 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-02-17 05:41:59 -0500 |
commit | a0dd005d1d9f4c3beab52086f3844ef9342d1e67 (patch) | |
tree | df87f09d8fc0a6cba0a2e341e8835767da1a714e /arch/arm | |
parent | 1309d4e68497184d2fd87e892ddf14076c2bda98 (diff) |
[ARM] pxa: fix clock lookup to find specific device clocks
Ensure that the clock lookup always finds an entry for a specific
device and ID before it falls back to finding just by ID. This
fixes a problem reported by Holger Schurig where the BTUART was
assigned the wrong clock.
Tested-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-pxa/clock.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c index 83ef5ecaf432..df5ae2710ab1 100644 --- a/arch/arm/mach-pxa/clock.c +++ b/arch/arm/mach-pxa/clock.c | |||
@@ -23,18 +23,27 @@ static LIST_HEAD(clocks); | |||
23 | static DEFINE_MUTEX(clocks_mutex); | 23 | static DEFINE_MUTEX(clocks_mutex); |
24 | static DEFINE_SPINLOCK(clocks_lock); | 24 | static DEFINE_SPINLOCK(clocks_lock); |
25 | 25 | ||
26 | static struct clk *clk_lookup(struct device *dev, const char *id) | ||
27 | { | ||
28 | struct clk *p; | ||
29 | |||
30 | list_for_each_entry(p, &clocks, node) | ||
31 | if (strcmp(id, p->name) == 0 && p->dev == dev) | ||
32 | return p; | ||
33 | |||
34 | return NULL; | ||
35 | } | ||
36 | |||
26 | struct clk *clk_get(struct device *dev, const char *id) | 37 | struct clk *clk_get(struct device *dev, const char *id) |
27 | { | 38 | { |
28 | struct clk *p, *clk = ERR_PTR(-ENOENT); | 39 | struct clk *p, *clk = ERR_PTR(-ENOENT); |
29 | 40 | ||
30 | mutex_lock(&clocks_mutex); | 41 | mutex_lock(&clocks_mutex); |
31 | list_for_each_entry(p, &clocks, node) { | 42 | p = clk_lookup(dev, id); |
32 | if (strcmp(id, p->name) == 0 && | 43 | if (!p) |
33 | (p->dev == NULL || p->dev == dev)) { | 44 | p = clk_lookup(NULL, id); |
34 | clk = p; | 45 | if (p) |
35 | break; | 46 | clk = p; |
36 | } | ||
37 | } | ||
38 | mutex_unlock(&clocks_mutex); | 47 | mutex_unlock(&clocks_mutex); |
39 | 48 | ||
40 | return clk; | 49 | return clk; |