[PATCH 3/5] clk: fixed-factor: Use devm_of_clk_add_provider

From: Ricardo Ribalda Delgado
Date: Thu Nov 01 2018 - 10:40:58 EST


Use devm_clk_add_provider. It will take care of clk un-registering.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@xxxxxxxxx>
---
drivers/clk/clk-fixed-factor.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index 7df6b5b1e7ee..876d76522475 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -148,7 +148,8 @@ static const struct of_device_id set_rate_parent_matches[] = {
{ /* Sentinel */ },
};

-static struct clk *_of_fixed_factor_clk_setup(struct device_node *node)
+static struct clk *_of_fixed_factor_clk_setup(struct device *dev,
+ struct device_node *node)
{
struct clk *clk;
const char *clk_name = node->name;
@@ -187,7 +188,11 @@ static struct clk *_of_fixed_factor_clk_setup(struct device_node *node)
return clk;
}

- ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
+ if (dev)
+ ret = devm_of_clk_add_provider(dev, of_clk_src_simple_get, clk);
+ else
+ ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
+
if (ret) {
clk_unregister(clk);
return ERR_PTR(ret);
@@ -201,7 +206,7 @@ static struct clk *_of_fixed_factor_clk_setup(struct device_node *node)
*/
void __init of_fixed_factor_clk_setup(struct device_node *node)
{
- _of_fixed_factor_clk_setup(node);
+ _of_fixed_factor_clk_setup(NULL, node);
}
CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",
of_fixed_factor_clk_setup);
@@ -210,7 +215,6 @@ static int of_fixed_factor_clk_remove(struct platform_device *pdev)
{
struct clk *clk = platform_get_drvdata(pdev);

- of_clk_del_provider(pdev->dev.of_node);
clk_unregister_fixed_factor(clk);

return 0;
@@ -224,7 +228,7 @@ static int of_fixed_factor_clk_probe(struct platform_device *pdev)
* This function is not executed when of_fixed_factor_clk_setup
* succeeded.
*/
- clk = _of_fixed_factor_clk_setup(pdev->dev.of_node);
+ clk = _of_fixed_factor_clk_setup(&pdev->dev, pdev->dev.of_node);
if (IS_ERR(clk))
return PTR_ERR(clk);

--
2.19.1