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

watchdog: of_xilinx_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>
Acked-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/2b041dc8230a4ed255051bb2d323da8a51a8d0be.1672491445.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
4de0224c 5eb3fb95

+1 -15
+1 -15
drivers/watchdog/of_xilinx_wdt.c
··· 154 154 return XWT_TIMER_FAILED; 155 155 } 156 156 157 - static void xwdt_clk_disable_unprepare(void *data) 158 - { 159 - clk_disable_unprepare(data); 160 - } 161 - 162 157 static int xwdt_probe(struct platform_device *pdev) 163 158 { 164 159 struct device *dev = &pdev->dev; ··· 188 193 189 194 watchdog_set_nowayout(xilinx_wdt_wdd, enable_once); 190 195 191 - xdev->clk = devm_clk_get(dev, NULL); 196 + xdev->clk = devm_clk_get_enabled(dev, NULL); 192 197 if (IS_ERR(xdev->clk)) { 193 198 if (PTR_ERR(xdev->clk) != -ENOENT) 194 199 return PTR_ERR(xdev->clk); ··· 206 211 "The watchdog clock freq cannot be obtained\n"); 207 212 } else { 208 213 pfreq = clk_get_rate(xdev->clk); 209 - rc = clk_prepare_enable(xdev->clk); 210 - if (rc) { 211 - dev_err(dev, "unable to enable clock\n"); 212 - return rc; 213 - } 214 - rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare, 215 - xdev->clk); 216 - if (rc) 217 - return rc; 218 214 } 219 215 220 216 /*