* - Add KERN_* tags to printks
* - fix possible wdt_is_open race
* - Report proper capabilities in watchdog_info
- * - Add WDIOC_{GETSTATUS, GETBOOTSTATUS, SETOPTIONS} ioctls
+ * - Add WDIOC_{GETSTATUS, GETBOOTSTATUS, SETTIMEOUT,
+ * GETTIMEOUT, SETOPTIONS} ioctls
* 09/8 - 2003 Changes by Wim Van Sebroeck <wim@iguana.be>
* - cleanup of trailing spaces
* - added extra printk's for startup problems
* - use module_param
+ * - made timeout (the emulated heartbeat) a module_param
+ * - made the keepalive ping an internal subroutine
*
* This WDT driver is different from most other Linux WDT
* drivers in that the driver will ping the watchdog by itself,
* char to /dev/watchdog every 30 seconds.
*/
-#define WDT_HEARTBEAT (HZ * 30)
+#define WATCHDOG_TIMEOUT 30 /* 30 sec default timeout */
+static int timeout = WATCHDOG_TIMEOUT; /* in seconds, will be multiplied by HZ to get seconds to wait for a ping */
+module_param(timeout, int, 0);
+MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
/*
* AMD Elan SC520 timeout value is 492us times a power of 2 (0-7)
static void wdt_startup(void)
{
- next_heartbeat = jiffies + WDT_HEARTBEAT;
+ next_heartbeat = jiffies + (timeout * HZ);
/* Start the timer */
timer.expires = jiffies + WDT_INTERVAL;
}
}
+static void wdt_keepalive(void)
+{
+ /* user land ping */
+ next_heartbeat = jiffies + (timeout * HZ);
+}
/*
* /dev/watchdog handling
}
/* Well, anyhow someone wrote to us, we should return that favour */
- next_heartbeat = jiffies + WDT_HEARTBEAT;
+ wdt_keepalive();
}
return count;
}
{
static struct watchdog_info ident=
{
- .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
+ .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
.firmware_version = 1,
.identity = "SC520",
};
case WDIOC_GETBOOTSTATUS:
return put_user(0, (int *)arg);
case WDIOC_KEEPALIVE:
- next_heartbeat = jiffies + WDT_HEARTBEAT;
+ wdt_keepalive();
return 0;
case WDIOC_SETOPTIONS:
{
return retval;
}
+ case WDIOC_SETTIMEOUT:
+ {
+ int new_timeout;
+
+ if(get_user(new_timeout, (int *)arg))
+ return -EFAULT;
+
+ if(new_timeout < 1 || new_timeout > 3600) /* arbitrary upper limit */
+ return -EINVAL;
+
+ timeout = new_timeout;
+ wdt_keepalive();
+ /* Fall through */
+ }
+ case WDIOC_GETTIMEOUT:
+ return put_user(timeout, (int *)arg);
}
}
spin_lock_init(&wdt_spinlock);
+ if(timeout < 1 || timeout > 3600) /* arbitrary upper limit */
+ {
+ timeout = WATCHDOG_TIMEOUT;
+ printk(KERN_INFO PFX "timeout value must be 1<=x<=3600, using %d\n",
+ timeout);
+ }
+
init_timer(&timer);
timer.function = wdt_timer_ping;
timer.data = 0;
wdtmrctl = (__u16 *)((char *)wdtmrctl + OFFS_WDTMRCTL);
wdtmrctl = ioremap((unsigned long)wdtmrctl, 2);
- printk(KERN_INFO PFX "WDT driver for SC520 initialised. (nowayout=%d)\n",
- nowayout);
+ printk(KERN_INFO PFX "WDT driver for SC520 initialised. timeout=%d sec (nowayout=%d)\n",
+ timeout,nowayout);
return 0;