summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2017-01-10 18:21:47 -0500
committerGuenter Roeck <linux@roeck-us.net>2017-02-24 17:00:23 -0500
commit528eff34dda07e98c7aeb2266d2bdb9c54439333 (patch)
tree5d7cfbb308be3af6e8683653c3c91e44f2e08ffb /drivers/watchdog
parent89f944c0f9abce176cf442894d29a7ab25f81c76 (diff)
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>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/da9062_wdt.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c
index a02cee6820a1..9083d3d922b0 100644
--- a/drivers/watchdog/da9062_wdt.c
+++ b/drivers/watchdog/da9062_wdt.c
@@ -220,9 +220,8 @@ static int da9062_wdt_probe(struct platform_device *pdev)
220 wdt->wdtdev.parent = &pdev->dev; 220 wdt->wdtdev.parent = &pdev->dev;
221 221
222 watchdog_set_drvdata(&wdt->wdtdev, wdt); 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 if (ret < 0) { 225 if (ret < 0) {
227 dev_err(wdt->hw->dev, 226 dev_err(wdt->hw->dev,
228 "watchdog registration failed (%d)\n", ret); 227 "watchdog registration failed (%d)\n", ret);
@@ -231,24 +230,11 @@ static int da9062_wdt_probe(struct platform_device *pdev)
231 230
232 da9062_set_window_start(wdt); 231 da9062_set_window_start(wdt);
233 232
234 ret = da9062_wdt_ping(&wdt->wdtdev); 233 return da9062_wdt_ping(&wdt->wdtdev);
235 if (ret < 0)
236 watchdog_unregister_device(&wdt->wdtdev);
237
238 return ret;
239}
240
241static int da9062_wdt_remove(struct platform_device *pdev)
242{
243 struct da9062_watchdog *wdt = dev_get_drvdata(&pdev->dev);
244
245 watchdog_unregister_device(&wdt->wdtdev);
246 return 0;
247} 234}
248 235
249static struct platform_driver da9062_wdt_driver = { 236static struct platform_driver da9062_wdt_driver = {
250 .probe = da9062_wdt_probe, 237 .probe = da9062_wdt_probe,
251 .remove = da9062_wdt_remove,
252 .driver = { 238 .driver = {
253 .name = "da9062-watchdog", 239 .name = "da9062-watchdog",
254 .of_match_table = da9062_compatible_id_table, 240 .of_match_table = da9062_compatible_id_table,