Skip to content

Commit 3cbb428

Browse files
Jinjie RuanWim Van Sebroeck
authored andcommitted
watchdog: at91sam9_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: Claudiu Beznea <[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 ce9ecca commit 3cbb428

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

drivers/watchdog/at91sam9_wdt.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -348,37 +348,28 @@ static int __init at91wdt_probe(struct platform_device *pdev)
348348
if (IS_ERR(wdt->base))
349349
return PTR_ERR(wdt->base);
350350

351-
wdt->sclk = devm_clk_get(&pdev->dev, NULL);
352-
if (IS_ERR(wdt->sclk))
353-
return PTR_ERR(wdt->sclk);
354-
355-
err = clk_prepare_enable(wdt->sclk);
356-
if (err) {
351+
wdt->sclk = devm_clk_get_enabled(&pdev->dev, NULL);
352+
if (IS_ERR(wdt->sclk)) {
357353
dev_err(&pdev->dev, "Could not enable slow clock\n");
358-
return err;
354+
return PTR_ERR(wdt->sclk);
359355
}
360356

361357
if (pdev->dev.of_node) {
362358
err = of_at91wdt_init(pdev->dev.of_node, wdt);
363359
if (err)
364-
goto err_clk;
360+
return err;
365361
}
366362

367363
err = at91_wdt_init(pdev, wdt);
368364
if (err)
369-
goto err_clk;
365+
return err;
370366

371367
platform_set_drvdata(pdev, wdt);
372368

373369
pr_info("enabled (heartbeat=%d sec, nowayout=%d)\n",
374370
wdt->wdd.timeout, wdt->nowayout);
375371

376372
return 0;
377-
378-
err_clk:
379-
clk_disable_unprepare(wdt->sclk);
380-
381-
return err;
382373
}
383374

384375
static int __exit at91wdt_remove(struct platform_device *pdev)
@@ -388,7 +379,6 @@ static int __exit at91wdt_remove(struct platform_device *pdev)
388379

389380
pr_warn("I quit now, hardware will probably reboot!\n");
390381
del_timer(&wdt->timer);
391-
clk_disable_unprepare(wdt->sclk);
392382

393383
return 0;
394384
}

0 commit comments

Comments
 (0)