On Sat, Dec 31, 2022 at 03:22:57PM +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@xxxxxxxxxx> Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx> > --- > drivers/watchdog/pic32-wdt.c | 17 +---------------- > 1 file changed, 1 insertion(+), 16 deletions(-) > > diff --git a/drivers/watchdog/pic32-wdt.c b/drivers/watchdog/pic32-wdt.c > index 41715d68d9e9..6d1a00222991 100644 > --- a/drivers/watchdog/pic32-wdt.c > +++ b/drivers/watchdog/pic32-wdt.c > @@ -162,11 +162,6 @@ static const struct of_device_id pic32_wdt_dt_ids[] = { > }; > MODULE_DEVICE_TABLE(of, pic32_wdt_dt_ids); > > -static void pic32_clk_disable_unprepare(void *data) > -{ > - clk_disable_unprepare(data); > -} > - > static int pic32_wdt_drv_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -186,22 +181,12 @@ static int pic32_wdt_drv_probe(struct platform_device *pdev) > if (!wdt->rst_base) > return -ENOMEM; > > - wdt->clk = devm_clk_get(dev, NULL); > + wdt->clk = devm_clk_get_enabled(dev, NULL); > if (IS_ERR(wdt->clk)) { > dev_err(dev, "clk not found\n"); > return PTR_ERR(wdt->clk); > } > > - ret = clk_prepare_enable(wdt->clk); > - if (ret) { > - dev_err(dev, "clk enable failed\n"); > - return ret; > - } > - ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare, > - wdt->clk); > - if (ret) > - return ret; > - > if (pic32_wdt_is_win_enabled(wdt)) { > dev_err(dev, "windowed-clear mode is not supported.\n"); > return -ENODEV; > -- > 2.34.1 >