summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2017-01-10 18:21:52 -0500
committerGuenter Roeck <linux@roeck-us.net>2017-02-24 17:00:23 -0500
commitcb5c14ea573b625053487f9dfde395ac0e8bc11b (patch)
tree9f0cb30d8e4fcfac77984172c464cf94fb44e154 /drivers/watchdog
parent30cba9a109feb0dbb262d575ae33be8c16d7d26f (diff)
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>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/mena21_wdt.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
index af6a7c489f08..045201a6fdb3 100644
--- a/drivers/watchdog/mena21_wdt.c
+++ b/drivers/watchdog/mena21_wdt.c
@@ -212,34 +212,15 @@ static int a21_wdt_probe(struct platform_device *pdev)
212 drv->wdt = a21_wdt; 212 drv->wdt = a21_wdt;
213 dev_set_drvdata(&pdev->dev, drv); 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 if (ret) { 216 if (ret) {
217 dev_err(&pdev->dev, "Cannot register watchdog device\n"); 217 dev_err(&pdev->dev, "Cannot register watchdog device\n");
218 goto err_register_wd; 218 return ret;
219 } 219 }
220 220
221 dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n"); 221 dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n");
222 222
223 return 0; 223 return 0;
224
225err_register_wd:
226 mutex_destroy(&drv->lock);
227
228 return ret;
229}
230
231static 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
242 return 0;
243} 224}
244 225
245static void a21_wdt_shutdown(struct platform_device *pdev) 226static void a21_wdt_shutdown(struct platform_device *pdev)
@@ -257,7 +238,6 @@ MODULE_DEVICE_TABLE(of, a21_wdt_ids);
257 238
258static struct platform_driver a21_wdt_driver = { 239static struct platform_driver a21_wdt_driver = {
259 .probe = a21_wdt_probe, 240 .probe = a21_wdt_probe,
260 .remove = a21_wdt_remove,
261 .shutdown = a21_wdt_shutdown, 241 .shutdown = a21_wdt_shutdown,
262 .driver = { 242 .driver = {
263 .name = "a21-watchdog", 243 .name = "a21-watchdog",