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

watchdog: pnx4008: 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/61f4e39db4c88408ee0149580e9aa925b784bc93.1672496714.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
a8a9b980 3c22939e

+1 -14
+1 -14
drivers/watchdog/pnx4008_wdt.c
··· 179 179 .max_timeout = MAX_HEARTBEAT, 180 180 }; 181 181 182 - static void pnx4008_clk_disable_unprepare(void *data) 183 - { 184 - clk_disable_unprepare(data); 185 - } 186 - 187 182 static int pnx4008_wdt_probe(struct platform_device *pdev) 188 183 { 189 184 struct device *dev = &pdev->dev; ··· 190 195 if (IS_ERR(wdt_base)) 191 196 return PTR_ERR(wdt_base); 192 197 193 - wdt_clk = devm_clk_get(dev, NULL); 198 + wdt_clk = devm_clk_get_enabled(dev, NULL); 194 199 if (IS_ERR(wdt_clk)) 195 200 return PTR_ERR(wdt_clk); 196 - 197 - ret = clk_prepare_enable(wdt_clk); 198 - if (ret) 199 - return ret; 200 - ret = devm_add_action_or_reset(dev, pnx4008_clk_disable_unprepare, 201 - wdt_clk); 202 - if (ret) 203 - return ret; 204 201 205 202 pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? 206 203 WDIOF_CARDRESET : 0;