diff options
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r-- | drivers/clk/clk.c | 32 |
1 files changed, 14 insertions, 18 deletions
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 static LIST_HEAD(of_clk_providers); static DEFINE_MUTEX(of_clk_mutex); -/* of_clk_provider list locking helpers */ -void of_clk_lock(void) -{ - mutex_lock(&of_clk_mutex); -} - -void of_clk_unlock(void) -{ - mutex_unlock(&of_clk_mutex); -} - struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, void *data) { @@ -2951,7 +2940,11 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, struct of_clk_provider *provider; struct clk *clk = ERR_PTR(-EPROBE_DEFER); + if (!clkspec) + return ERR_PTR(-EINVAL); + /* Check if we have such a provider in our array */ + mutex_lock(&of_clk_mutex); list_for_each_entry(provider, &of_clk_providers, link) { if (provider->node == clkspec->np) clk = provider->get(clkspec, provider->data); @@ -2967,19 +2960,22 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, break; } } + mutex_unlock(&of_clk_mutex); return clk; } +/** + * of_clk_get_from_provider() - Lookup a clock from a clock provider + * @clkspec: pointer to a clock specifier data structure + * + * This function looks up a struct clk from the registered list of clock + * providers, an input is a clock specifier data structure as returned + * from the of_parse_phandle_with_args() function call. + */ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) { - struct clk *clk; - - mutex_lock(&of_clk_mutex); - clk = __of_clk_get_from_provider(clkspec, NULL, __func__); - mutex_unlock(&of_clk_mutex); - - return clk; + return __of_clk_get_from_provider(clkspec, NULL, __func__); } int of_clk_get_parent_count(struct device_node *np) |