diff options
author | Stephen Boyd <sboyd@codeaurora.org> | 2015-02-05 18:39:11 -0500 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2015-03-12 15:20:34 -0400 |
commit | 306c342f9cb1f573af57a6afd1b3549aa97b9281 (patch) | |
tree | 12b6028e71456ca59e0f2632c38b27e1e085c2c4 | |
parent | 50595f8b9e78b3c80d341bf9da3e7848d9abbe2a (diff) |
clk: Replace of_clk_get_by_clkspec() with of_clk_get_from_provider()
of_clk_get_by_clkspec() has the same function signature as
of_clk_get_from_provider()
struct clk *of_clk_get_by_clkspec(struct of_phandle_args
*clkspec)
struct clk *of_clk_get_from_provider(struct of_phandle_args
*clkspec)
except of_clk_get_by_clkspec() checks to make sure clkspec is not
NULL. Let's remove of_clk_get_by_clkspec() and replace the
callers of it (clkconf.c) with of_clk_get_from_provider().
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r-- | drivers/clk/clk-conf.c | 7 | ||||
-rw-r--r-- | drivers/clk/clk.c | 32 | ||||
-rw-r--r-- | drivers/clk/clk.h | 3 | ||||
-rw-r--r-- | drivers/clk/clkdev.c | 30 |
4 files changed, 18 insertions, 54 deletions
diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c index aad4796aa3ed..48a65b2b4027 100644 --- a/drivers/clk/clk-conf.c +++ b/drivers/clk/clk-conf.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/device.h> | 13 | #include <linux/device.h> |
14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
15 | #include <linux/printk.h> | 15 | #include <linux/printk.h> |
16 | #include "clk.h" | ||
17 | 16 | ||
18 | static int __set_clk_parents(struct device_node *node, bool clk_supplier) | 17 | static int __set_clk_parents(struct device_node *node, bool clk_supplier) |
19 | { | 18 | { |
@@ -39,7 +38,7 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier) | |||
39 | } | 38 | } |
40 | if (clkspec.np == node && !clk_supplier) | 39 | if (clkspec.np == node && !clk_supplier) |
41 | return 0; | 40 | return 0; |
42 | pclk = of_clk_get_by_clkspec(&clkspec); | 41 | pclk = of_clk_get_from_provider(&clkspec); |
43 | if (IS_ERR(pclk)) { | 42 | if (IS_ERR(pclk)) { |
44 | pr_warn("clk: couldn't get parent clock %d for %s\n", | 43 | pr_warn("clk: couldn't get parent clock %d for %s\n", |
45 | index, node->full_name); | 44 | index, node->full_name); |
@@ -54,7 +53,7 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier) | |||
54 | rc = 0; | 53 | rc = 0; |
55 | goto err; | 54 | goto err; |
56 | } | 55 | } |
57 | clk = of_clk_get_by_clkspec(&clkspec); | 56 | clk = of_clk_get_from_provider(&clkspec); |
58 | if (IS_ERR(clk)) { | 57 | if (IS_ERR(clk)) { |
59 | pr_warn("clk: couldn't get parent clock %d for %s\n", | 58 | pr_warn("clk: couldn't get parent clock %d for %s\n", |
60 | index, node->full_name); | 59 | index, node->full_name); |
@@ -98,7 +97,7 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier) | |||
98 | if (clkspec.np == node && !clk_supplier) | 97 | if (clkspec.np == node && !clk_supplier) |
99 | return 0; | 98 | return 0; |
100 | 99 | ||
101 | clk = of_clk_get_by_clkspec(&clkspec); | 100 | clk = of_clk_get_from_provider(&clkspec); |
102 | if (IS_ERR(clk)) { | 101 | if (IS_ERR(clk)) { |
103 | pr_warn("clk: couldn't get clock %d for %s\n", | 102 | pr_warn("clk: couldn't get clock %d for %s\n", |
104 | index, node->full_name); | 103 | index, node->full_name); |
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 024d78316b38..9872ec255f9a 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -2857,17 +2857,6 @@ static const struct of_device_id __clk_of_table_sentinel | |||
2857 | static LIST_HEAD(of_clk_providers); | 2857 | static LIST_HEAD(of_clk_providers); |
2858 | static DEFINE_MUTEX(of_clk_mutex); | 2858 | static DEFINE_MUTEX(of_clk_mutex); |
2859 | 2859 | ||
2860 | /* of_clk_provider list locking helpers */ | ||
2861 | void of_clk_lock(void) | ||
2862 | { | ||
2863 | mutex_lock(&of_clk_mutex); | ||
2864 | } | ||
2865 | |||
2866 | void of_clk_unlock(void) | ||
2867 | { | ||
2868 | mutex_unlock(&of_clk_mutex); | ||
2869 | } | ||
2870 | |||
2871 | struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, | 2860 | struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, |
2872 | void *data) | 2861 | void *data) |
2873 | { | 2862 | { |
@@ -2951,7 +2940,11 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, | |||
2951 | struct of_clk_provider *provider; | 2940 | struct of_clk_provider *provider; |
2952 | struct clk *clk = ERR_PTR(-EPROBE_DEFER); | 2941 | struct clk *clk = ERR_PTR(-EPROBE_DEFER); |
2953 | 2942 | ||
2943 | if (!clkspec) | ||
2944 | return ERR_PTR(-EINVAL); | ||
2945 | |||
2954 | /* Check if we have such a provider in our array */ | 2946 | /* Check if we have such a provider in our array */ |
2947 | mutex_lock(&of_clk_mutex); | ||
2955 | list_for_each_entry(provider, &of_clk_providers, link) { | 2948 | list_for_each_entry(provider, &of_clk_providers, link) { |
2956 | if (provider->node == clkspec->np) | 2949 | if (provider->node == clkspec->np) |
2957 | clk = provider->get(clkspec, provider->data); | 2950 | clk = provider->get(clkspec, provider->data); |
@@ -2967,19 +2960,22 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, | |||
2967 | break; | 2960 | break; |
2968 | } | 2961 | } |
2969 | } | 2962 | } |
2963 | mutex_unlock(&of_clk_mutex); | ||
2970 | 2964 | ||
2971 | return clk; | 2965 | return clk; |
2972 | } | 2966 | } |
2973 | 2967 | ||
2968 | /** | ||
2969 | * of_clk_get_from_provider() - Lookup a clock from a clock provider | ||
2970 | * @clkspec: pointer to a clock specifier data structure | ||
2971 | * | ||
2972 | * This function looks up a struct clk from the registered list of clock | ||
2973 | * providers, an input is a clock specifier data structure as returned | ||
2974 | * from the of_parse_phandle_with_args() function call. | ||
2975 | */ | ||
2974 | struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) | 2976 | struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) |
2975 | { | 2977 | { |
2976 | struct clk *clk; | 2978 | return __of_clk_get_from_provider(clkspec, NULL, __func__); |
2977 | |||
2978 | mutex_lock(&of_clk_mutex); | ||
2979 | clk = __of_clk_get_from_provider(clkspec, NULL, __func__); | ||
2980 | mutex_unlock(&of_clk_mutex); | ||
2981 | |||
2982 | return clk; | ||
2983 | } | 2979 | } |
2984 | 2980 | ||
2985 | int of_clk_get_parent_count(struct device_node *np) | 2981 | int of_clk_get_parent_count(struct device_node *np) |
diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index ba845408cc3e..00b35a13cdf3 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h | |||
@@ -12,11 +12,8 @@ | |||
12 | struct clk_hw; | 12 | struct clk_hw; |
13 | 13 | ||
14 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) | 14 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) |
15 | struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec); | ||
16 | struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, | 15 | struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, |
17 | const char *dev_id, const char *con_id); | 16 | const char *dev_id, const char *con_id); |
18 | void of_clk_lock(void); | ||
19 | void of_clk_unlock(void); | ||
20 | #endif | 17 | #endif |
21 | 18 | ||
22 | #ifdef CONFIG_COMMON_CLK | 19 | #ifdef CONFIG_COMMON_CLK |
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 043fd3633373..1fcb6ef2cdac 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c | |||
@@ -28,34 +28,6 @@ static LIST_HEAD(clocks); | |||
28 | static DEFINE_MUTEX(clocks_mutex); | 28 | static DEFINE_MUTEX(clocks_mutex); |
29 | 29 | ||
30 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) | 30 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) |
31 | |||
32 | static struct clk *__of_clk_get_by_clkspec(struct of_phandle_args *clkspec, | ||
33 | const char *dev_id, const char *con_id) | ||
34 | { | ||
35 | struct clk *clk; | ||
36 | |||
37 | if (!clkspec) | ||
38 | return ERR_PTR(-EINVAL); | ||
39 | |||
40 | of_clk_lock(); | ||
41 | clk = __of_clk_get_from_provider(clkspec, dev_id, con_id); | ||
42 | of_clk_unlock(); | ||
43 | return clk; | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * of_clk_get_by_clkspec() - Lookup a clock form a clock provider | ||
48 | * @clkspec: pointer to a clock specifier data structure | ||
49 | * | ||
50 | * This function looks up a struct clk from the registered list of clock | ||
51 | * providers, an input is a clock specifier data structure as returned | ||
52 | * from the of_parse_phandle_with_args() function call. | ||
53 | */ | ||
54 | struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec) | ||
55 | { | ||
56 | return __of_clk_get_by_clkspec(clkspec, NULL, __func__); | ||
57 | } | ||
58 | |||
59 | static struct clk *__of_clk_get(struct device_node *np, int index, | 31 | static struct clk *__of_clk_get(struct device_node *np, int index, |
60 | const char *dev_id, const char *con_id) | 32 | const char *dev_id, const char *con_id) |
61 | { | 33 | { |
@@ -71,7 +43,7 @@ static struct clk *__of_clk_get(struct device_node *np, int index, | |||
71 | if (rc) | 43 | if (rc) |
72 | return ERR_PTR(rc); | 44 | return ERR_PTR(rc); |
73 | 45 | ||
74 | clk = __of_clk_get_by_clkspec(&clkspec, dev_id, con_id); | 46 | clk = __of_clk_get_from_provider(&clkspec, dev_id, con_id); |
75 | of_node_put(clkspec.np); | 47 | of_node_put(clkspec.np); |
76 | 48 | ||
77 | return clk; | 49 | return clk; |