Commit 35cc1fac authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] 2.6.0-rc1 - iminor(inode).patch

get rid of unnecessary iminor(inode) code in watchdog's open and close functions.
parent f73e9f0f
...@@ -134,23 +134,15 @@ static int cpu5wdt_stop(void) ...@@ -134,23 +134,15 @@ static int cpu5wdt_stop(void)
static int cpu5wdt_open(struct inode *inode, struct file *file) static int cpu5wdt_open(struct inode *inode, struct file *file)
{ {
switch(iminor(inode)) { if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
case WATCHDOG_MINOR: return -EBUSY;
if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
return -EBUSY;
break;
default:
return -ENODEV;
}
return 0; return 0;
} }
static int cpu5wdt_release(struct inode *inode, struct file *file) static int cpu5wdt_release(struct inode *inode, struct file *file)
{ {
if(iminor(inode)==WATCHDOG_MINOR) { clear_bit(0, &cpu5wdt_device.inuse);
clear_bit(0, &cpu5wdt_device.inuse);
}
return 0; return 0;
} }
......
...@@ -217,38 +217,32 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -217,38 +217,32 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
static int static int
ibwdt_open(struct inode *inode, struct file *file) ibwdt_open(struct inode *inode, struct file *file)
{ {
if (iminor(inode) == WATCHDOG_MINOR) { spin_lock(&ibwdt_lock);
spin_lock(&ibwdt_lock); if (ibwdt_is_open) {
if (ibwdt_is_open) {
spin_unlock(&ibwdt_lock);
return -EBUSY;
}
if (nowayout)
__module_get(THIS_MODULE);
/* Activate */
ibwdt_is_open = 1;
ibwdt_ping();
spin_unlock(&ibwdt_lock); spin_unlock(&ibwdt_lock);
return 0; return -EBUSY;
} else {
return -ENODEV;
} }
if (nowayout)
__module_get(THIS_MODULE);
/* Activate */
ibwdt_is_open = 1;
ibwdt_ping();
spin_unlock(&ibwdt_lock);
return 0;
} }
static int static int
ibwdt_close(struct inode *inode, struct file *file) ibwdt_close(struct inode *inode, struct file *file)
{ {
if (iminor(inode) == WATCHDOG_MINOR) { spin_lock(&ibwdt_lock);
spin_lock(&ibwdt_lock); if (expect_close)
if (expect_close) outb_p(wd_times[wd_margin], WDT_STOP);
outb_p(wd_times[wd_margin], WDT_STOP); 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;
ibwdt_is_open = 0; spin_unlock(&ibwdt_lock);
spin_unlock(&ibwdt_lock);
}
return 0; return 0;
} }
......
...@@ -376,46 +376,38 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -376,46 +376,38 @@ 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)
{ {
switch(iminor(inode)){ spin_lock(&zf_lock);
case WATCHDOG_MINOR: if(zf_is_open){
spin_lock(&zf_lock); spin_unlock(&zf_lock);
if(zf_is_open){ return -EBUSY;
spin_unlock(&zf_lock); }
return -EBUSY;
}
if (nowayout) if (nowayout)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
zf_is_open = 1; zf_is_open = 1;
spin_unlock(&zf_lock); spin_unlock(&zf_lock);
zf_timer_on(); zf_timer_on();
return 0; return 0;
default:
return -ENODEV;
}
} }
static int zf_close(struct inode *inode, struct file *file) static int zf_close(struct inode *inode, struct file *file)
{ {
if(iminor(inode) == WATCHDOG_MINOR){ if(zf_expect_close){
zf_timer_off();
if(zf_expect_close){ } else {
zf_timer_off(); del_timer(&zf_timer);
} else { printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n");
del_timer(&zf_timer); }
printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n");
}
spin_lock(&zf_lock); spin_lock(&zf_lock);
zf_is_open = 0; zf_is_open = 0;
spin_unlock(&zf_lock); spin_unlock(&zf_lock);
zf_expect_close = 0; zf_expect_close = 0;
}
return 0; 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