From: Dave Jones Date: Fri, 10 Jan 2003 02:46:53 +0000 (-0100) Subject: [WATCHDOG] wdt nowayout changes from 2.4 X-Git-Tag: v2.5.56~1^2~1^2~4 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=ac8173fa3e8a6f7c73e2fcddcfc6a092af7c426a;p=history.git [WATCHDOG] wdt nowayout changes from 2.4 --- diff --git a/drivers/char/watchdog/wdt.c b/drivers/char/watchdog/wdt.c index 33deb303e3d4..f50fd376e0ec 100644 --- a/drivers/char/watchdog/wdt.c +++ b/drivers/char/watchdog/wdt.c @@ -52,6 +52,7 @@ #include static unsigned long wdt_is_open; +static int expect_close; /* * You must set these - there is no sane way to probe for this board. @@ -258,8 +259,21 @@ static ssize_t wdt_write(struct file *file, const char *buf, size_t count, loff_ if (ppos != &file->f_pos) return -ESPIPE; - if(count) - { + if(count) { + if (!nowayout) { + size_t i; + + /* In case it was set long ago */ + expect_close = 0; + + for (i = 0; i != count; i++) { + char c; + if (get_user(c, buf + i)) + return -EFAULT; + if (c == 'V') + expect_close = 1; + } + } wdt_ping(); return 1; } @@ -317,10 +331,11 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, { static struct watchdog_info ident= { - WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER - |WDIOF_EXTERN1|WDIOF_EXTERN2|WDIOF_FANFAULT, - 1, - "WDT500/501" + .options = WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER + |WDIOF_EXTERN1|WDIOF_EXTERN2|WDIOF_FANFAULT + |WDIOF_SETTIMEOUT|WDIOF_MAGICCLOSE, + .firmware_version = 1, + .identity = "WDT500/501" }; ident.options&=WDT_OPTION_MASK; /* Mask down to the card we have */ @@ -399,9 +414,11 @@ static int wdt_release(struct inode *inode, struct file *file) { if(minor(inode->i_rdev)==WATCHDOG_MINOR) { - if (!nowayout) { + if (expect_close) { inb_p(WDT_DC); /* Disable counters */ wdt_ctr_load(2,0); /* 0 length reset pulses now */ + } else { + printk(KERN_CRIT "wdt: WDT device closed unexpectedly. WDT will not stop!\n"); } clear_bit(0, &wdt_is_open); }