watchdog: pic32-wdt: Use devm_clk_get_enabled() helper
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> Link: https://lore.kernel.org/r/4335b4201b535ebc749a98bad0b99e3cb5317c39.1672496563.git.christophe.jaillet@wanadoo.fr 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
a8a9b98057
commit
7f7f8ad072
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user