aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2011-04-30 05:14:08 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-04-30 05:14:08 -0400
commite8bf8df9c296b782c32236c6a5893aec301320c7 (patch)
tree13b3749d6b912b84b069d83ca39b53bea5e23ac5 /drivers/clk
parent0f22072ab50cac7983f9660d33974b45184da4f9 (diff)
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>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clkdev.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 0fc0a79852de..6db161f64ae0 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -32,10 +32,9 @@ static DEFINE_MUTEX(clocks_mutex);
32 * Then we take the most specific entry - with the following 32 * Then we take the most specific entry - with the following
33 * order of precedence: dev+con > dev only > con only. 33 * order of precedence: dev+con > dev only > con only.
34 */ 34 */
35static struct clk *clk_find(const char *dev_id, const char *con_id) 35static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
36{ 36{
37 struct clk_lookup *p; 37 struct clk_lookup *p, *cl = NULL;
38 struct clk *clk = NULL;
39 int match, best = 0; 38 int match, best = 0;
40 39
41 list_for_each_entry(p, &clocks, node) { 40 list_for_each_entry(p, &clocks, node) {
@@ -52,27 +51,27 @@ static struct clk *clk_find(const char *dev_id, const char *con_id)
52 } 51 }
53 52
54 if (match > best) { 53 if (match > best) {
55 clk = p->clk; 54 cl = p;
56 if (match != 3) 55 if (match != 3)
57 best = match; 56 best = match;
58 else 57 else
59 break; 58 break;
60 } 59 }
61 } 60 }
62 return clk; 61 return cl;
63} 62}
64 63
65struct clk *clk_get_sys(const char *dev_id, const char *con_id) 64struct clk *clk_get_sys(const char *dev_id, const char *con_id)
66{ 65{
67 struct clk *clk; 66 struct clk_lookup *cl;
68 67
69 mutex_lock(&clocks_mutex); 68 mutex_lock(&clocks_mutex);
70 clk = clk_find(dev_id, con_id); 69 cl = clk_find(dev_id, con_id);
71 if (clk && !__clk_get(clk)) 70 if (cl && !__clk_get(cl->clk))
72 clk = NULL; 71 cl = NULL;
73 mutex_unlock(&clocks_mutex); 72 mutex_unlock(&clocks_mutex);
74 73
75 return clk ? clk : ERR_PTR(-ENOENT); 74 return cl ? cl->clk : ERR_PTR(-ENOENT);
76} 75}
77EXPORT_SYMBOL(clk_get_sys); 76EXPORT_SYMBOL(clk_get_sys);
78 77