Commit dab4075e authored by Dave Jones's avatar Dave Jones

[PATCH] watchdog nowayout for mixcomwd

Originally from Matt Domsch.
Adds a nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
From 2.4
parent 99458ba3
...@@ -27,10 +27,13 @@ ...@@ -27,10 +27,13 @@
* *
* Version 0.4 (99/11/15): * Version 0.4 (99/11/15):
* - support for one more type board * - 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/module.h>
#include <linux/config.h> #include <linux/config.h>
...@@ -57,26 +60,30 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 }; ...@@ -57,26 +60,30 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 };
static long mixcomwd_opened; /* long req'd for setbit --RR */ static long mixcomwd_opened; /* long req'd for setbit --RR */
static int watchdog_port; static int watchdog_port;
#ifndef CONFIG_WATCHDOG_NOWAYOUT
static int mixcomwd_timer_alive; static int mixcomwd_timer_alive;
static struct timer_list mixcomwd_timer; static struct timer_list mixcomwd_timer;
#ifdef CONFIG_WATCHDOG_NOWAYOUT
static int nowayout = 1;
#else
static int nowayout = 0;
#endif #endif
MODULE_PARM(nowayout,"i");
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
static void mixcomwd_ping(void) static void mixcomwd_ping(void)
{ {
outb_p(55,watchdog_port); outb_p(55,watchdog_port);
return; return;
} }
#ifndef CONFIG_WATCHDOG_NOWAYOUT
static void mixcomwd_timerfun(unsigned long d) static void mixcomwd_timerfun(unsigned long d)
{ {
mixcomwd_ping(); mixcomwd_ping();
mod_timer(&mixcomwd_timer,jiffies+ 5*HZ); mod_timer(&mixcomwd_timer,jiffies+ 5*HZ);
} }
#endif
/* /*
* Allow only one person to hold it open * Allow only one person to hold it open
...@@ -89,31 +96,32 @@ static int mixcomwd_open(struct inode *inode, struct file *file) ...@@ -89,31 +96,32 @@ static int mixcomwd_open(struct inode *inode, struct file *file)
} }
mixcomwd_ping(); mixcomwd_ping();
#ifndef CONFIG_WATCHDOG_NOWAYOUT if (nowayout) {
if(mixcomwd_timer_alive) { MOD_INC_USE_COUNT;
del_timer(&mixcomwd_timer); } else {
mixcomwd_timer_alive=0; if(mixcomwd_timer_alive) {
} del_timer(&mixcomwd_timer);
#endif mixcomwd_timer_alive=0;
}
}
return 0; return 0;
} }
static int mixcomwd_release(struct inode *inode, struct file *file) static int mixcomwd_release(struct inode *inode, struct file *file)
{ {
#ifndef CONFIG_WATCHDOG_NOWAYOUT if (!nowayout) {
if(mixcomwd_timer_alive) { if(mixcomwd_timer_alive) {
printk(KERN_ERR "mixcomwd: release called while internal timer alive"); printk(KERN_ERR "mixcomwd: release called while internal timer alive");
return -EBUSY; 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); clear_bit(0,&mixcomwd_opened);
return 0; return 0;
} }
...@@ -145,9 +153,9 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file, ...@@ -145,9 +153,9 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file,
{ {
case WDIOC_GETSTATUS: case WDIOC_GETSTATUS:
status=mixcomwd_opened; status=mixcomwd_opened;
#ifndef CONFIG_WATCHDOG_NOWAYOUT if (!nowayout) {
status|=mixcomwd_timer_alive; status|=mixcomwd_timer_alive;
#endif }
if (copy_to_user((int *)arg, &status, sizeof(int))) { if (copy_to_user((int *)arg, &status, sizeof(int))) {
return -EFAULT; return -EFAULT;
} }
...@@ -252,14 +260,14 @@ static int __init mixcomwd_init(void) ...@@ -252,14 +260,14 @@ static int __init mixcomwd_init(void)
static void __exit mixcomwd_exit(void) static void __exit mixcomwd_exit(void)
{ {
#ifndef CONFIG_WATCHDOG_NOWAYOUT if (!nowayout) {
if(mixcomwd_timer_alive) { if(mixcomwd_timer_alive) {
printk(KERN_WARNING "mixcomwd: I quit now, hardware will" printk(KERN_WARNING "mixcomwd: I quit now, hardware will"
" probably reboot!\n"); " probably reboot!\n");
del_timer(&mixcomwd_timer); del_timer(&mixcomwd_timer);
mixcomwd_timer_alive=0; mixcomwd_timer_alive=0;
}
} }
#endif
release_region(watchdog_port,1); release_region(watchdog_port,1);
misc_deregister(&mixcomwd_miscdev); misc_deregister(&mixcomwd_miscdev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment