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>

+9 -10
+9 -10
drivers/clk/clkdev.c
··· 32 * Then we take the most specific entry - with the following 33 * order of precedence: dev+con > dev only > con only. 34 */ 35 - static struct clk *clk_find(const char *dev_id, const char *con_id) 36 { 37 - struct clk_lookup *p; 38 - struct clk *clk = NULL; 39 int match, best = 0; 40 41 list_for_each_entry(p, &clocks, node) { ··· 51 } 52 53 if (match > best) { 54 - clk = p->clk; 55 if (match != 3) 56 best = match; 57 else 58 break; 59 } 60 } 61 - return clk; 62 } 63 64 struct clk *clk_get_sys(const char *dev_id, const char *con_id) 65 { 66 - struct clk *clk; 67 68 mutex_lock(&clocks_mutex); 69 - clk = clk_find(dev_id, con_id); 70 - if (clk && !__clk_get(clk)) 71 - clk = NULL; 72 mutex_unlock(&clocks_mutex); 73 74 - return clk ? clk : ERR_PTR(-ENOENT); 75 } 76 EXPORT_SYMBOL(clk_get_sys); 77
··· 32 * Then we take the most specific entry - with the following 33 * order of precedence: dev+con > dev only > con only. 34 */ 35 + static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) 36 { 37 + struct clk_lookup *p, *cl = NULL; 38 int match, best = 0; 39 40 list_for_each_entry(p, &clocks, node) { ··· 52 } 53 54 if (match > best) { 55 + cl = p; 56 if (match != 3) 57 best = match; 58 else 59 break; 60 } 61 } 62 + return cl; 63 } 64 65 struct clk *clk_get_sys(const char *dev_id, const char *con_id) 66 { 67 + struct clk_lookup *cl; 68 69 mutex_lock(&clocks_mutex); 70 + cl = clk_find(dev_id, con_id); 71 + if (cl && !__clk_get(cl->clk)) 72 + cl = NULL; 73 mutex_unlock(&clocks_mutex); 74 75 + return cl ? cl->clk : ERR_PTR(-ENOENT); 76 } 77 EXPORT_SYMBOL(clk_get_sys); 78