[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>
This commit is contained in:
parent
1309d4e684
commit
a0dd005d1d
|
@ -23,18 +23,27 @@ static LIST_HEAD(clocks);
|
||||||
static DEFINE_MUTEX(clocks_mutex);
|
static DEFINE_MUTEX(clocks_mutex);
|
||||||
static DEFINE_SPINLOCK(clocks_lock);
|
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 *clk_get(struct device *dev, const char *id)
|
||||||
{
|
{
|
||||||
struct clk *p, *clk = ERR_PTR(-ENOENT);
|
struct clk *p, *clk = ERR_PTR(-ENOENT);
|
||||||
|
|
||||||
mutex_lock(&clocks_mutex);
|
mutex_lock(&clocks_mutex);
|
||||||
list_for_each_entry(p, &clocks, node) {
|
p = clk_lookup(dev, id);
|
||||||
if (strcmp(id, p->name) == 0 &&
|
if (!p)
|
||||||
(p->dev == NULL || p->dev == dev)) {
|
p = clk_lookup(NULL, id);
|
||||||
|
if (p)
|
||||||
clk = p;
|
clk = p;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mutex_unlock(&clocks_mutex);
|
mutex_unlock(&clocks_mutex);
|
||||||
|
|
||||||
return clk;
|
return clk;
|
||||||
|
|
Loading…
Reference in New Issue