Commit cb5c14ea authored by Guenter Roeck's avatar Guenter Roeck

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: default avatarJohannes Thumshirn <morbidrsa@gmail.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 30cba9a1
...@@ -212,33 +212,14 @@ static int a21_wdt_probe(struct platform_device *pdev) ...@@ -212,33 +212,14 @@ static int a21_wdt_probe(struct platform_device *pdev)
drv->wdt = a21_wdt; drv->wdt = a21_wdt;
dev_set_drvdata(&pdev->dev, drv); dev_set_drvdata(&pdev->dev, drv);
ret = watchdog_register_device(&a21_wdt); ret = devm_watchdog_register_device(&pdev->dev, &a21_wdt);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Cannot register watchdog device\n"); dev_err(&pdev->dev, "Cannot register watchdog device\n");
goto err_register_wd; return ret;
} }
dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n"); dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n");
return 0;
err_register_wd:
mutex_destroy(&drv->lock);
return ret;
}
static int a21_wdt_remove(struct platform_device *pdev)
{
struct a21_wdt_drv *drv = dev_get_drvdata(&pdev->dev);
dev_warn(&pdev->dev,
"Unregistering A21 watchdog driver, board may reboot\n");
watchdog_unregister_device(&drv->wdt);
mutex_destroy(&drv->lock);
return 0; return 0;
} }
...@@ -257,7 +238,6 @@ MODULE_DEVICE_TABLE(of, a21_wdt_ids); ...@@ -257,7 +238,6 @@ MODULE_DEVICE_TABLE(of, a21_wdt_ids);
static struct platform_driver a21_wdt_driver = { static struct platform_driver a21_wdt_driver = {
.probe = a21_wdt_probe, .probe = a21_wdt_probe,
.remove = a21_wdt_remove,
.shutdown = a21_wdt_shutdown, .shutdown = a21_wdt_shutdown,
.driver = { .driver = {
.name = "a21-watchdog", .name = "a21-watchdog",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment