summaryrefslogtreecommitdiff
path: root/include/linux/watchdog.h
diff options
context:
space:
mode:
authorDamien Riegel <damien.riegel@savoirfairelinux.com>2015-11-20 16:54:51 -0500
committerWim Van Sebroeck <wim@iguana.be>2015-12-13 15:55:51 +0100
commite131319669e0ef5e6fcd75174daeffa40492135c (patch)
tree3ea2434a3d6661fd62b51efd1cfad7d0ac1c5052 /include/linux/watchdog.h
parent0ebad1e5e5bae3e59125675d37a70d946f283fef (diff)
watchdog: core: add reboot notifier support
Many watchdog drivers register a reboot notifier in order to stop the watchdog on system reboot. Thus we can factorize this code in the watchdog core. For that purpose, a new notifier block is added in watchdog_device for internal use only, as well as a new watchdog_stop_on_reboot helper function. If this helper is called, watchdog core registers the related notifier block and will stop the watchdog when SYS_HALT or SYS_DOWN is received. Since this operation can be critical on some platforms, abort the device registration if the reboot notifier registration fails. Suggested-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com> 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>
Diffstat (limited to 'include/linux/watchdog.h')
-rw-r--r--include/linux/watchdog.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index 5b52c834f7aa..a88f955fde92 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -65,6 +65,7 @@ struct watchdog_ops {
* @timeout: The watchdog devices timeout value (in seconds).
* @min_timeout:The watchdog devices minimum timeout value (in seconds).
* @max_timeout:The watchdog devices maximum timeout value (in seconds).
+ * @reboot_nb: The notifier block to stop watchdog on reboot.
* @restart_nb: The notifier block to register a restart function.
* @driver-data:Pointer to the drivers private data.
* @lock: Lock for watchdog core internal use only.
@@ -92,6 +93,7 @@ struct watchdog_device {
unsigned int timeout;
unsigned int min_timeout;
unsigned int max_timeout;
+ struct notifier_block reboot_nb;
struct notifier_block restart_nb;
void *driver_data;
struct mutex lock;
@@ -102,6 +104,7 @@ struct watchdog_device {
#define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */
#define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */
#define WDOG_UNREGISTERED 4 /* Has the device been unregistered */
+#define WDOG_STOP_ON_REBOOT 5 /* Should be stopped on reboot */
struct list_head deferred;
};
@@ -121,6 +124,12 @@ static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool noway
set_bit(WDOG_NO_WAY_OUT, &wdd->status);
}
+/* Use the following function to stop the watchdog on reboot */
+static inline void watchdog_stop_on_reboot(struct watchdog_device *wdd)
+{
+ set_bit(WDOG_STOP_ON_REBOOT, &wdd->status);
+}
+
/* Use the following function to check if a timeout value is invalid */
static inline bool watchdog_timeout_invalid(struct watchdog_device *wdd, unsigned int t)
{