Commit 6a670cdd authored by Dave Jones's avatar Dave Jones Committed by Dave Jones

[WATCHDOG] simplify advwdt_open, and add C99 struct initialisers

parent 97cb93ec
...@@ -157,26 +157,23 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -157,26 +157,23 @@ advwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
static int static int
advwdt_open(struct inode *inode, struct file *file) advwdt_open(struct inode *inode, struct file *file)
{ {
switch (minor(inode->i_rdev)) { if (minor(inode->i_rdev) = WATCHDOG_MINOR) {
case WATCHDOG_MINOR: spin_lock(&advwdt_lock);
spin_lock(&advwdt_lock); if (advwdt_is_open) {
if (advwdt_is_open) {
spin_unlock(&advwdt_lock);
return -EBUSY;
}
if (nowayout) {
MOD_INC_USE_COUNT;
}
/*
* Activate
*/
advwdt_is_open = 1;
advwdt_ping();
spin_unlock(&advwdt_lock); spin_unlock(&advwdt_lock);
return 0; return -EBUSY;
default: }
return -ENODEV;
if (nowayout)
MOD_INC_USE_COUNT;
/* Activate */
advwdt_is_open = 1;
advwdt_ping();
spin_unlock(&advwdt_lock);
return 0;
} else {
return -ENODEV;
} }
} }
...@@ -185,9 +182,9 @@ advwdt_close(struct inode *inode, struct file *file) ...@@ -185,9 +182,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);
if (!nowayout) { if (!nowayout)
inb_p(WDT_STOP); inb_p(WDT_STOP);
}
advwdt_is_open = 0; advwdt_is_open = 0;
spin_unlock(&advwdt_lock); spin_unlock(&advwdt_lock);
} }
...@@ -202,10 +199,10 @@ static int ...@@ -202,10 +199,10 @@ static int
advwdt_notify_sys(struct notifier_block *this, unsigned long code, advwdt_notify_sys(struct notifier_block *this, unsigned long code,
void *unused) void *unused)
{ {
if (code == SYS_DOWN || code == SYS_HALT) { if (code == SYS_DOWN || code == SYS_HALT)
/* Turn the WDT off */ /* Turn the WDT off */
inb_p(WDT_STOP); inb_p(WDT_STOP);
}
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -223,9 +220,9 @@ static struct file_operations advwdt_fops = { ...@@ -223,9 +220,9 @@ static struct file_operations advwdt_fops = {
}; };
static struct miscdevice advwdt_miscdev = { static struct miscdevice advwdt_miscdev = {
WATCHDOG_MINOR, .minor = WATCHDOG_MINOR,
"watchdog", .name = "watchdog",
&advwdt_fops .fops = &advwdt_fops
}; };
/* /*
...@@ -234,9 +231,9 @@ static struct miscdevice advwdt_miscdev = { ...@@ -234,9 +231,9 @@ static struct miscdevice advwdt_miscdev = {
*/ */
static struct notifier_block advwdt_notifier = { static struct notifier_block advwdt_notifier = {
advwdt_notify_sys, .self = advwdt_notify_sys,
NULL, .next = NULL,
0 .priority = 0
}; };
static void __init static void __init
...@@ -290,5 +287,3 @@ module_exit(advwdt_exit); ...@@ -290,5 +287,3 @@ module_exit(advwdt_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
/* end of advantechwdt.c */
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