diff -urw nano/drivers/char/scx200_watchdog.c.orig nano/drivers/char/scx200_watchdog.c --- nano/drivers/char/scx200_watchdog.c.orig Thu Feb 21 13:49:53 2002 +++ nano/drivers/char/scx200_watchdog.c Thu Feb 21 13:55:30 2002 @@ -38,13 +38,15 @@ #define CONFIG_WATCHDOG_NOWAYOUT 0 #endif -static char name[] = "scx200_watchdog"; +static const char name[] = "scx200_watchdog"; static int margin = 60; /* in seconds */ MODULE_PARM(margin, "i"); +MODULE_PARM_DESC(margin, "Watchdog margin in seconds"); static int nowayout = CONFIG_WATCHDOG_NOWAYOUT; MODULE_PARM(nowayout, "i"); +MODULE_PARM_DESC(nowayout, "If true the watchdog can't be disabled\n"); static u16 wdto_restart; static struct semaphore open_sem; @@ -57,6 +59,8 @@ #define WDSTS 0x04 /* Status Register */ #define WDOVF (1<<0) /* Overflow */ +#define W_SCALE (32768/1024) /* This depends on the value of W_ENABLE */ + static void scx200_watchdog_ping(void) { outw(wdto_restart, scx200_config_block + WDTO); @@ -65,7 +69,7 @@ static void scx200_watchdog_update_margin(void) { printk(KERN_INFO "%s: timer margin %d seconds\n", name, margin); - wdto_restart = 32768 / 1024 * margin; + wdto_restart = margin * W_SCALE; scx200_watchdog_ping(); } @@ -117,7 +121,7 @@ static int scx200_watchdog_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { - if (code == SYS_DOWN || code == SYS_HALT) + if (code == SYS_HALT || code == SYS_POWER_OFF) scx200_watchdog_disable(); return NOTIFY_DONE; @@ -125,9 +129,7 @@ static struct notifier_block scx200_watchdog_notifier = { - scx200_watchdog_notify_sys, - NULL, - 0 + notifier_call: scx200_watchdog_notify_sys }; static ssize_t scx200_watchdog_write(struct file *file, const char *data, @@ -182,13 +184,12 @@ case WDIOC_SETTIMEOUT: if (get_user(new_margin, (int *)arg)) return -EFAULT; - margin = new_margin; + margin = new_margin * 60; /* convert minutes to seconds */ scx200_watchdog_update_margin(); return 0; - #ifdef WDIOC_GETTIMEOUT case WDIOC_GETTIMEOUT: - return put_user(margin, (int *)arg); + return put_user((margin + 59) / 60, (int *)arg); #endif } } @@ -210,6 +211,11 @@ static int __init scx200_watchdog_init(void) { int r; + + if (scx200_f0_pdev == NULL) { + printk(KERN_ERR "%s: Not a SCx200 CPU\n", name); + return -ENODEV; + } scx200_watchdog_update_margin(); sema_init(&open_sem, 1);