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

watchdog: da9062_wdt: Convert to use device managed functions

Use device managed functions to simplify error handling, reduce
source code size, improve readability, and reduce the likelyhood of bugs.

The conversion was done automatically with coccinelle using the
following semantic patches. The semantic patches and the scripts used
to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Replace 'val = e; return val;' with 'return e;'
- Drop assignments to otherwise unused variables
- Drop remove function
- Drop dev_set_drvdata()
- Use devm_watchdog_register_driver() to register watchdog device

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

+2 -16
+2 -16
drivers/watchdog/da9062_wdt.c
··· 220 220 wdt->wdtdev.parent = &pdev->dev; 221 221 222 222 watchdog_set_drvdata(&wdt->wdtdev, wdt); 223 - dev_set_drvdata(&pdev->dev, wdt); 224 223 225 - ret = watchdog_register_device(&wdt->wdtdev); 224 + ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdtdev); 226 225 if (ret < 0) { 227 226 dev_err(wdt->hw->dev, 228 227 "watchdog registration failed (%d)\n", ret); ··· 230 231 231 232 da9062_set_window_start(wdt); 232 233 233 - ret = da9062_wdt_ping(&wdt->wdtdev); 234 - if (ret < 0) 235 - watchdog_unregister_device(&wdt->wdtdev); 236 - 237 - return ret; 238 - } 239 - 240 - static int da9062_wdt_remove(struct platform_device *pdev) 241 - { 242 - struct da9062_watchdog *wdt = dev_get_drvdata(&pdev->dev); 243 - 244 - watchdog_unregister_device(&wdt->wdtdev); 245 - return 0; 234 + return da9062_wdt_ping(&wdt->wdtdev); 246 235 } 247 236 248 237 static struct platform_driver da9062_wdt_driver = { 249 238 .probe = da9062_wdt_probe, 250 - .remove = da9062_wdt_remove, 251 239 .driver = { 252 240 .name = "da9062-watchdog", 253 241 .of_match_table = da9062_compatible_id_table,