Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: davinci: 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/6a4cf8e8b9d8f555c77395ba2ecadc205553774d.1672483046.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Christophe JAILLET and committed by
Wim Van Sebroeck
0a032072 2cf46c63

+1 -17
+1 -17
drivers/watchdog/davinci_wdt.c
··· 189 189 .restart = davinci_wdt_restart, 190 190 }; 191 191 192 - static void davinci_clk_disable_unprepare(void *data) 193 - { 194 - clk_disable_unprepare(data); 195 - } 196 - 197 192 static int davinci_wdt_probe(struct platform_device *pdev) 198 193 { 199 - int ret = 0; 200 194 struct device *dev = &pdev->dev; 201 195 struct watchdog_device *wdd; 202 196 struct davinci_wdt_device *davinci_wdt; ··· 199 205 if (!davinci_wdt) 200 206 return -ENOMEM; 201 207 202 - davinci_wdt->clk = devm_clk_get(dev, NULL); 208 + davinci_wdt->clk = devm_clk_get_enabled(dev, NULL); 203 209 if (IS_ERR(davinci_wdt->clk)) 204 210 return dev_err_probe(dev, PTR_ERR(davinci_wdt->clk), 205 211 "failed to get clock node\n"); 206 - 207 - ret = clk_prepare_enable(davinci_wdt->clk); 208 - if (ret) { 209 - dev_err(dev, "failed to prepare clock\n"); 210 - return ret; 211 - } 212 - ret = devm_add_action_or_reset(dev, davinci_clk_disable_unprepare, 213 - davinci_wdt->clk); 214 - if (ret) 215 - return ret; 216 212 217 213 platform_set_drvdata(pdev, davinci_wdt); 218 214