CLKDEV: Fix clkdev return value for NULL clk case
clkdev may incorrectly cause a clkdev entry with a NULL clk to return -ENOENT. This is not the intention of this code; -ENOENT should only be returned if the clock entry can not be found in the table. Fix this. Reported-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
@@ -32,10 +32,9 @@ static DEFINE_MUTEX(clocks_mutex);
|
|||||||
* Then we take the most specific entry - with the following
|
* Then we take the most specific entry - with the following
|
||||||
* order of precedence: dev+con > dev only > con only.
|
* order of precedence: dev+con > dev only > con only.
|
||||||
*/
|
*/
|
||||||
static struct clk *clk_find(const char *dev_id, const char *con_id)
|
static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
|
||||||
{
|
{
|
||||||
struct clk_lookup *p;
|
struct clk_lookup *p, *cl = NULL;
|
||||||
struct clk *clk = NULL;
|
|
||||||
int match, best = 0;
|
int match, best = 0;
|
||||||
|
|
||||||
list_for_each_entry(p, &clocks, node) {
|
list_for_each_entry(p, &clocks, node) {
|
||||||
@@ -52,27 +51,27 @@ static struct clk *clk_find(const char *dev_id, const char *con_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (match > best) {
|
if (match > best) {
|
||||||
clk = p->clk;
|
cl = p;
|
||||||
if (match != 3)
|
if (match != 3)
|
||||||
best = match;
|
best = match;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return clk;
|
return cl;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct clk *clk_get_sys(const char *dev_id, const char *con_id)
|
struct clk *clk_get_sys(const char *dev_id, const char *con_id)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_lookup *cl;
|
||||||
|
|
||||||
mutex_lock(&clocks_mutex);
|
mutex_lock(&clocks_mutex);
|
||||||
clk = clk_find(dev_id, con_id);
|
cl = clk_find(dev_id, con_id);
|
||||||
if (clk && !__clk_get(clk))
|
if (cl && !__clk_get(cl->clk))
|
||||||
clk = NULL;
|
cl = NULL;
|
||||||
mutex_unlock(&clocks_mutex);
|
mutex_unlock(&clocks_mutex);
|
||||||
|
|
||||||
return clk ? clk : ERR_PTR(-ENOENT);
|
return cl ? cl->clk : ERR_PTR(-ENOENT);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(clk_get_sys);
|
EXPORT_SYMBOL(clk_get_sys);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user