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

watchdog: pic32-dmt: 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/f9a4dcfc6d31bd9c1417e2d97a40cc2c1dbc6f30.1672496405.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
e0912ea8 7f7f8ad0

+1 -14
+1 -14
drivers/watchdog/pic32-dmt.c
··· 164 164 .ops = &pic32_dmt_fops, 165 165 }; 166 166 167 - static void pic32_clk_disable_unprepare(void *data) 168 - { 169 - clk_disable_unprepare(data); 170 - } 171 - 172 167 static int pic32_dmt_probe(struct platform_device *pdev) 173 168 { 174 169 struct device *dev = &pdev->dev; ··· 179 184 if (IS_ERR(dmt->regs)) 180 185 return PTR_ERR(dmt->regs); 181 186 182 - dmt->clk = devm_clk_get(dev, NULL); 187 + dmt->clk = devm_clk_get_enabled(dev, NULL); 183 188 if (IS_ERR(dmt->clk)) { 184 189 dev_err(dev, "clk not found\n"); 185 190 return PTR_ERR(dmt->clk); 186 191 } 187 - 188 - ret = clk_prepare_enable(dmt->clk); 189 - if (ret) 190 - return ret; 191 - ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare, 192 - dmt->clk); 193 - if (ret) 194 - return ret; 195 192 196 193 wdd->timeout = pic32_dmt_get_timeout_secs(dmt); 197 194 if (!wdd->timeout) {