Commit 8c30fef8 authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] 2.6.0-rc1 _is_open.patch

Make _is_open code consistent for all watchdog-drivers
parent a74c51c3
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/system.h> #include <asm/system.h>
static int ibwdt_is_open; static unsigned long ibwdt_is_open;
static spinlock_t ibwdt_lock; static spinlock_t ibwdt_lock;
static char expect_close; static char expect_close;
...@@ -184,9 +184,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -184,9 +184,7 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break; break;
case WDIOC_GETSTATUS: case WDIOC_GETSTATUS:
if (copy_to_user((int *)arg, &ibwdt_is_open, sizeof(int))) return put_user(0, (int *) arg);
return -EFAULT;
break;
case WDIOC_KEEPALIVE: case WDIOC_KEEPALIVE:
ibwdt_ping(); ibwdt_ping();
...@@ -218,7 +216,7 @@ static int ...@@ -218,7 +216,7 @@ static int
ibwdt_open(struct inode *inode, struct file *file) ibwdt_open(struct inode *inode, struct file *file)
{ {
spin_lock(&ibwdt_lock); spin_lock(&ibwdt_lock);
if (ibwdt_is_open) { if (test_and_set_bit(0, &ibwdt_is_open)) {
spin_unlock(&ibwdt_lock); spin_unlock(&ibwdt_lock);
return -EBUSY; return -EBUSY;
} }
...@@ -226,7 +224,6 @@ ibwdt_open(struct inode *inode, struct file *file) ...@@ -226,7 +224,6 @@ ibwdt_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
/* Activate */ /* Activate */
ibwdt_is_open = 1;
ibwdt_ping(); ibwdt_ping();
spin_unlock(&ibwdt_lock); spin_unlock(&ibwdt_lock);
return 0; return 0;
...@@ -241,7 +238,7 @@ ibwdt_close(struct inode *inode, struct file *file) ...@@ -241,7 +238,7 @@ ibwdt_close(struct inode *inode, struct file *file)
else else
printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); 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; expect_close = 0;
spin_unlock(&ibwdt_lock); spin_unlock(&ibwdt_lock);
return 0; return 0;
......
...@@ -130,7 +130,7 @@ module_param(action, int, 0); ...@@ -130,7 +130,7 @@ module_param(action, int, 0);
MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*) 1 = SMI 2 = NMI 3 = SCI"); 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_action = GEN_RESET;
static int zf_is_open = 0; static unsigned long zf_is_open;
static char zf_expect_close; static char zf_expect_close;
static spinlock_t zf_lock; static spinlock_t zf_lock;
static spinlock_t zf_port_lock; static spinlock_t zf_port_lock;
...@@ -359,9 +359,7 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -359,9 +359,7 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break; break;
case WDIOC_GETSTATUS: case WDIOC_GETSTATUS:
if (copy_to_user((int *)arg, &zf_is_open, sizeof(int))) return put_user(0, (int *) arg);
return -EFAULT;
break;
case WDIOC_KEEPALIVE: case WDIOC_KEEPALIVE:
zf_ping(0); zf_ping(0);
...@@ -377,7 +375,7 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -377,7 +375,7 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
static int zf_open(struct inode *inode, struct file *file) static int zf_open(struct inode *inode, struct file *file)
{ {
spin_lock(&zf_lock); spin_lock(&zf_lock);
if(zf_is_open){ if(test_and_set_bit(0, &zf_is_open)) {
spin_unlock(&zf_lock); spin_unlock(&zf_lock);
return -EBUSY; return -EBUSY;
} }
...@@ -385,8 +383,6 @@ static int zf_open(struct inode *inode, struct file *file) ...@@ -385,8 +383,6 @@ static int zf_open(struct inode *inode, struct file *file)
if (nowayout) if (nowayout)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
zf_is_open = 1;
spin_unlock(&zf_lock); spin_unlock(&zf_lock);
zf_timer_on(); zf_timer_on();
...@@ -404,7 +400,7 @@ static int zf_close(struct inode *inode, struct file *file) ...@@ -404,7 +400,7 @@ static int zf_close(struct inode *inode, struct file *file)
} }
spin_lock(&zf_lock); spin_lock(&zf_lock);
zf_is_open = 0; clear_bit(0, &zf_is_open);
spin_unlock(&zf_lock); spin_unlock(&zf_lock);
zf_expect_close = 0; zf_expect_close = 0;
......
...@@ -55,7 +55,7 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 }; ...@@ -55,7 +55,7 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 };
#define FLASHCOM_WATCHDOG_OFFSET 0x4 #define FLASHCOM_WATCHDOG_OFFSET 0x4
#define FLASHCOM_ID 0x18 #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 watchdog_port;
static int mixcomwd_timer_alive; static int mixcomwd_timer_alive;
......
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