提交 306c342f 编写于 作者: S Stephen Boyd

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: NTomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
上级 50595f8b
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/printk.h> #include <linux/printk.h>
#include "clk.h"
static int __set_clk_parents(struct device_node *node, bool clk_supplier) static int __set_clk_parents(struct device_node *node, bool clk_supplier)
{ {
...@@ -39,7 +38,7 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier) ...@@ -39,7 +38,7 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)
} }
if (clkspec.np == node && !clk_supplier) if (clkspec.np == node && !clk_supplier)
return 0; return 0;
pclk = of_clk_get_by_clkspec(&clkspec); pclk = of_clk_get_from_provider(&clkspec);
if (IS_ERR(pclk)) { if (IS_ERR(pclk)) {
pr_warn("clk: couldn't get parent clock %d for %s\n", pr_warn("clk: couldn't get parent clock %d for %s\n",
index, node->full_name); index, node->full_name);
...@@ -54,7 +53,7 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier) ...@@ -54,7 +53,7 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)
rc = 0; rc = 0;
goto err; goto err;
} }
clk = of_clk_get_by_clkspec(&clkspec); clk = of_clk_get_from_provider(&clkspec);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
pr_warn("clk: couldn't get parent clock %d for %s\n", pr_warn("clk: couldn't get parent clock %d for %s\n",
index, node->full_name); index, node->full_name);
...@@ -98,7 +97,7 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier) ...@@ -98,7 +97,7 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
if (clkspec.np == node && !clk_supplier) if (clkspec.np == node && !clk_supplier)
return 0; return 0;
clk = of_clk_get_by_clkspec(&clkspec); clk = of_clk_get_from_provider(&clkspec);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
pr_warn("clk: couldn't get clock %d for %s\n", pr_warn("clk: couldn't get clock %d for %s\n",
index, node->full_name); index, node->full_name);
......
...@@ -2857,17 +2857,6 @@ static const struct of_device_id __clk_of_table_sentinel ...@@ -2857,17 +2857,6 @@ static const struct of_device_id __clk_of_table_sentinel
static LIST_HEAD(of_clk_providers); static LIST_HEAD(of_clk_providers);
static DEFINE_MUTEX(of_clk_mutex); 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, struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec,
void *data) void *data)
{ {
...@@ -2951,7 +2940,11 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, ...@@ -2951,7 +2940,11 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
struct of_clk_provider *provider; struct of_clk_provider *provider;
struct clk *clk = ERR_PTR(-EPROBE_DEFER); struct clk *clk = ERR_PTR(-EPROBE_DEFER);
if (!clkspec)
return ERR_PTR(-EINVAL);
/* Check if we have such a provider in our array */ /* Check if we have such a provider in our array */
mutex_lock(&of_clk_mutex);
list_for_each_entry(provider, &of_clk_providers, link) { list_for_each_entry(provider, &of_clk_providers, link) {
if (provider->node == clkspec->np) if (provider->node == clkspec->np)
clk = provider->get(clkspec, provider->data); clk = provider->get(clkspec, provider->data);
...@@ -2967,19 +2960,22 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, ...@@ -2967,19 +2960,22 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
break; break;
} }
} }
mutex_unlock(&of_clk_mutex);
return clk; 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 *of_clk_get_from_provider(struct of_phandle_args *clkspec)
{ {
struct clk *clk; return __of_clk_get_from_provider(clkspec, NULL, __func__);
mutex_lock(&of_clk_mutex);
clk = __of_clk_get_from_provider(clkspec, NULL, __func__);
mutex_unlock(&of_clk_mutex);
return clk;
} }
int of_clk_get_parent_count(struct device_node *np) int of_clk_get_parent_count(struct device_node *np)
......
...@@ -12,11 +12,8 @@ ...@@ -12,11 +12,8 @@
struct clk_hw; struct clk_hw;
#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec);
struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
const char *dev_id, const char *con_id); const char *dev_id, const char *con_id);
void of_clk_lock(void);
void of_clk_unlock(void);
#endif #endif
#ifdef CONFIG_COMMON_CLK #ifdef CONFIG_COMMON_CLK
......
...@@ -28,34 +28,6 @@ static LIST_HEAD(clocks); ...@@ -28,34 +28,6 @@ static LIST_HEAD(clocks);
static DEFINE_MUTEX(clocks_mutex); static DEFINE_MUTEX(clocks_mutex);
#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
static struct clk *__of_clk_get_by_clkspec(struct of_phandle_args *clkspec,
const char *dev_id, const char *con_id)
{
struct clk *clk;
if (!clkspec)
return ERR_PTR(-EINVAL);
of_clk_lock();
clk = __of_clk_get_from_provider(clkspec, dev_id, con_id);
of_clk_unlock();
return clk;
}
/**
* of_clk_get_by_clkspec() - Lookup a clock form 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_by_clkspec(struct of_phandle_args *clkspec)
{
return __of_clk_get_by_clkspec(clkspec, NULL, __func__);
}
static struct clk *__of_clk_get(struct device_node *np, int index, static struct clk *__of_clk_get(struct device_node *np, int index,
const char *dev_id, const char *con_id) const char *dev_id, const char *con_id)
{ {
...@@ -71,7 +43,7 @@ static struct clk *__of_clk_get(struct device_node *np, int index, ...@@ -71,7 +43,7 @@ static struct clk *__of_clk_get(struct device_node *np, int index,
if (rc) if (rc)
return ERR_PTR(rc); return ERR_PTR(rc);
clk = __of_clk_get_by_clkspec(&clkspec, dev_id, con_id); clk = __of_clk_get_from_provider(&clkspec, dev_id, con_id);
of_node_put(clkspec.np); of_node_put(clkspec.np);
return clk; return clk;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册