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>
This commit is contained in:

committed by
Wim Van Sebroeck

parent
0ebad1e5e5
commit
e131319669
@@ -53,6 +53,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;
|
||||
@@ -76,6 +77,9 @@ It contains following fields:
|
||||
* timeout: the watchdog timer's timeout value (in seconds).
|
||||
* min_timeout: the watchdog timer's minimum timeout value (in seconds).
|
||||
* max_timeout: the watchdog timer's maximum timeout value (in seconds).
|
||||
* reboot_nb: notifier block that is registered for reboot notifications, for
|
||||
internal use only. If the driver calls watchdog_stop_on_reboot, watchdog core
|
||||
will stop the watchdog on such notifications.
|
||||
* restart_nb: notifier block that is registered for machine restart, for
|
||||
internal use only. If a watchdog is capable of restarting the machine, it
|
||||
should define ops->restart. Priority can be changed through
|
||||
@@ -240,6 +244,10 @@ to set the default timeout value as timeout value in the watchdog_device and
|
||||
then use this function to set the user "preferred" timeout value.
|
||||
This routine returns zero on success and a negative errno code for failure.
|
||||
|
||||
To disable the watchdog on reboot, the user must call the following helper:
|
||||
|
||||
static inline void watchdog_stop_on_reboot(struct watchdog_device *wdd);
|
||||
|
||||
To change the priority of the restart handler the following helper should be
|
||||
used:
|
||||
|
||||
|
Reference in New Issue
Block a user