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
commit64b849e28b8be15a5bb855890fd9ddb8be162db6 (patch)
tree43d18d088505e7b661d9d1c39f4a490260c030a8 /drivers/watchdog
parent528eff34dda07e98c7aeb2266d2bdb9c54439333 (diff)
watchdog: da9063_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;' - Replace 'if (e) return e; return 0;' with 'return e;' - Drop assignments to otherwise unused variables - Drop 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/da9063_wdt.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index 5d6b4e5f7989..4691c5509129 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -151,7 +151,6 @@ static const struct watchdog_ops da9063_watchdog_ops = {
151 151
152static int da9063_wdt_probe(struct platform_device *pdev) 152static int da9063_wdt_probe(struct platform_device *pdev)
153{ 153{
154 int ret;
155 struct da9063 *da9063; 154 struct da9063 *da9063;
156 struct da9063_watchdog *wdt; 155 struct da9063_watchdog *wdt;
157 156
@@ -181,27 +180,12 @@ static int da9063_wdt_probe(struct platform_device *pdev)
181 watchdog_set_restart_priority(&wdt->wdtdev, 128); 180 watchdog_set_restart_priority(&wdt->wdtdev, 128);
182 181
183 watchdog_set_drvdata(&wdt->wdtdev, wdt); 182 watchdog_set_drvdata(&wdt->wdtdev, wdt);
184 dev_set_drvdata(&pdev->dev, wdt);
185
186 ret = watchdog_register_device(&wdt->wdtdev);
187 if (ret)
188 return ret;
189
190 return 0;
191}
192
193static int da9063_wdt_remove(struct platform_device *pdev)
194{
195 struct da9063_watchdog *wdt = dev_get_drvdata(&pdev->dev);
196
197 watchdog_unregister_device(&wdt->wdtdev);
198 183
199 return 0; 184 return devm_watchdog_register_device(&pdev->dev, &wdt->wdtdev);
200} 185}
201 186
202static struct platform_driver da9063_wdt_driver = { 187static struct platform_driver da9063_wdt_driver = {
203 .probe = da9063_wdt_probe, 188 .probe = da9063_wdt_probe,
204 .remove = da9063_wdt_remove,
205 .driver = { 189 .driver = {
206 .name = DA9063_DRVNAME_WATCHDOG, 190 .name = DA9063_DRVNAME_WATCHDOG,
207 }, 191 },