drivers/watchdog/of_xilinx_wdt.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
The devm_clk_get_enabled() helper:
- calls devm_clk_get()
- calls clk_prepare_enable() and registers what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids the need of a dedicated function used
with devm_add_action_or_reset().
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Note that the order of operations is slightly modified by this patch. The
clk is now prepare_enable()'ed before calling clk_get_rate().
---
drivers/watchdog/of_xilinx_wdt.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c
index 3318544366b8..f184843380a3 100644
--- a/drivers/watchdog/of_xilinx_wdt.c
+++ b/drivers/watchdog/of_xilinx_wdt.c
@@ -193,7 +193,7 @@ static int xwdt_probe(struct platform_device *pdev)
watchdog_set_nowayout(xilinx_wdt_wdd, enable_once);
- xdev->clk = devm_clk_get(dev, NULL);
+ xdev->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(xdev->clk)) {
if (PTR_ERR(xdev->clk) != -ENOENT)
return PTR_ERR(xdev->clk);
@@ -211,15 +211,6 @@ static int xwdt_probe(struct platform_device *pdev)
"The watchdog clock freq cannot be obtained\n");
} else {
pfreq = clk_get_rate(xdev->clk);
- rc = clk_prepare_enable(xdev->clk);
- if (rc) {
- dev_err(dev, "unable to enable clock\n");
- return rc;
- }
- rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare,
- xdev->clk);
- if (rc)
- return rc;
}
/*
--
2.34.1
Le 31/12/2022 à 13:51, Christophe JAILLET a écrit : > The devm_clk_get_enabled() helper: > - calls devm_clk_get() > - calls clk_prepare_enable() and registers what is needed in order to > call clk_disable_unprepare() when needed, as a managed resource. > > This simplifies the code and avoids the need of a dedicated function used > with devm_add_action_or_reset(). > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > Note that the order of operations is slightly modified by this patch. The > clk is now prepare_enable()'ed before calling clk_get_rate(). > --- > drivers/watchdog/of_xilinx_wdt.c | 11 +---------- > 1 file changed, 1 insertion(+), 10 deletions(-) > > diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c > index 3318544366b8..f184843380a3 100644 > --- a/drivers/watchdog/of_xilinx_wdt.c > +++ b/drivers/watchdog/of_xilinx_wdt.c > @@ -193,7 +193,7 @@ static int xwdt_probe(struct platform_device *pdev) > > watchdog_set_nowayout(xilinx_wdt_wdd, enable_once); > > - xdev->clk = devm_clk_get(dev, NULL); > + xdev->clk = devm_clk_get_enabled(dev, NULL); > if (IS_ERR(xdev->clk)) { > if (PTR_ERR(xdev->clk) != -ENOENT) > return PTR_ERR(xdev->clk); > @@ -211,15 +211,6 @@ static int xwdt_probe(struct platform_device *pdev) > "The watchdog clock freq cannot be obtained\n"); > } else { > pfreq = clk_get_rate(xdev->clk); > - rc = clk_prepare_enable(xdev->clk); > - if (rc) { > - dev_err(dev, "unable to enable clock\n"); > - return rc; > - } > - rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare, > - xdev->clk); > - if (rc) > - return rc; > } > > /* NACK. This one is incomplet, xwdt_clk_disable_unprepare() should be removed as-well. I'll send a v2. CJ
© 2016 - 2025 Red Hat, Inc.