diff options
author | Damien Riegel <damien.riegel@savoirfairelinux.com> | 2015-11-16 12:28:11 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2015-12-13 09:30:00 -0500 |
commit | 0ebad1e5e5bae3e59125675d37a70d946f283fef (patch) | |
tree | 0f5154fb8330d06be74d7aa44bf7956677fe06f4 | |
parent | c71f5cd25f946fe1eb13bb25230ce0a957c9ac16 (diff) |
watchdog: sunxi_wdt: use core restart handler
Get rid of the custom restart handler by using the one provided by the
watchdog core.
Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r-- | drivers/watchdog/sunxi_wdt.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c index 47bd8a14d01f..e027deb54740 100644 --- a/drivers/watchdog/sunxi_wdt.c +++ b/drivers/watchdog/sunxi_wdt.c | |||
@@ -21,11 +21,9 @@ | |||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/moduleparam.h> | 23 | #include <linux/moduleparam.h> |
24 | #include <linux/notifier.h> | ||
25 | #include <linux/of.h> | 24 | #include <linux/of.h> |
26 | #include <linux/of_device.h> | 25 | #include <linux/of_device.h> |
27 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
28 | #include <linux/reboot.h> | ||
29 | #include <linux/types.h> | 27 | #include <linux/types.h> |
30 | #include <linux/watchdog.h> | 28 | #include <linux/watchdog.h> |
31 | 29 | ||
@@ -60,7 +58,6 @@ struct sunxi_wdt_dev { | |||
60 | struct watchdog_device wdt_dev; | 58 | struct watchdog_device wdt_dev; |
61 | void __iomem *wdt_base; | 59 | void __iomem *wdt_base; |
62 | const struct sunxi_wdt_reg *wdt_regs; | 60 | const struct sunxi_wdt_reg *wdt_regs; |
63 | struct notifier_block restart_handler; | ||
64 | }; | 61 | }; |
65 | 62 | ||
66 | /* | 63 | /* |
@@ -86,12 +83,9 @@ static const int wdt_timeout_map[] = { | |||
86 | }; | 83 | }; |
87 | 84 | ||
88 | 85 | ||
89 | static int sunxi_restart_handle(struct notifier_block *this, unsigned long mode, | 86 | static int sunxi_wdt_restart(struct watchdog_device *wdt_dev) |
90 | void *cmd) | ||
91 | { | 87 | { |
92 | struct sunxi_wdt_dev *sunxi_wdt = container_of(this, | 88 | struct sunxi_wdt_dev *sunxi_wdt = watchdog_get_drvdata(wdt_dev); |
93 | struct sunxi_wdt_dev, | ||
94 | restart_handler); | ||
95 | void __iomem *wdt_base = sunxi_wdt->wdt_base; | 89 | void __iomem *wdt_base = sunxi_wdt->wdt_base; |
96 | const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; | 90 | const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; |
97 | u32 val; | 91 | u32 val; |
@@ -120,7 +114,7 @@ static int sunxi_restart_handle(struct notifier_block *this, unsigned long mode, | |||
120 | val |= WDT_MODE_EN; | 114 | val |= WDT_MODE_EN; |
121 | writel(val, wdt_base + regs->wdt_mode); | 115 | writel(val, wdt_base + regs->wdt_mode); |
122 | } | 116 | } |
123 | return NOTIFY_DONE; | 117 | return 0; |
124 | } | 118 | } |
125 | 119 | ||
126 | static int sunxi_wdt_ping(struct watchdog_device *wdt_dev) | 120 | static int sunxi_wdt_ping(struct watchdog_device *wdt_dev) |
@@ -208,6 +202,7 @@ static const struct watchdog_ops sunxi_wdt_ops = { | |||
208 | .stop = sunxi_wdt_stop, | 202 | .stop = sunxi_wdt_stop, |
209 | .ping = sunxi_wdt_ping, | 203 | .ping = sunxi_wdt_ping, |
210 | .set_timeout = sunxi_wdt_set_timeout, | 204 | .set_timeout = sunxi_wdt_set_timeout, |
205 | .restart = sunxi_wdt_restart, | ||
211 | }; | 206 | }; |
212 | 207 | ||
213 | static const struct sunxi_wdt_reg sun4i_wdt_reg = { | 208 | static const struct sunxi_wdt_reg sun4i_wdt_reg = { |
@@ -268,6 +263,7 @@ static int sunxi_wdt_probe(struct platform_device *pdev) | |||
268 | 263 | ||
269 | watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, &pdev->dev); | 264 | watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, &pdev->dev); |
270 | watchdog_set_nowayout(&sunxi_wdt->wdt_dev, nowayout); | 265 | watchdog_set_nowayout(&sunxi_wdt->wdt_dev, nowayout); |
266 | watchdog_set_restart_priority(&sunxi_wdt->wdt_dev, 128); | ||
271 | 267 | ||
272 | watchdog_set_drvdata(&sunxi_wdt->wdt_dev, sunxi_wdt); | 268 | watchdog_set_drvdata(&sunxi_wdt->wdt_dev, sunxi_wdt); |
273 | 269 | ||
@@ -277,13 +273,6 @@ static int sunxi_wdt_probe(struct platform_device *pdev) | |||
277 | if (unlikely(err)) | 273 | if (unlikely(err)) |
278 | return err; | 274 | return err; |
279 | 275 | ||
280 | sunxi_wdt->restart_handler.notifier_call = sunxi_restart_handle; | ||
281 | sunxi_wdt->restart_handler.priority = 128; | ||
282 | err = register_restart_handler(&sunxi_wdt->restart_handler); | ||
283 | if (err) | ||
284 | dev_err(&pdev->dev, | ||
285 | "cannot register restart handler (err=%d)\n", err); | ||
286 | |||
287 | dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", | 276 | dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", |
288 | sunxi_wdt->wdt_dev.timeout, nowayout); | 277 | sunxi_wdt->wdt_dev.timeout, nowayout); |
289 | 278 | ||
@@ -294,8 +283,6 @@ static int sunxi_wdt_remove(struct platform_device *pdev) | |||
294 | { | 283 | { |
295 | struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); | 284 | struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); |
296 | 285 | ||
297 | unregister_restart_handler(&sunxi_wdt->restart_handler); | ||
298 | |||
299 | watchdog_unregister_device(&sunxi_wdt->wdt_dev); | 286 | watchdog_unregister_device(&sunxi_wdt->wdt_dev); |
300 | watchdog_set_drvdata(&sunxi_wdt->wdt_dev, NULL); | 287 | watchdog_set_drvdata(&sunxi_wdt->wdt_dev, NULL); |
301 | 288 | ||