diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2014-05-19 13:22:50 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-05-22 18:54:59 -0400 |
commit | 7f05e28f9dd3eb7a3f27c6f50b715995dc7a88c5 (patch) | |
tree | ffde9347941f4ee8cfa9112e15bb9a8138bc3be8 /drivers/clk | |
parent | 222cb1bf180e413e1816aaf4166e4f56e72201d8 (diff) |
clk: Add of_clk_get_by_clkspec() helper
This patch adds of_clk_get_by_clkspec() helper function, which does only
a struct clk lookup from the clock providers. It is used in the subsequent
patch where parsing of a clock from device tree and the lookup from
providers needed to be split.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.h | 1 | ||||
-rw-r--r-- | drivers/clk/clkdev.c | 34 |
2 files changed, 28 insertions, 7 deletions
diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index 795cc9f0dac0..c798138f023f 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) | 12 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) |
13 | struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec); | ||
13 | struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec); | 14 | struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec); |
14 | void of_clk_lock(void); | 15 | void of_clk_lock(void); |
15 | void of_clk_unlock(void); | 16 | void of_clk_unlock(void); |
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index a360b2eca5cb..f890b901c6bc 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c | |||
@@ -27,6 +27,32 @@ static LIST_HEAD(clocks); | |||
27 | static DEFINE_MUTEX(clocks_mutex); | 27 | static DEFINE_MUTEX(clocks_mutex); |
28 | 28 | ||
29 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) | 29 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) |
30 | |||
31 | /** | ||
32 | * of_clk_get_by_clkspec() - Lookup a clock form a clock provider | ||
33 | * @clkspec: pointer to a clock specifier data structure | ||
34 | * | ||
35 | * This function looks up a struct clk from the registered list of clock | ||
36 | * providers, an input is a clock specifier data structure as returned | ||
37 | * from the of_parse_phandle_with_args() function call. | ||
38 | */ | ||
39 | struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec) | ||
40 | { | ||
41 | struct clk *clk; | ||
42 | |||
43 | if (!clkspec) | ||
44 | return ERR_PTR(-EINVAL); | ||
45 | |||
46 | of_clk_lock(); | ||
47 | clk = __of_clk_get_from_provider(clkspec); | ||
48 | |||
49 | if (!IS_ERR(clk) && !__clk_get(clk)) | ||
50 | clk = ERR_PTR(-ENOENT); | ||
51 | |||
52 | of_clk_unlock(); | ||
53 | return clk; | ||
54 | } | ||
55 | |||
30 | struct clk *of_clk_get(struct device_node *np, int index) | 56 | struct clk *of_clk_get(struct device_node *np, int index) |
31 | { | 57 | { |
32 | struct of_phandle_args clkspec; | 58 | struct of_phandle_args clkspec; |
@@ -41,13 +67,7 @@ struct clk *of_clk_get(struct device_node *np, int index) | |||
41 | if (rc) | 67 | if (rc) |
42 | return ERR_PTR(rc); | 68 | return ERR_PTR(rc); |
43 | 69 | ||
44 | of_clk_lock(); | 70 | clk = of_clk_get_by_clkspec(&clkspec); |
45 | clk = __of_clk_get_from_provider(&clkspec); | ||
46 | |||
47 | if (!IS_ERR(clk) && !__clk_get(clk)) | ||
48 | clk = ERR_PTR(-ENOENT); | ||
49 | |||
50 | of_clk_unlock(); | ||
51 | of_node_put(clkspec.np); | 71 | of_node_put(clkspec.np); |
52 | return clk; | 72 | return clk; |
53 | } | 73 | } |