Generic Watchdog Timer Driver
Subsystems (2)
RFC PATCH 4/10 Generic Watchdog Timer Driver
commit 254c9369d07a369fd45e4be343ed2062ecd915a6
Author: Wim Van Sebroeck <[email protected]> Date: Fri Jun 18 09:44:49 2010 +0000
watchdog: WatchDog Timer Driver Core - Part 4
This part add's the WDIOC_SETOPTIONS ioctl functionality to the WatchDog Timer Driver Core framework.
Signed-off-by Alan Cox <[email protected]>
Signed-off-by Wim Van Sebroeck <[email protected]>
Documentation/watchdog/src/watchdog-with-timer-example.c +2 -4
@@ -45,11 +45,11 @@ module_param(timeout, int, 0); MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. " "(default = " __MODULE_STRING(WDT_TIMEOUT) ")"); +static struct watchdog_device wdt_dev;static void wdt_timer_tick (unsigned long data); static DEFINE_TIMER(timer, wdt_timer_tick, 0, 0);/* The timer that pings the watchdog */ static unsigned long next_heartbeat;/* the next_heartbeat for the timer */ -static unsigned long running;/* is watchdog running for userspace? */ static struct platform_device *wdt_platform_device;
@@ -73,7 +73,7 @@ static inline void wdt_reset(void)static void wdt_timer_tick (unsigned long data) {if (time_before (jiffies, next_heartbeat) || - (!running)) { + (!test_bit (WDOG_ACTIVE , &wdt_dev.status))) {wdt_reset ();mod_timer (&timer, jiffies +WDT_HEARTBEAT ); }else
@@ -99,7 +99,6 @@ static int wdt_start(struct watchdog_device *wdd)/* Start the watchdog timer hardware here */ printk(KERN_INFO PFX "wdt_start\n"); - running =1 ;return 0 ; }
@@ -108,7 +107,6 @@ static int wdt_stop(struct watchdog_device *wdd)/* The watchdog timer hardware can not be stopped... */ printk(KERN_INFO PFX "wdt_stop\n"); - running =0 ;return 0 ; }
Documentation/watchdog/watchdog-kernel-api.txt +7 -2
@@ -54,8 +54,9 @@ It contains following fields: * bootstatus: status of the device after booting (reported with watchdog WDIOF_* status bits). * status: this field contains a number of status bits that give extra - information about the status of the device (Like: is the device opened via - the /dev/watchdog interface or not, ...) + information about the status of the device (Like: is the watchdog timer + running/active, is the device opened via the /dev/watchdog interface or not, + ...) The list of watchdog operations is defined as:
@@ -104,6 +105,10 @@ they are supported. These optional routines/operations are: The status bits should (preferably) be set with the set_bit and clear_bit alike bit-operations. The status bit's that are defined are: +* WDOG_ACTIVE: this status bit indicates whether or not a watchdog timer device + is active or not. When the watchdog is active after booting, then you should + set this status bit (Note: when you register the watchdog timer device with + this bit set, then opening /dev/watchdog will skip the start operation) * WDOG_DEV_OPEN: this status bit shows whether or not the watchdog device was opened via /dev/watchdog. (This bit should only be used by the WatchDog Timer Driver Core).
drivers/watchdog/core/watchdog_dev.c +73 -8
116 lines not on this page · raw message
include/linux/watchdog.h +1 -0
@@ -79,6 +79,7 @@ struct watchdog_device {const struct watchdog_ops *ops;int bootstatus;long status; +#define WDOG_ACTIVE 0/* is the watchdog running/active */ #define WDOG_DEV_OPEN 1/* is the watchdog opened via * /dev/watchdog */ };