Commit 89e5b7ac authored by Guenter Roeck's avatar Guenter Roeck Committed by Wim Van Sebroeck

watchdog: ux500_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

- Drop empty remove function
- Introduce local variable 'struct device *dev' and use it instead of
  dereferencing it repeatedly
- Use devm_watchdog_register_driver() to register watchdog device
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent 1f533058
...@@ -86,8 +86,9 @@ static struct watchdog_device ux500_wdt = { ...@@ -86,8 +86,9 @@ static struct watchdog_device ux500_wdt = {
static int ux500_wdt_probe(struct platform_device *pdev) static int ux500_wdt_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
int ret; int ret;
struct ux500_wdt_data *pdata = dev_get_platdata(&pdev->dev); struct ux500_wdt_data *pdata = dev_get_platdata(dev);
if (pdata) { if (pdata) {
if (pdata->timeout > 0) if (pdata->timeout > 0)
...@@ -96,7 +97,7 @@ static int ux500_wdt_probe(struct platform_device *pdev) ...@@ -96,7 +97,7 @@ static int ux500_wdt_probe(struct platform_device *pdev)
ux500_wdt.max_timeout = WATCHDOG_MAX28; ux500_wdt.max_timeout = WATCHDOG_MAX28;
} }
ux500_wdt.parent = &pdev->dev; ux500_wdt.parent = dev;
watchdog_set_nowayout(&ux500_wdt, nowayout); watchdog_set_nowayout(&ux500_wdt, nowayout);
/* disable auto off on sleep */ /* disable auto off on sleep */
...@@ -105,18 +106,11 @@ static int ux500_wdt_probe(struct platform_device *pdev) ...@@ -105,18 +106,11 @@ static int ux500_wdt_probe(struct platform_device *pdev)
/* set HW initial value */ /* set HW initial value */
prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000);
ret = watchdog_register_device(&ux500_wdt); ret = devm_watchdog_register_device(dev, &ux500_wdt);
if (ret) if (ret)
return ret; return ret;
dev_info(&pdev->dev, "initialized\n"); dev_info(dev, "initialized\n");
return 0;
}
static int ux500_wdt_remove(struct platform_device *dev)
{
watchdog_unregister_device(&ux500_wdt);
return 0; return 0;
} }
...@@ -153,7 +147,6 @@ static int ux500_wdt_resume(struct platform_device *pdev) ...@@ -153,7 +147,6 @@ static int ux500_wdt_resume(struct platform_device *pdev)
static struct platform_driver ux500_wdt_driver = { static struct platform_driver ux500_wdt_driver = {
.probe = ux500_wdt_probe, .probe = ux500_wdt_probe,
.remove = ux500_wdt_remove,
.suspend = ux500_wdt_suspend, .suspend = ux500_wdt_suspend,
.resume = ux500_wdt_resume, .resume = ux500_wdt_resume,
.driver = { .driver = {
......
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