]> git.hungrycats.org Git - linux/commitdiff
[PATCH] watchdog nowayout for mixcomwd
authorDave Jones <davej@suse.de>
Wed, 3 Apr 2002 04:00:35 +0000 (20:00 -0800)
committerDave Jones <davej@suse.de>
Wed, 3 Apr 2002 04:00:35 +0000 (20:00 -0800)
Originally from Matt Domsch.
Adds a nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
From 2.4

drivers/char/mixcomwd.c

index 3f6e87a7c0d2d7b53f8da438e4df02e760112cae..bbcb881ef1b05186b0bb34290db3911fb95dcc6a 100644 (file)
  *
  * Version 0.4 (99/11/15):
  *             - support for one more type board
+ *
+ * Version 0.5 (2001/12/14) Matt Domsch <Matt_Domsch@dell.com>
+ *              - added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
  *     
  */
 
-#define VERSION "0.4
+#define VERSION "0.5
   
 #include <linux/module.h>
 #include <linux/config.h>
@@ -57,26 +60,30 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 };
 static long mixcomwd_opened; /* long req'd for setbit --RR */
 
 static int watchdog_port;
-
-#ifndef CONFIG_WATCHDOG_NOWAYOUT
 static int mixcomwd_timer_alive;
 static struct timer_list mixcomwd_timer;
+
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
+static int nowayout = 1;
+#else
+static int nowayout = 0;
 #endif
 
+MODULE_PARM(nowayout,"i");
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
+
 static void mixcomwd_ping(void)
 {
        outb_p(55,watchdog_port);
        return;
 }
 
-#ifndef CONFIG_WATCHDOG_NOWAYOUT
 static void mixcomwd_timerfun(unsigned long d)
 {
        mixcomwd_ping();
        
        mod_timer(&mixcomwd_timer,jiffies+ 5*HZ);
 }
-#endif
 
 /*
  *     Allow only one person to hold it open
@@ -89,31 +96,32 @@ static int mixcomwd_open(struct inode *inode, struct file *file)
        }
        mixcomwd_ping();
        
-#ifndef CONFIG_WATCHDOG_NOWAYOUT
-       if(mixcomwd_timer_alive) {
-               del_timer(&mixcomwd_timer);
-               mixcomwd_timer_alive=0;
-       } 
-#endif
+       if (nowayout) {
+               MOD_INC_USE_COUNT;
+       } else {
+               if(mixcomwd_timer_alive) {
+                       del_timer(&mixcomwd_timer);
+                       mixcomwd_timer_alive=0;
+               }
+       }
        return 0;
 }
 
 static int mixcomwd_release(struct inode *inode, struct file *file)
 {
 
-#ifndef CONFIG_WATCHDOG_NOWAYOUT
-       if(mixcomwd_timer_alive) {
-               printk(KERN_ERR "mixcomwd: release called while internal timer alive");
-               return -EBUSY;
+       if (!nowayout) {
+               if(mixcomwd_timer_alive) {
+                       printk(KERN_ERR "mixcomwd: release called while internal timer alive");
+                       return -EBUSY;
+               }
+               init_timer(&mixcomwd_timer);
+               mixcomwd_timer.expires=jiffies + 5 * HZ;
+               mixcomwd_timer.function=mixcomwd_timerfun;
+               mixcomwd_timer.data=0;
+               mixcomwd_timer_alive=1;
+               add_timer(&mixcomwd_timer);
        }
-       init_timer(&mixcomwd_timer);
-       mixcomwd_timer.expires=jiffies + 5 * HZ;
-       mixcomwd_timer.function=mixcomwd_timerfun;
-       mixcomwd_timer.data=0;
-       mixcomwd_timer_alive=1;
-       add_timer(&mixcomwd_timer);
-#endif
-
        clear_bit(0,&mixcomwd_opened);
        return 0;
 }
@@ -145,9 +153,9 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file,
        {
                case WDIOC_GETSTATUS:
                        status=mixcomwd_opened;
-#ifndef CONFIG_WATCHDOG_NOWAYOUT
-                       status|=mixcomwd_timer_alive;
-#endif
+                       if (!nowayout) {
+                               status|=mixcomwd_timer_alive;
+                       }
                        if (copy_to_user((int *)arg, &status, sizeof(int))) {
                                return -EFAULT;
                        }
@@ -252,14 +260,14 @@ static int __init mixcomwd_init(void)
 
 static void __exit mixcomwd_exit(void)
 {
-#ifndef CONFIG_WATCHDOG_NOWAYOUT
-       if(mixcomwd_timer_alive) {
-               printk(KERN_WARNING "mixcomwd: I quit now, hardware will"
-                       " probably reboot!\n");
-               del_timer(&mixcomwd_timer);
-               mixcomwd_timer_alive=0;
+       if (!nowayout) {
+               if(mixcomwd_timer_alive) {
+                       printk(KERN_WARNING "mixcomwd: I quit now, hardware will"
+                              " probably reboot!\n");
+                       del_timer(&mixcomwd_timer);
+                       mixcomwd_timer_alive=0;
+               }
        }
-#endif
        release_region(watchdog_port,1);
        misc_deregister(&mixcomwd_miscdev);
 }