Commit a5ab05a5 authored by Linus Torvalds's avatar Linus Torvalds

Merge http://linux-watchdog.bkbits.net/linux-2.6-watchdog

into home.osdl.org:/home/torvalds/v2.5/linux
parents 0010bc50 30cbd07c
......@@ -100,7 +100,7 @@ static ssize_t acq_write(struct file *file, const char *buf, size_t count, loff_
* five months ago... */
expect_close = 0;
/* scan to see wether or not we got the magic character */
/* scan to see whether or not we got the magic character */
for (i = 0; i != count; i++) {
char c;
if (get_user(c, buf + i))
......
......@@ -183,7 +183,7 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
}
default:
return -ENOTTY;
return -ENOIOCTLCMD;
}
return 0;
}
......
......@@ -153,7 +153,7 @@ static ssize_t ali_write(struct file *file, const char *data,
* five months ago... */
ali_expect_release = 0;
/* scan to see wether or not we got the magic character */
/* scan to see whether or not we got the magic character */
for (i = 0; i != len; i++) {
char c;
if(get_user(c, data+i))
......@@ -402,7 +402,7 @@ static int __init watchdog_init(void)
spin_lock_init(&ali_lock);
/* Check wether or not the hardware watchdog is there */
/* Check whether or not the hardware watchdog is there */
if (ali_find_watchdog() != 0) {
return -ENODEV;
}
......
......@@ -19,6 +19,7 @@
#include <linux/config.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
......@@ -57,11 +58,20 @@ 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_param(timeout, int, 0);
MODULE_PARM_DESC(timeout, "range is 0-38 seconds, default is 38");
#ifdef CONFIG_WATCHDOG_NOWAYOUT
static int nowayout = 1;
#else
static int nowayout = 0;
#endif
module_param(nowayout, int, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
static inline u8 seconds_to_ticks(int seconds)
{
/* the internal timer is stored as ticks which decrement
......@@ -170,12 +180,12 @@ static int amdtco_fop_ioctl(struct inode *inode, struct file *file, unsigned int
static struct watchdog_info ident = {
.options = WDIOF_SETTIMEOUT | WDIOF_CARDRESET,
.identity = "AMD 766/768"
.identity = "AMD 766/768",
};
switch (cmd) {
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof ident))
......@@ -223,7 +233,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 +241,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;
}
......@@ -242,7 +253,7 @@ static ssize_t amdtco_fop_write(struct file *file, const char *data, size_t len,
return -ESPIPE;
if (len) {
#ifndef CONFIG_WATCHDOG_NOWAYOUT
if (!nowayout) {
size_t i;
char c;
expect_close = 0;
......@@ -252,9 +263,9 @@ 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();
}
......@@ -273,7 +284,7 @@ static int amdtco_notify_sys(struct notifier_block *this, unsigned long code, vo
static struct notifier_block amdtco_notifier =
{
.notifier_call = amdtco_notify_sys
.notifier_call = amdtco_notify_sys,
};
static struct file_operations amdtco_fops =
......@@ -282,20 +293,20 @@ static struct file_operations amdtco_fops =
.write = amdtco_fop_write,
.ioctl = amdtco_fop_ioctl,
.open = amdtco_fop_open,
.release = amdtco_fop_release
.release = amdtco_fop_release,
};
static struct miscdevice amdtco_miscdev =
{
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &amdtco_fops
.fops = &amdtco_fops,
};
static struct pci_device_id amdtco_pci_tbl[] = {
/* AMD 766 PCI_IDs here */
{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_OPUS_7443, PCI_ANY_ID, PCI_ANY_ID, },
{ 0, }
{ 0, },
};
MODULE_DEVICE_TABLE (pci, amdtco_pci_tbl);
......
......@@ -134,23 +134,15 @@ static int cpu5wdt_stop(void)
static int cpu5wdt_open(struct inode *inode, struct file *file)
{
switch(iminor(inode)) {
case WATCHDOG_MINOR:
if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
return -EBUSY;
break;
default:
return -ENODEV;
}
return 0;
}
static int cpu5wdt_release(struct inode *inode, struct file *file)
{
if(iminor(inode)==WATCHDOG_MINOR) {
clear_bit(0, &cpu5wdt_device.inuse);
}
return 0;
}
......@@ -160,7 +152,7 @@ static int cpu5wdt_ioctl(struct inode *inode, struct file *file, unsigned int cm
static struct watchdog_info ident =
{
.options = WDIOF_CARDRESET,
.identity = "CPU5 WDT"
.identity = "CPU5 WDT",
};
switch(cmd) {
......@@ -191,7 +183,7 @@ static int cpu5wdt_ioctl(struct inode *inode, struct file *file, unsigned int cm
}
break;
default:
return -EINVAL;
return -ENOIOCTLCMD;
}
return 0;
}
......@@ -217,7 +209,7 @@ static struct file_operations cpu5wdt_fops = {
static struct miscdevice cpu5wdt_misc = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &cpu5wdt_fops
.fops = &cpu5wdt_fops,
};
/* init/exit function */
......
/*
* Eurotech CPU-1220/1410 on board WDT driver for Linux 2.4.x
* Eurotech CPU-1220/1410 on board WDT driver
*
* (c) Copyright 2001 Ascensit <support@ascensit.com>
* (c) Copyright 2001 Rodolfo Giometti <giometti@ascensit.com>
......@@ -277,7 +277,7 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file,
switch(cmd) {
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
return copy_to_user((struct watchdog_info *)arg, &ident,
......@@ -406,7 +406,7 @@ static struct file_operations eurwdt_fops = {
static struct miscdevice eurwdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &eurwdt_fops
.fops = &eurwdt_fops,
};
/*
......
......@@ -197,7 +197,7 @@ static int i810tco_release (struct inode *inode, struct file *file)
/*
* Shut off the timer.
*/
if (tco_expect_close == 42 && !nowayout) {
if (tco_expect_close == 42) {
tco_timer_stop ();
} else {
tco_timer_reload ();
......@@ -217,8 +217,11 @@ static ssize_t i810tco_write (struct file *file, const char *data,
/* See if we got the magic character 'V' and reload the timer */
if (len) {
if (!nowayout) {
size_t i;
/* note: just in case someone wrote the magic character
* five months ago... */
tco_expect_close = 0;
/* scan to see whether or not we got the magic character */
......@@ -229,6 +232,7 @@ static ssize_t i810tco_write (struct file *file, const char *data,
if (c == 'V')
tco_expect_close = 42;
}
}
/* someone wrote to us, we should reload the timer */
tco_timer_reload ();
......@@ -251,7 +255,7 @@ static int i810tco_ioctl (struct inode *inode, struct file *file,
};
switch (cmd) {
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
if (copy_to_user
((struct watchdog_info *) arg, &ident, sizeof (ident)))
......
/*
* IB700 Single Board Computer WDT driver for Linux 2.4.x
* IB700 Single Board Computer WDT driver
*
* (c) Copyright 2001 Charles Howes <chowes@vsol.net>
*
......@@ -48,9 +48,9 @@
#include <asm/uaccess.h>
#include <asm/system.h>
static int ibwdt_is_open;
static unsigned long 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();
......@@ -174,7 +174,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
.firmware_version = 1,
.identity = "IB700 WDT"
.identity = "IB700 WDT",
};
switch (cmd) {
......@@ -184,9 +184,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break;
case WDIOC_GETSTATUS:
if (copy_to_user((int *)arg, &ibwdt_is_open, sizeof(int)))
return -EFAULT;
break;
return put_user(0, (int *) arg);
case WDIOC_KEEPALIVE:
ibwdt_ping();
......@@ -209,7 +207,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break;
default:
return -ENOTTY;
return -ENOIOCTLCMD;
}
return 0;
}
......@@ -217,9 +215,8 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
static int
ibwdt_open(struct inode *inode, struct file *file)
{
if (iminor(inode) == WATCHDOG_MINOR) {
spin_lock(&ibwdt_lock);
if (ibwdt_is_open) {
if (test_and_set_bit(0, &ibwdt_is_open)) {
spin_unlock(&ibwdt_lock);
return -EBUSY;
}
......@@ -227,28 +224,23 @@ ibwdt_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE);
/* Activate */
ibwdt_is_open = 1;
ibwdt_ping();
spin_unlock(&ibwdt_lock);
return 0;
} else {
return -ENODEV;
}
}
static int
ibwdt_close(struct inode *inode, struct file *file)
{
if (iminor(inode) == WATCHDOG_MINOR) {
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;
clear_bit(0, &ibwdt_is_open);
expect_close = 0;
spin_unlock(&ibwdt_lock);
}
return 0;
}
......@@ -282,7 +274,7 @@ static struct file_operations ibwdt_fops = {
static struct miscdevice ibwdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &ibwdt_fops
.fops = &ibwdt_fops,
};
/*
......@@ -293,7 +285,7 @@ static struct miscdevice ibwdt_miscdev = {
static struct notifier_block ibwdt_notifier = {
.notifier_call = ibwdt_notify_sys,
.next = NULL,
.priority = 0
.priority = 0,
};
static int __init ibwdt_init(void)
......
......@@ -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();
......
......@@ -113,7 +113,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CON
static struct watchdog_info zf_info = {
.options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
.firmware_version = 1,
.identity = "ZF-Logic watchdog"
.identity = "ZF-Logic watchdog",
};
......@@ -130,8 +130,8 @@ module_param(action, int, 0);
MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*) 1 = SMI 2 = NMI 3 = SCI");
static int zf_action = GEN_RESET;
static int zf_is_open = 0;
static int zf_expect_close = 0;
static unsigned long zf_is_open;
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");
}
}
}
......@@ -359,16 +359,14 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break;
case WDIOC_GETSTATUS:
if (copy_to_user((int *)arg, &zf_is_open, sizeof(int)))
return -EFAULT;
break;
return put_user(0, (int *) arg);
case WDIOC_KEEPALIVE:
zf_ping(0);
break;
default:
return -ENOTTY;
return -ENOIOCTLCMD;
}
return 0;
......@@ -376,10 +374,8 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
static int zf_open(struct inode *inode, struct file *file)
{
switch(iminor(inode)){
case WATCHDOG_MINOR:
spin_lock(&zf_lock);
if(zf_is_open){
if(test_and_set_bit(0, &zf_is_open)) {
spin_unlock(&zf_lock);
return -EBUSY;
}
......@@ -387,23 +383,16 @@ static int zf_open(struct inode *inode, struct file *file)
if (nowayout)
__module_get(THIS_MODULE);
zf_is_open = 1;
spin_unlock(&zf_lock);
zf_timer_on();
return 0;
default:
return -ENODEV;
}
}
static int zf_close(struct inode *inode, struct file *file)
{
if(iminor(inode) == WATCHDOG_MINOR){
if(zf_expect_close){
if(zf_expect_close == 42){
zf_timer_off();
} else {
del_timer(&zf_timer);
......@@ -411,11 +400,10 @@ static int zf_close(struct inode *inode, struct file *file)
}
spin_lock(&zf_lock);
zf_is_open = 0;
clear_bit(0, &zf_is_open);
spin_unlock(&zf_lock);
zf_expect_close = 0;
}
return 0;
}
......@@ -448,7 +436,7 @@ static struct file_operations zf_fops = {
static struct miscdevice zf_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &zf_fops
.fops = &zf_fops,
};
......@@ -459,7 +447,7 @@ static struct miscdevice zf_miscdev = {
static struct notifier_block zf_notifier = {
.notifier_call = zf_notify_sys,
.next = NULL,
.priority = 0
.priority = 0,
};
static void __init zf_show_action(int act)
......
......@@ -55,12 +55,12 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 };
#define FLASHCOM_WATCHDOG_OFFSET 0x4
#define FLASHCOM_ID 0x18
static long mixcomwd_opened; /* long req'd for setbit --RR */
static unsigned 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();
......@@ -167,7 +168,7 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file,
static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
.firmware_version = 1,
.identity = "MixCOM watchdog"
.identity = "MixCOM watchdog",
};
switch(cmd)
......@@ -191,7 +192,7 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file,
mixcomwd_ping();
break;
default:
return -ENOTTY;
return -ENOIOCTLCMD;
}
return 0;
}
......@@ -207,9 +208,9 @@ static struct file_operations mixcomwd_fops=
static struct miscdevice mixcomwd_miscdev=
{
WATCHDOG_MINOR,
"watchdog",
&mixcomwd_fops
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &mixcomwd_fops,
};
static int __init mixcomwd_checkcard(int port)
......
......@@ -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)");
......@@ -248,14 +248,14 @@ static int pcwd_ioctl(struct inode *inode, struct file *file,
int cdat, rv;
static struct watchdog_info ident=
{
WDIOF_OVERHEAT|WDIOF_CARDRESET,
1,
"PCWD"
.options = WDIOF_OVERHEAT|WDIOF_CARDRESET,
.firmware_version = 1,
.identity = "PCWD",
};
switch(cmd) {
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
if(copy_to_user((void*)arg, &ident, sizeof(ident)))
......@@ -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;
}
......@@ -576,15 +577,15 @@ static struct file_operations pcwd_fops = {
};
static struct miscdevice pcwd_miscdev = {
WATCHDOG_MINOR,
"watchdog",
&pcwd_fops
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &pcwd_fops,
};
static struct miscdevice temp_miscdev = {
TEMP_MINOR,
"temperature",
&pcwd_fops
.minor = TEMP_MINOR,
.name = "temperature",
.fops = &pcwd_fops,
};
static void __init pcwd_validate_timeout(void)
......
......@@ -77,6 +77,7 @@ static int sa1100dog_release(struct inode *inode, struct file *file)
}
clear_bit(1, &sa1100wdt_users);
expect_close = 0;
return 0;
}
......
......@@ -183,7 +183,7 @@ static ssize_t fop_write(struct file * file, const char * buf, size_t count, lof
* five months ago... */
wdt_expect_close = 0;
/* scan to see wether or not we got the magic character */
/* scan to see whether or not we got the magic character */
for(ofs = 0; ofs != count; ofs++)
{
char c;
......
......@@ -175,12 +175,12 @@ static int sc1200wdt_ioctl(struct inode *inode, struct file *file, unsigned int
static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
.firmware_version = 0,
.identity = "PC87307/PC97307"
.identity = "PC87307/PC97307",
};
switch (cmd) {
default:
return -ENOTTY; /* Keep Pavel Machek amused ;) */
return -ENOIOCTLCMD; /* Keep Pavel Machek amused ;) */
case WDIOC_GETSUPPORT:
if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof ident))
......@@ -292,7 +292,7 @@ static int sc1200wdt_notify_sys(struct notifier_block *this, unsigned long code,
static struct notifier_block sc1200wdt_notifier =
{
notifier_call: sc1200wdt_notify_sys
.notifier_call = sc1200wdt_notify_sys,
};
static struct file_operations sc1200wdt_fops =
......@@ -301,7 +301,7 @@ static struct file_operations sc1200wdt_fops =
.write = sc1200wdt_write,
.ioctl = sc1200wdt_ioctl,
.open = sc1200wdt_open,
.release = sc1200wdt_release
.release = sc1200wdt_release,
};
static struct miscdevice sc1200wdt_miscdev =
......@@ -334,7 +334,7 @@ static int __init sc1200wdt_probe(void)
struct pnp_device_id scl200wdt_pnp_devices[] = {
/* National Semiconductor PC87307/PC97307 watchdog component */
{.id = "NSC0800", .driver_data = 0},
{.id = ""}
{.id = ""},
};
static int scl200wdt_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id)
......
/* linux/drivers/char/scx200_wdt.c
/* drivers/char/watchdog/scx200_wdt.c
National Semiconductor SCx200 Watchdog support
......@@ -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;
......@@ -127,7 +127,7 @@ static int scx200_wdt_notify_sys(struct notifier_block *this,
static struct notifier_block scx200_wdt_notifier =
{
.notifier_call = scx200_wdt_notify_sys
.notifier_call = scx200_wdt_notify_sys,
};
static ssize_t scx200_wdt_write(struct file *file, const char *data,
......@@ -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;
......@@ -170,7 +170,7 @@ static int scx200_wdt_ioctl(struct inode *inode, struct file *file,
switch (cmd) {
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
if(copy_to_user((struct watchdog_info *)arg, &ident,
sizeof(ident)))
......
......@@ -303,7 +303,7 @@ static int sh_wdt_ioctl(struct inode *inode, struct file *file,
return retval;
}
default:
return -ENOTTY;
return -ENOIOCTLCMD;
}
return 0;
......
......@@ -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));
......@@ -169,7 +170,7 @@ static int softdog_ioctl(struct inode *inode, struct file *file,
};
switch (cmd) {
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
if(copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
return -EFAULT;
......
......@@ -184,7 +184,7 @@ wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
}
default:
return -ENOTTY;
return -ENOIOCTLCMD;
}
return 0;
}
......
......@@ -205,7 +205,7 @@ static ssize_t fop_write(struct file * file, const char * buf, size_t count, lof
* five months ago... */
wdt_expect_close = 0;
/* scan to see wether or not we got the magic character */
/* scan to see whether or not we got the magic character */
for(ofs = 0; ofs != count; ofs++)
{
char c;
......
......@@ -109,7 +109,7 @@ static ssize_t wafwdt_write(struct file *file, const char *buf, size_t count, lo
/* In case it was set long ago */
expect_close = 0;
/* scan to see wether or not we got the magic character */
/* scan to see whether or not we got the magic character */
for (i = 0; i != count; i++) {
char c;
if (get_user(c, buf + i))
......@@ -182,7 +182,7 @@ static int wafwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd
}
default:
return -ENOTTY;
return -ENOIOCTLCMD;
}
return 0;
}
......
......@@ -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();
......@@ -326,14 +326,14 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
|WDIOF_EXTERN1|WDIOF_EXTERN2|WDIOF_FANFAULT
|WDIOF_SETTIMEOUT|WDIOF_MAGICCLOSE,
.firmware_version = 1,
.identity = "WDT500/501"
.identity = "WDT500/501",
};
ident.options&=WDT_OPTION_MASK; /* Mask down to the card we have */
switch(cmd)
{
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))?-EFAULT:0;
......@@ -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;
}
......@@ -468,7 +469,7 @@ static struct miscdevice wdt_miscdev=
{
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &wdt_fops
.fops = &wdt_fops,
};
#ifdef CONFIG_WDT_501
......@@ -476,7 +477,7 @@ static struct miscdevice temp_miscdev=
{
.minor = TEMP_MINOR,
.name = "temperature",
.fops = &wdt_fops
.fops = &wdt_fops,
};
#endif
......@@ -489,7 +490,7 @@ static struct notifier_block wdt_notifier=
{
.notifier_call = wdt_notify_sys,
.next = NULL,
.priority = 0
.priority = 0,
};
/**
......
......@@ -132,7 +132,7 @@ watchdog_write(struct file *file, const char *data, size_t len, loff_t *ppos)
static struct watchdog_info ident = {
.options = WDIOF_SETTIMEOUT,
.identity = "Footbridge Watchdog"
.identity = "Footbridge Watchdog",
};
static int
......@@ -192,7 +192,7 @@ static struct file_operations watchdog_fops = {
static struct miscdevice watchdog_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &watchdog_fops
.fops = &watchdog_fops,
};
static int __init footbridge_watchdog_init(void)
......
......@@ -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;
}
}
......@@ -257,7 +258,7 @@ static ssize_t wdt977_write(struct file *file, const char *buf, size_t count, lo
static struct watchdog_info ident = {
.options = WDIOF_SETTIMEOUT,
.identity = "Winbond 83977"
.identity = "Winbond 83977",
};
static int wdt977_ioctl(struct inode *inode, struct file *file,
......@@ -268,7 +269,7 @@ static int wdt977_ioctl(struct inode *inode, struct file *file,
switch(cmd)
{
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
return copy_to_user((struct watchdog_info *)arg, &ident,
......@@ -341,7 +342,7 @@ static struct miscdevice wdt977_miscdev=
{
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &wdt977_fops
.fops = &wdt977_fops,
};
static int __init nwwatchdog_init(void)
......
......@@ -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();
......@@ -319,7 +319,7 @@ static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd
switch(cmd)
{
default:
return -ENOTTY;
return -ENOIOCTLCMD;
case WDIOC_GETSUPPORT:
return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))?-EFAULT:0;
......@@ -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