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 <ruanjinjie@huawei.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230824135514.2661364-3-ruanjinjie@huawei.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
This commit is contained in:
parent
3cbb42827d
commit
c51a6977bd
@ -257,19 +257,13 @@ static int ath79_wdt_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(wdt_base))
|
||||
return PTR_ERR(wdt_base);
|
||||
|
||||
wdt_clk = devm_clk_get(&pdev->dev, "wdt");
|
||||
wdt_clk = devm_clk_get_enabled(&pdev->dev, "wdt");
|
||||
if (IS_ERR(wdt_clk))
|
||||
return PTR_ERR(wdt_clk);
|
||||
|
||||
err = clk_prepare_enable(wdt_clk);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
wdt_freq = clk_get_rate(wdt_clk);
|
||||
if (!wdt_freq) {
|
||||
err = -EINVAL;
|
||||
goto err_clk_disable;
|
||||
}
|
||||
if (!wdt_freq)
|
||||
return -EINVAL;
|
||||
|
||||
max_timeout = (0xfffffffful / wdt_freq);
|
||||
if (timeout < 1 || timeout > max_timeout) {
|
||||
@ -286,20 +280,15 @@ static int ath79_wdt_probe(struct platform_device *pdev)
|
||||
if (err) {
|
||||
dev_err(&pdev->dev,
|
||||
"unable to register misc device, err=%d\n", err);
|
||||
goto err_clk_disable;
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_clk_disable:
|
||||
clk_disable_unprepare(wdt_clk);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void ath79_wdt_remove(struct platform_device *pdev)
|
||||
{
|
||||
misc_deregister(&ath79_wdt_miscdev);
|
||||
clk_disable_unprepare(wdt_clk);
|
||||
}
|
||||
|
||||
static void ath79_wdt_shutdown(struct platform_device *pdev)
|
||||
|
Loading…
Reference in New Issue
Block a user