* [PATCH] watchdog: imx7ulp: Use devm_clk_get_enabled() helper
@ 2022-12-31 10:59 Christophe JAILLET
2022-12-31 23:10 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-12-31 10:59 UTC (permalink / raw)
To: Wim Van Sebroeck, Guenter Roeck, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-watchdog,
linux-arm-kernel
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>
---
drivers/watchdog/imx7ulp_wdt.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c
index 2897902090b3..7ca486794ba7 100644
--- a/drivers/watchdog/imx7ulp_wdt.c
+++ b/drivers/watchdog/imx7ulp_wdt.c
@@ -299,11 +299,6 @@ static int imx7ulp_wdt_init(struct imx7ulp_wdt_device *wdt, unsigned int timeout
return ret;
}
-static void imx7ulp_wdt_action(void *data)
-{
- clk_disable_unprepare(data);
-}
-
static int imx7ulp_wdt_probe(struct platform_device *pdev)
{
struct imx7ulp_wdt_device *imx7ulp_wdt;
@@ -321,7 +316,7 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
if (IS_ERR(imx7ulp_wdt->base))
return PTR_ERR(imx7ulp_wdt->base);
- imx7ulp_wdt->clk = devm_clk_get(dev, NULL);
+ imx7ulp_wdt->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(imx7ulp_wdt->clk)) {
dev_err(dev, "Failed to get watchdog clock\n");
return PTR_ERR(imx7ulp_wdt->clk);
@@ -336,14 +331,6 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
dev_info(dev, "imx7ulp wdt probe\n");
}
- ret = clk_prepare_enable(imx7ulp_wdt->clk);
- if (ret)
- return ret;
-
- ret = devm_add_action_or_reset(dev, imx7ulp_wdt_action, imx7ulp_wdt->clk);
- if (ret)
- return ret;
-
wdog = &imx7ulp_wdt->wdd;
wdog->info = &imx7ulp_wdt_info;
wdog->ops = &imx7ulp_wdt_ops;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] watchdog: imx7ulp: Use devm_clk_get_enabled() helper
2022-12-31 10:59 [PATCH] watchdog: imx7ulp: Use devm_clk_get_enabled() helper Christophe JAILLET
@ 2022-12-31 23:10 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-12-31 23:10 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Wim Van Sebroeck, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
linux-kernel, kernel-janitors, linux-watchdog, linux-arm-kernel
On Sat, Dec 31, 2022 at 11:59:57AM +0100, Christophe JAILLET wrote:
> 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>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/watchdog/imx7ulp_wdt.c | 15 +--------------
> 1 file changed, 1 insertion(+), 14 deletions(-)
>
> diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c
> index 2897902090b3..7ca486794ba7 100644
> --- a/drivers/watchdog/imx7ulp_wdt.c
> +++ b/drivers/watchdog/imx7ulp_wdt.c
> @@ -299,11 +299,6 @@ static int imx7ulp_wdt_init(struct imx7ulp_wdt_device *wdt, unsigned int timeout
> return ret;
> }
>
> -static void imx7ulp_wdt_action(void *data)
> -{
> - clk_disable_unprepare(data);
> -}
> -
> static int imx7ulp_wdt_probe(struct platform_device *pdev)
> {
> struct imx7ulp_wdt_device *imx7ulp_wdt;
> @@ -321,7 +316,7 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
> if (IS_ERR(imx7ulp_wdt->base))
> return PTR_ERR(imx7ulp_wdt->base);
>
> - imx7ulp_wdt->clk = devm_clk_get(dev, NULL);
> + imx7ulp_wdt->clk = devm_clk_get_enabled(dev, NULL);
> if (IS_ERR(imx7ulp_wdt->clk)) {
> dev_err(dev, "Failed to get watchdog clock\n");
> return PTR_ERR(imx7ulp_wdt->clk);
> @@ -336,14 +331,6 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
> dev_info(dev, "imx7ulp wdt probe\n");
> }
>
> - ret = clk_prepare_enable(imx7ulp_wdt->clk);
> - if (ret)
> - return ret;
> -
> - ret = devm_add_action_or_reset(dev, imx7ulp_wdt_action, imx7ulp_wdt->clk);
> - if (ret)
> - return ret;
> -
> wdog = &imx7ulp_wdt->wdd;
> wdog->info = &imx7ulp_wdt_info;
> wdog->ops = &imx7ulp_wdt_ops;
> --
> 2.34.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-31 23:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-31 10:59 [PATCH] watchdog: imx7ulp: Use devm_clk_get_enabled() helper Christophe JAILLET
2022-12-31 23:10 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).