Commit 24f83f6a authored by Dave Jones's avatar Dave Jones

[PATCH] watchdog nowayout for advantechwdt

Originally from Matt Domsch.
Adds a nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
From 2.4
parent 5fc0937f
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
* *
* (c) Copyright 1995 Alan Cox <alan@redhat.com> * (c) Copyright 1995 Alan Cox <alan@redhat.com>
* *
* 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
* Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
* Added timeout module option to override default
*/ */
#include <linux/config.h> #include <linux/config.h>
...@@ -56,8 +59,7 @@ static spinlock_t advwdt_lock; ...@@ -56,8 +59,7 @@ static spinlock_t advwdt_lock;
* the manual says WDT_STOP is 0x43, not 0x443). * the manual says WDT_STOP is 0x43, not 0x443).
* (0x43 is also a write-only control register for the 8254 timer!) * (0x43 is also a write-only control register for the 8254 timer!)
* *
* TODO: module parameters to set the I/O port addresses and NOWAYOUT * TODO: module parameters to set the I/O port addresses
* option at load time.
*/ */
#define WDT_STOP 0x443 #define WDT_STOP 0x443
...@@ -65,6 +67,19 @@ static spinlock_t advwdt_lock; ...@@ -65,6 +67,19 @@ static spinlock_t advwdt_lock;
#define WD_TIMO 60 /* 1 minute */ #define WD_TIMO 60 /* 1 minute */
static int timeout = WD_TIMO; /* in seconds */
MODULE_PARM(timeout,"i");
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=60)");
#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)");
/* /*
* Kernel methods. * Kernel methods.
*/ */
...@@ -73,7 +88,7 @@ static void ...@@ -73,7 +88,7 @@ static void
advwdt_ping(void) advwdt_ping(void)
{ {
/* Write a watchdog value */ /* Write a watchdog value */
outb_p(WD_TIMO, WDT_START); outb_p(timeout, WDT_START);
} }
static ssize_t static ssize_t
...@@ -135,6 +150,9 @@ advwdt_open(struct inode *inode, struct file *file) ...@@ -135,6 +150,9 @@ advwdt_open(struct inode *inode, struct file *file)
spin_unlock(&advwdt_lock); spin_unlock(&advwdt_lock);
return -EBUSY; return -EBUSY;
} }
if (nowayout) {
MOD_INC_USE_COUNT;
}
/* /*
* Activate * Activate
*/ */
...@@ -153,9 +171,9 @@ advwdt_close(struct inode *inode, struct file *file) ...@@ -153,9 +171,9 @@ advwdt_close(struct inode *inode, struct file *file)
{ {
if (minor(inode->i_rdev) == WATCHDOG_MINOR) { if (minor(inode->i_rdev) == WATCHDOG_MINOR) {
spin_lock(&advwdt_lock); spin_lock(&advwdt_lock);
#ifndef CONFIG_WATCHDOG_NOWAYOUT if (!nowayout) {
inb_p(WDT_STOP); inb_p(WDT_STOP);
#endif }
advwdt_is_open = 0; advwdt_is_open = 0;
spin_unlock(&advwdt_lock); spin_unlock(&advwdt_lock);
} }
...@@ -207,11 +225,21 @@ static struct notifier_block advwdt_notifier = { ...@@ -207,11 +225,21 @@ static struct notifier_block advwdt_notifier = {
0 0
}; };
static void __init
advwdt_validate_timeout(void)
{
if (timeout < 1 || timeout > 63) {
timeout = WD_TIMO;
printk(KERN_INFO "advantechwdt: timeout value must be 1 <= x <= 63, using %d\n", timeout);
}
}
static int __init static int __init
advwdt_init(void) advwdt_init(void)
{ {
printk("WDT driver for Advantech single board computer initialising.\n"); printk("WDT driver for Advantech single board computer initialising.\n");
advwdt_validate_timeout();
spin_lock_init(&advwdt_lock); spin_lock_init(&advwdt_lock);
misc_register(&advwdt_miscdev); misc_register(&advwdt_miscdev);
#if WDT_START != WDT_STOP #if WDT_START != WDT_STOP
......
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