Commit 2dd850ef authored by Stephen Boyd's avatar Stephen Boyd

Merge branch 'clk-devm-provider' into clk-next

* clk-devm-provider:
  clk: qcom: common: Migrate to devm_* APIs for resets and clk providers
  clk: Add devm_of_clk_add_hw_provider()/del_provider() APIs
parents ed9c62f7 b87206f8
...@@ -237,6 +237,7 @@ CLOCK ...@@ -237,6 +237,7 @@ CLOCK
devm_clk_get() devm_clk_get()
devm_clk_put() devm_clk_put()
devm_clk_hw_register() devm_clk_hw_register()
devm_of_clk_add_hw_provider()
DMA DMA
dmam_alloc_coherent() dmam_alloc_coherent()
......
...@@ -3275,6 +3275,37 @@ int of_clk_add_hw_provider(struct device_node *np, ...@@ -3275,6 +3275,37 @@ int of_clk_add_hw_provider(struct device_node *np,
} }
EXPORT_SYMBOL_GPL(of_clk_add_hw_provider); EXPORT_SYMBOL_GPL(of_clk_add_hw_provider);
static void devm_of_clk_release_provider(struct device *dev, void *res)
{
of_clk_del_provider(*(struct device_node **)res);
}
int devm_of_clk_add_hw_provider(struct device *dev,
struct clk_hw *(*get)(struct of_phandle_args *clkspec,
void *data),
void *data)
{
struct device_node **ptr, *np;
int ret;
ptr = devres_alloc(devm_of_clk_release_provider, sizeof(*ptr),
GFP_KERNEL);
if (!ptr)
return -ENOMEM;
np = dev->of_node;
ret = of_clk_add_hw_provider(np, get, data);
if (!ret) {
*ptr = np;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return ret;
}
EXPORT_SYMBOL_GPL(devm_of_clk_add_hw_provider);
/** /**
* of_clk_del_provider() - Remove a previously registered clock provider * of_clk_del_provider() - Remove a previously registered clock provider
* @np: Device node pointer associated with clock provider * @np: Device node pointer associated with clock provider
...@@ -3296,6 +3327,27 @@ void of_clk_del_provider(struct device_node *np) ...@@ -3296,6 +3327,27 @@ void of_clk_del_provider(struct device_node *np)
} }
EXPORT_SYMBOL_GPL(of_clk_del_provider); EXPORT_SYMBOL_GPL(of_clk_del_provider);
static int devm_clk_provider_match(struct device *dev, void *res, void *data)
{
struct device_node **np = res;
if (WARN_ON(!np || !*np))
return 0;
return *np == data;
}
void devm_of_clk_del_provider(struct device *dev)
{
int ret;
ret = devres_release(dev, devm_of_clk_release_provider,
devm_clk_provider_match, dev->of_node);
WARN_ON(ret);
}
EXPORT_SYMBOL(devm_of_clk_del_provider);
static struct clk_hw * static struct clk_hw *
__of_clk_get_hw_from_provider(struct of_clk_provider *provider, __of_clk_get_hw_from_provider(struct of_clk_provider *provider,
struct of_phandle_args *clkspec) struct of_phandle_args *clkspec)
......
...@@ -111,16 +111,6 @@ qcom_pll_set_fsm_mode(struct regmap *map, u32 reg, u8 bias_count, u8 lock_count) ...@@ -111,16 +111,6 @@ qcom_pll_set_fsm_mode(struct regmap *map, u32 reg, u8 bias_count, u8 lock_count)
} }
EXPORT_SYMBOL_GPL(qcom_pll_set_fsm_mode); EXPORT_SYMBOL_GPL(qcom_pll_set_fsm_mode);
static void qcom_cc_del_clk_provider(void *data)
{
of_clk_del_provider(data);
}
static void qcom_cc_reset_unregister(void *data)
{
reset_controller_unregister(data);
}
static void qcom_cc_gdsc_unregister(void *data) static void qcom_cc_gdsc_unregister(void *data)
{ {
gdsc_unregister(data); gdsc_unregister(data);
...@@ -248,13 +238,7 @@ int qcom_cc_really_probe(struct platform_device *pdev, ...@@ -248,13 +238,7 @@ int qcom_cc_really_probe(struct platform_device *pdev,
return ret; return ret;
} }
ret = of_clk_add_hw_provider(dev->of_node, qcom_cc_clk_hw_get, cc); ret = devm_of_clk_add_hw_provider(dev, qcom_cc_clk_hw_get, cc);
if (ret)
return ret;
ret = devm_add_action_or_reset(dev, qcom_cc_del_clk_provider,
pdev->dev.of_node);
if (ret) if (ret)
return ret; return ret;
...@@ -266,13 +250,7 @@ int qcom_cc_really_probe(struct platform_device *pdev, ...@@ -266,13 +250,7 @@ int qcom_cc_really_probe(struct platform_device *pdev,
reset->regmap = regmap; reset->regmap = regmap;
reset->reset_map = desc->resets; reset->reset_map = desc->resets;
ret = reset_controller_register(&reset->rcdev); ret = devm_reset_controller_register(dev, &reset->rcdev);
if (ret)
return ret;
ret = devm_add_action_or_reset(dev, qcom_cc_reset_unregister,
&reset->rcdev);
if (ret) if (ret)
return ret; return ret;
......
...@@ -815,7 +815,12 @@ int of_clk_add_hw_provider(struct device_node *np, ...@@ -815,7 +815,12 @@ int of_clk_add_hw_provider(struct device_node *np,
struct clk_hw *(*get)(struct of_phandle_args *clkspec, struct clk_hw *(*get)(struct of_phandle_args *clkspec,
void *data), void *data),
void *data); void *data);
int devm_of_clk_add_hw_provider(struct device *dev,
struct clk_hw *(*get)(struct of_phandle_args *clkspec,
void *data),
void *data);
void of_clk_del_provider(struct device_node *np); void of_clk_del_provider(struct device_node *np);
void devm_of_clk_del_provider(struct device *dev);
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);
struct clk_hw *of_clk_hw_simple_get(struct of_phandle_args *clkspec, struct clk_hw *of_clk_hw_simple_get(struct of_phandle_args *clkspec,
...@@ -847,7 +852,15 @@ static inline int of_clk_add_hw_provider(struct device_node *np, ...@@ -847,7 +852,15 @@ static inline int of_clk_add_hw_provider(struct device_node *np,
{ {
return 0; return 0;
} }
static inline int devm_of_clk_add_hw_provider(struct device *dev,
struct clk_hw *(*get)(struct of_phandle_args *clkspec,
void *data),
void *data)
{
return 0;
}
static inline void of_clk_del_provider(struct device_node *np) {} static inline void of_clk_del_provider(struct device_node *np) {}
static inline void devm_of_clk_del_provider(struct device *dev) {}
static inline struct clk *of_clk_src_simple_get( static inline struct clk *of_clk_src_simple_get(
struct of_phandle_args *clkspec, void *data) struct of_phandle_args *clkspec, void *data)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment