aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Riegel <damien.riegel@savoirfairelinux.com>2015-11-20 16:54:54 -0500
committerWim Van Sebroeck <wim@iguana.be>2015-12-13 09:56:02 -0500
commit28e805b44d52900fc5b05b35ef3945dc6db336a1 (patch)
tree68c66c723ca11de50054a803478bf384faeda920
parent5e1f976f43dc6b5903ee4b78536347b5004cefe4 (diff)
watchdog: gpio_wdt: use core reboot notifier
Get rid of the custom reboot notifier block registration and use the one provided by the watchdog core. Note that this watchdog used to stop unconditionnaly on SYS_HALT and SYS_POWER_OFF. The core function now calls ops->stop on SYS_HALT and SYS_DOWN. To prevent the watchdog from being stopped on reboot, the "always-running" property must be set, otherwise it will now be stopped. Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com> Reviewed-by: Vivien Didelot <vivien.didelot@savoirlinux.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r--drivers/watchdog/gpio_wdt.c35
1 files changed, 2 insertions, 33 deletions
diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index 90d59d3f38a3..035c2387b846 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -12,10 +12,8 @@
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/notifier.h>
16#include <linux/of_gpio.h> 15#include <linux/of_gpio.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
18#include <linux/reboot.h>
19#include <linux/watchdog.h> 17#include <linux/watchdog.h>
20 18
21#define SOFT_TIMEOUT_MIN 1 19#define SOFT_TIMEOUT_MIN 1
@@ -36,7 +34,6 @@ struct gpio_wdt_priv {
36 unsigned int hw_algo; 34 unsigned int hw_algo;
37 unsigned int hw_margin; 35 unsigned int hw_margin;
38 unsigned long last_jiffies; 36 unsigned long last_jiffies;
39 struct notifier_block notifier;
40 struct timer_list timer; 37 struct timer_list timer;
41 struct watchdog_device wdd; 38 struct watchdog_device wdd;
42}; 39};
@@ -126,26 +123,6 @@ static int gpio_wdt_set_timeout(struct watchdog_device *wdd, unsigned int t)
126 return gpio_wdt_ping(wdd); 123 return gpio_wdt_ping(wdd);
127} 124}
128 125
129static int gpio_wdt_notify_sys(struct notifier_block *nb, unsigned long code,
130 void *unused)
131{
132 struct gpio_wdt_priv *priv = container_of(nb, struct gpio_wdt_priv,
133 notifier);
134
135 mod_timer(&priv->timer, 0);
136
137 switch (code) {
138 case SYS_HALT:
139 case SYS_POWER_OFF:
140 gpio_wdt_disable(priv);
141 break;
142 default:
143 break;
144 }
145
146 return NOTIFY_DONE;
147}
148
149static const struct watchdog_info gpio_wdt_ident = { 126static const struct watchdog_info gpio_wdt_ident = {
150 .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | 127 .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING |
151 WDIOF_SETTIMEOUT, 128 WDIOF_SETTIMEOUT,
@@ -224,23 +201,16 @@ static int gpio_wdt_probe(struct platform_device *pdev)
224 201
225 setup_timer(&priv->timer, gpio_wdt_hwping, (unsigned long)&priv->wdd); 202 setup_timer(&priv->timer, gpio_wdt_hwping, (unsigned long)&priv->wdd);
226 203
204 watchdog_stop_on_reboot(&priv->wdd);
205
227 ret = watchdog_register_device(&priv->wdd); 206 ret = watchdog_register_device(&priv->wdd);
228 if (ret) 207 if (ret)
229 return ret; 208 return ret;
230 209
231 priv->notifier.notifier_call = gpio_wdt_notify_sys;
232 ret = register_reboot_notifier(&priv->notifier);
233 if (ret)
234 goto error_unregister;
235
236 if (priv->always_running) 210 if (priv->always_running)
237 gpio_wdt_start_impl(priv); 211 gpio_wdt_start_impl(priv);
238 212
239 return 0; 213 return 0;
240
241error_unregister:
242 watchdog_unregister_device(&priv->wdd);
243 return ret;
244} 214}
245 215
246static int gpio_wdt_remove(struct platform_device *pdev) 216static int gpio_wdt_remove(struct platform_device *pdev)
@@ -248,7 +218,6 @@ static int gpio_wdt_remove(struct platform_device *pdev)
248 struct gpio_wdt_priv *priv = platform_get_drvdata(pdev); 218 struct gpio_wdt_priv *priv = platform_get_drvdata(pdev);
249 219
250 del_timer_sync(&priv->timer); 220 del_timer_sync(&priv->timer);
251 unregister_reboot_notifier(&priv->notifier);
252 watchdog_unregister_device(&priv->wdd); 221 watchdog_unregister_device(&priv->wdd);
253 222
254 return 0; 223 return 0;