patch-2.4.18 linux/drivers/char/ib700wdt.c
Next file: linux/drivers/char/joystick/emu10k1-gp.c
Previous file: linux/drivers/char/i810-tco.c
Back to the patch index
Back to the overall index
- Lines: 97
- Date:
Thu Jan 17 22:00:03 2002
- Orig file:
linux.orig/drivers/char/ib700wdt.c
- Orig date:
Mon Feb 18 20:18:39 2002
diff -Naur -X /home/marcelo/lib/dontdiff linux.orig/drivers/char/ib700wdt.c linux/drivers/char/ib700wdt.c
@@ -87,11 +87,34 @@
*
*/
+static int wd_times[] = {
+ 30, /* 0x0 */
+ 28, /* 0x1 */
+ 26, /* 0x2 */
+ 24, /* 0x3 */
+ 22, /* 0x4 */
+ 20, /* 0x5 */
+ 18, /* 0x6 */
+ 16, /* 0x7 */
+ 14, /* 0x8 */
+ 12, /* 0x9 */
+ 10, /* 0xA */
+ 8, /* 0xB */
+ 6, /* 0xC */
+ 4, /* 0xD */
+ 2, /* 0xE */
+ 0, /* 0xF */
+};
+
#define WDT_STOP 0x441
#define WDT_START 0x443
+/* Default timeout */
#define WD_TIMO 0 /* 30 seconds +/- 20%, from table */
+static int wd_margin = WD_TIMO;
+
+
/*
* Kernel methods.
*/
@@ -100,7 +123,7 @@
ibwdt_ping(void)
{
/* Write a watchdog value */
- outb_p(WD_TIMO, WDT_START);
+ outb_p(wd_times[wd_margin], WDT_START);
}
static ssize_t
@@ -127,8 +150,10 @@
ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg)
{
+ int i, new_margin;
+
static struct watchdog_info ident = {
- WDIOF_KEEPALIVEPING, 1, "IB700 WDT"
+ WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, 1, "IB700 WDT"
};
switch (cmd) {
@@ -146,6 +171,22 @@
ibwdt_ping();
break;
+ case WDIOC_SETTIMEOUT:
+ if (get_user(new_margin, (int *)arg))
+ return -EFAULT;
+ if ((new_margin < 0) || (new_margin > 30))
+ return -EINVAL;
+ for (i = 0x0F; i > -1; i--)
+ if (wd_times[i] > new_margin)
+ break;
+ wd_margin = i;
+ ibwdt_ping();
+ /* Fall */
+
+ case WDIOC_GETTIMEOUT:
+ return put_user(wd_times[wd_margin], (int *)arg);
+ break;
+
default:
return -ENOTTY;
}
@@ -182,7 +223,7 @@
if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) {
spin_lock(&ibwdt_lock);
#ifndef CONFIG_WATCHDOG_NOWAYOUT
- outb_p(WD_TIMO, WDT_STOP);
+ outb_p(wd_times[wd_margin], WDT_STOP);
#endif
ibwdt_is_open = 0;
spin_unlock(&ibwdt_lock);
@@ -201,7 +242,7 @@
{
if (code == SYS_DOWN || code == SYS_HALT) {
/* Turn the WDT off */
- outb_p(WD_TIMO, WDT_STOP);
+ outb_p(wd_times[wd_margin], WDT_STOP);
}
return NOTIFY_DONE;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)