]> git.neil.brown.name Git - history.git/commitdiff
[WATCHDOG] wdt nowayout changes from 2.4
authorDave Jones <davej@codemonkey.org.u>
Fri, 10 Jan 2003 02:46:53 +0000 (01:46 -0100)
committerDave Jones <davej@tetrachloride.(none)>
Fri, 10 Jan 2003 02:46:53 +0000 (01:46 -0100)
drivers/char/watchdog/wdt.c

index 33deb303e3d40a1af2f881f30c2b2ae800cbb0d5..f50fd376e0ecbc46531e86a054b64b21c4105bff 100644 (file)
@@ -52,6 +52,7 @@
 #include <asm/system.h>
 
 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);
        }