Skip to content

Commit c51a697

Browse files
Jinjie RuanWim Van Sebroeck
authored andcommitted
watchdog: ath79_wdt: Use the devm_clk_get_enabled() helper function
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. Signed-off-by: Jinjie Ruan <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 3cbb428 commit c51a697

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

drivers/watchdog/ath79_wdt.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,13 @@ static int ath79_wdt_probe(struct platform_device *pdev)
257257
if (IS_ERR(wdt_base))
258258
return PTR_ERR(wdt_base);
259259

260-
wdt_clk = devm_clk_get(&pdev->dev, "wdt");
260+
wdt_clk = devm_clk_get_enabled(&pdev->dev, "wdt");
261261
if (IS_ERR(wdt_clk))
262262
return PTR_ERR(wdt_clk);
263263

264-
err = clk_prepare_enable(wdt_clk);
265-
if (err)
266-
return err;
267-
268264
wdt_freq = clk_get_rate(wdt_clk);
269-
if (!wdt_freq) {
270-
err = -EINVAL;
271-
goto err_clk_disable;
272-
}
265+
if (!wdt_freq)
266+
return -EINVAL;
273267

274268
max_timeout = (0xfffffffful / wdt_freq);
275269
if (timeout < 1 || timeout > max_timeout) {
@@ -286,20 +280,15 @@ static int ath79_wdt_probe(struct platform_device *pdev)
286280
if (err) {
287281
dev_err(&pdev->dev,
288282
"unable to register misc device, err=%d\n", err);
289-
goto err_clk_disable;
283+
return err;
290284
}
291285

292286
return 0;
293-
294-
err_clk_disable:
295-
clk_disable_unprepare(wdt_clk);
296-
return err;
297287
}
298288

299289
static void ath79_wdt_remove(struct platform_device *pdev)
300290
{
301291
misc_deregister(&ath79_wdt_miscdev);
302-
clk_disable_unprepare(wdt_clk);
303292
}
304293

305294
static void ath79_wdt_shutdown(struct platform_device *pdev)

0 commit comments

Comments
 (0)