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

watchdog: mena21_wdt: Convert to use device managed functions and other improvements

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

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 'goto l; ... l: return e;' with 'return e;'
- Drop assignments to otherwise unused variables
- Drop remove function
- Drop unnecessary mutex_destroy() on allocated data
- Use devm_watchdog_register_driver() to register watchdog device

Acked-by: Johannes Thumshirn <morbidrsa@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

+2 -22
+2 -22
drivers/watchdog/mena21_wdt.c
··· 212 212 drv->wdt = a21_wdt; 213 213 dev_set_drvdata(&pdev->dev, drv); 214 214 215 - ret = watchdog_register_device(&a21_wdt); 215 + ret = devm_watchdog_register_device(&pdev->dev, &a21_wdt); 216 216 if (ret) { 217 217 dev_err(&pdev->dev, "Cannot register watchdog device\n"); 218 - goto err_register_wd; 218 + return ret; 219 219 } 220 220 221 221 dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n"); 222 - 223 - return 0; 224 - 225 - err_register_wd: 226 - mutex_destroy(&drv->lock); 227 - 228 - return ret; 229 - } 230 - 231 - static int a21_wdt_remove(struct platform_device *pdev) 232 - { 233 - struct a21_wdt_drv *drv = dev_get_drvdata(&pdev->dev); 234 - 235 - dev_warn(&pdev->dev, 236 - "Unregistering A21 watchdog driver, board may reboot\n"); 237 - 238 - watchdog_unregister_device(&drv->wdt); 239 - 240 - mutex_destroy(&drv->lock); 241 222 242 223 return 0; 243 224 } ··· 238 257 239 258 static struct platform_driver a21_wdt_driver = { 240 259 .probe = a21_wdt_probe, 241 - .remove = a21_wdt_remove, 242 260 .shutdown = a21_wdt_shutdown, 243 261 .driver = { 244 262 .name = "a21-watchdog",