Commit df21fd50 authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] 2.6.0-rc1 expect_close.patch

Made the behaviour and syntax of expect_close the same for all watchdog-drivers
parent 35cc1fac
......@@ -57,7 +57,7 @@ static u32 pmbase; /* PMxx I/O base */
static struct pci_dev *dev;
static struct semaphore open_sem;
static spinlock_t amdtco_lock; /* only for device access */
static int expect_close = 0;
static char expect_close;
MODULE_PARM(timeout, "i");
MODULE_PARM_DESC(timeout, "range is 0-38 seconds, default is 38");
......@@ -223,7 +223,7 @@ static int amdtco_fop_ioctl(struct inode *inode, struct file *file, unsigned int
static int amdtco_fop_release(struct inode *inode, struct file *file)
{
if (expect_close) {
if (expect_close == 42) {
amdtco_disable();
printk(KERN_INFO PFX "Watchdog disabled\n");
} else {
......@@ -231,6 +231,7 @@ static int amdtco_fop_release(struct inode *inode, struct file *file)
printk(KERN_CRIT PFX "Unexpected close!, timeout in %d seconds\n", timeout);
}
expect_close = 0;
up(&open_sem);
return 0;
}
......@@ -252,7 +253,7 @@ static ssize_t amdtco_fop_write(struct file *file, const char *data, size_t len,
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
#endif
amdtco_ping();
......
......@@ -50,7 +50,7 @@
static int ibwdt_is_open;
static spinlock_t ibwdt_lock;
static int expect_close = 0;
static char expect_close;
#define PFX "ib700wdt: "
......@@ -157,7 +157,7 @@ ibwdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
if (get_user(c, buf + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
}
ibwdt_ping();
......@@ -236,12 +236,13 @@ static int
ibwdt_close(struct inode *inode, struct file *file)
{
spin_lock(&ibwdt_lock);
if (expect_close)
if (expect_close == 42)
outb_p(wd_times[wd_margin], WDT_STOP);
else
printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n");
ibwdt_is_open = 0;
expect_close = 0;
spin_unlock(&ibwdt_lock);
return 0;
}
......
......@@ -26,7 +26,7 @@
static unsigned long indydog_alive;
static struct sgimc_misc_ctrl *mcmisc_regs;
static int expect_close = 0;
static char expect_close;
#ifdef CONFIG_WATCHDOG_NOWAYOUT
static int nowayout = 1;
......@@ -77,7 +77,7 @@ static int indydog_release(struct inode *inode, struct file *file)
* Lock it in if it's a module and we set nowayout
*/
if (expect_close) {
if (expect_close == 42) {
u32 mc_ctrl0 = mcmisc_regs->cpuctrl0;
mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG;
mcmisc_regs->cpuctrl0 = mc_ctrl0;
......@@ -86,6 +86,7 @@ static int indydog_release(struct inode *inode, struct file *file)
printk(KERN_CRIT "WDT device closed unexpectedly. WDT will not stop!\n");
}
clear_bit(0,&indydog_alive);
expect_close = 0;
return 0;
}
......@@ -109,7 +110,7 @@ static ssize_t indydog_write(struct file *file, const char *data, size_t len, lo
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
}
indydog_ping();
......
......@@ -131,7 +131,7 @@ MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*) 1 = SMI
static int zf_action = GEN_RESET;
static int zf_is_open = 0;
static int zf_expect_close = 0;
static char zf_expect_close;
static spinlock_t zf_lock;
static spinlock_t zf_port_lock;
static struct timer_list zf_timer;
......@@ -330,8 +330,8 @@ static ssize_t zf_write(struct file *file, const char *buf, size_t count,
if (get_user(c, buf + ofs))
return -EFAULT;
if (c == 'V'){
zf_expect_close = 1;
dprintk("zf_expect_close 1\n");
zf_expect_close = 42;
dprintk("zf_expect_close = 42\n");
}
}
}
......@@ -396,7 +396,7 @@ static int zf_open(struct inode *inode, struct file *file)
static int zf_close(struct inode *inode, struct file *file)
{
if(zf_expect_close){
if(zf_expect_close == 42){
zf_timer_off();
} else {
del_timer(&zf_timer);
......
......@@ -60,7 +60,7 @@ static long mixcomwd_opened; /* long req'd for setbit --RR */
static int watchdog_port;
static int mixcomwd_timer_alive;
static struct timer_list mixcomwd_timer = TIMER_INITIALIZER(NULL, 0, 0);
static int expect_close = 0;
static char expect_close;
#ifdef CONFIG_WATCHDOG_NOWAYOUT
static int nowayout = 1;
......@@ -113,7 +113,7 @@ static int mixcomwd_open(struct inode *inode, struct file *file)
static int mixcomwd_release(struct inode *inode, struct file *file)
{
if (expect_close) {
if (expect_close == 42) {
if(mixcomwd_timer_alive) {
printk(KERN_ERR "mixcomwd: release called while internal timer alive");
return -EBUSY;
......@@ -129,6 +129,7 @@ static int mixcomwd_release(struct inode *inode, struct file *file)
}
clear_bit(0,&mixcomwd_opened);
expect_close=0;
return 0;
}
......@@ -152,7 +153,7 @@ static ssize_t mixcomwd_write(struct file *file, const char *data, size_t len, l
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
}
mixcomwd_ping();
......
......@@ -86,7 +86,7 @@ static int pcwd_ioports[] = { 0x270, 0x350, 0x370, 0x000 };
#define WD_TIMEOUT 4 /* 2 seconds for a timeout */
static int timeout_val = WD_TIMEOUT;
static int timeout = 2;
static int expect_close = 0;
static char expect_close;
module_param(timeout, int, 0);
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=2)");
......@@ -415,7 +415,7 @@ static ssize_t pcwd_write(struct file *file, const char *buf, size_t len,
if (get_user(c, buf + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
}
pcwd_send_heartbeat();
......@@ -477,7 +477,7 @@ static ssize_t pcwd_read(struct file *file, char *buf, size_t count,
static int pcwd_close(struct inode *ino, struct file *filep)
{
if (iminor(ino)==WATCHDOG_MINOR) {
if (expect_close) {
if (expect_close == 42) {
/* Disable the board */
if (revision == PCWD_REVISION_C) {
spin_lock(&io_lock);
......@@ -488,6 +488,7 @@ static int pcwd_close(struct inode *ino, struct file *filep)
atomic_inc( &open_allowed );
}
}
expect_close = 0;
return 0;
}
......
......@@ -77,6 +77,7 @@ static int sa1100dog_release(struct inode *inode, struct file *file)
}
clear_bit(1, &sa1100wdt_users);
expect_close = 0;
return 0;
}
......
......@@ -51,7 +51,7 @@ MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
static u16 wdto_restart;
static struct semaphore open_semaphore;
static unsigned expect_close;
static char expect_close;
/* Bits of the WDCNFG register */
#define W_ENABLE 0x00fa /* Enable watchdog */
......@@ -98,18 +98,18 @@ static int scx200_wdt_open(struct inode *inode, struct file *file)
if (down_trylock(&open_semaphore))
return -EBUSY;
scx200_wdt_enable();
expect_close = 0;
return 0;
}
static int scx200_wdt_release(struct inode *inode, struct file *file)
{
if (!expect_close) {
if (expect_close != 42) {
printk(KERN_WARNING NAME ": watchdog device closed unexpectedly, will not disable the watchdog timer\n");
} else if (!nowayout) {
scx200_wdt_disable();
}
expect_close = 0;
up(&open_semaphore);
return 0;
......@@ -149,7 +149,7 @@ static ssize_t scx200_wdt_write(struct file *file, const char *data,
if (get_user(c, data+i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
return len;
......
......@@ -49,7 +49,7 @@
#define TIMER_MARGIN 60 /* (secs) Default is 1 minute */
static int expect_close = 0;
static char expect_close;
static int soft_margin = TIMER_MARGIN; /* in seconds */
#ifdef ONLY_TESTING
static int soft_noboot = 1;
......@@ -120,12 +120,13 @@ static int softdog_release(struct inode *inode, struct file *file)
* Shut off the timer.
* Lock it in if it's a module and we set nowayout
*/
if (expect_close) {
if (expect_close == 42) {
del_timer(&watchdog_ticktock);
} else {
printk(KERN_CRIT "SOFTDOG: WDT device closed unexpectedly. WDT will not stop!\n");
}
clear_bit(0, &timer_alive);
expect_close = 0;
return 0;
}
......@@ -151,7 +152,7 @@ static ssize_t softdog_write(struct file *file, const char *data, size_t len, lo
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
}
mod_timer(&watchdog_ticktock, jiffies+(soft_margin*HZ));
......
......@@ -49,7 +49,7 @@
#include "wd501p.h"
static unsigned long wdt_is_open;
static int expect_close;
static char expect_close;
/*
* You must set these - there is no sane way to probe for this board.
......@@ -261,7 +261,7 @@ static ssize_t wdt_write(struct file *file, const char *buf, size_t count, loff_
if (get_user(c, buf + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
}
wdt_ping();
......@@ -414,13 +414,14 @@ static int wdt_release(struct inode *inode, struct file *file)
{
if(iminor(inode)==WATCHDOG_MINOR)
{
if (expect_close) {
if (expect_close == 42) {
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);
expect_close = 0;
}
return 0;
}
......
......@@ -43,7 +43,7 @@ static int timeout = DEFAULT_TIMEOUT*60; /* TO in seconds from user */
static int timeoutM = DEFAULT_TIMEOUT; /* timeout in minutes */
static unsigned long timer_alive;
static int testmode;
static int expect_close = 0;
static char expect_close;
module_param(timeout, int, 0);
MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (60..15300), default=60");
......@@ -165,7 +165,7 @@ static int wdt977_release(struct inode *inode, struct file *file)
* Shut off the timer.
* Lock it in if it's a module and we set nowayout
*/
if (!nowayout)
if (expect_close == 42)
{
/* unlock the SuperIO chip */
outb(0x87,0x370);
......@@ -202,6 +202,7 @@ static int wdt977_release(struct inode *inode, struct file *file)
} else {
printk(KERN_CRIT "WDT device closed unexpectedly. WDT will not stop!\n");
}
expect_close = 0;
return 0;
}
......@@ -235,7 +236,7 @@ static ssize_t wdt977_write(struct file *file, const char *buf, size_t count, lo
if (get_user(c, buf + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
}
......
......@@ -72,7 +72,7 @@
static struct semaphore open_sem;
static spinlock_t wdtpci_lock;
static int expect_close = 0;
static char expect_close;
static int io;
static int irq;
......@@ -247,7 +247,7 @@ static ssize_t wdtpci_write(struct file *file, const char *buf, size_t count, lo
if(get_user(c, buf+i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
expect_close = 42;
}
}
wdtpci_ping();
......@@ -425,7 +425,7 @@ static int wdtpci_release(struct inode *inode, struct file *file)
if (iminor(inode)==WATCHDOG_MINOR) {
unsigned long flags;
if (expect_close) {
if (expect_close == 42) {
spin_lock_irqsave(&wdtpci_lock, flags);
inb_p(WDT_DC); /* Disable counters */
wdtpci_ctr_load(2,0); /* 0 length reset pulses now */
......@@ -434,6 +434,7 @@ static int wdtpci_release(struct inode *inode, struct file *file)
printk(KERN_CRIT PFX "Unexpected close, not stopping timer!");
wdtpci_ping();
}
expect_close = 0;
up(&open_sem);
}
return 0;
......
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