Message ID | f23a2cf84958adca255b82fd688e7cee0461760f.1672484376.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | watchdog: imx7ulp: Use devm_clk_get_enabled() helper | expand |
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 >
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;
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(-)