Skip to content

Commit

Permalink
[ARM] pxa: fix clock lookup to find specific device clocks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Russell King authored and Russell King committed Feb 17, 2008
1 parent 1309d4e commit a0dd005
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions arch/arm/mach-pxa/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,27 @@ static LIST_HEAD(clocks);
static DEFINE_MUTEX(clocks_mutex);
static DEFINE_SPINLOCK(clocks_lock);

static struct clk *clk_lookup(struct device *dev, const char *id)
{
struct clk *p;

list_for_each_entry(p, &clocks, node)
if (strcmp(id, p->name) == 0 && p->dev == dev)
return p;

return NULL;
}

struct clk *clk_get(struct device *dev, const char *id)
{
struct clk *p, *clk = ERR_PTR(-ENOENT);

mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) {
if (strcmp(id, p->name) == 0 &&
(p->dev == NULL || p->dev == dev)) {
clk = p;
break;
}
}
p = clk_lookup(dev, id);
if (!p)
p = clk_lookup(NULL, id);
if (p)
clk = p;
mutex_unlock(&clocks_mutex);

return clk;
Expand Down

0 comments on commit a0dd005

Please sign in to comment.