Commit 4e71c0ea authored by Dave Jones's avatar Dave Jones

[WATCHDOG] return code checking and various cleanups for ib700wdt.

partly based on a patch from Tariq Shureih to the kernel janitors list.
parent 924175cd
...@@ -50,6 +50,8 @@ static int ibwdt_is_open; ...@@ -50,6 +50,8 @@ static int ibwdt_is_open;
static spinlock_t ibwdt_lock; static spinlock_t ibwdt_lock;
static int expect_close = 0; static int expect_close = 0;
#define PFX "ib700wdt: "
/* /*
* *
* Watchdog Timer Configuration * Watchdog Timer Configuration
...@@ -245,7 +247,7 @@ ibwdt_close(struct inode *inode, struct file *file) ...@@ -245,7 +247,7 @@ ibwdt_close(struct inode *inode, struct file *file)
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 "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);
...@@ -298,29 +300,49 @@ static struct notifier_block ibwdt_notifier = { ...@@ -298,29 +300,49 @@ static struct notifier_block ibwdt_notifier = {
.priority = 0 .priority = 0
}; };
static int __init static int __init ibwdt_init(void)
ibwdt_init(void)
{ {
printk("WDT driver for IB700 single board computer initialising.\n"); int res;
printk(KERN_INFO PFX "WDT driver for IB700 single board computer initialising.\n");
spin_lock_init(&ibwdt_lock); spin_lock_init(&ibwdt_lock);
if (misc_register(&ibwdt_miscdev)) res = misc_register(&ibwdt_miscdev);
return -ENODEV; if (res) {
printk (KERN_ERR PFX "failed to register misc device\n");
goto out_nomisc;
}
#if WDT_START != WDT_STOP #if WDT_START != WDT_STOP
if (!request_region(WDT_STOP, 1, "IB700 WDT")) { if (!request_region(WDT_STOP, 1, "IB700 WDT")) {
misc_deregister(&ibwdt_miscdev); printk (KERN_ERR PFX "STOP method I/O %X is not available.\n", WDT_STOP);
return -EIO; res = -EIO;
goto out_nostopreg;
} }
#endif #endif
if (!request_region(WDT_START, 1, "IB700 WDT")) { if (!request_region(WDT_START, 1, "IB700 WDT")) {
#if WDT_START != WDT_STOP printk (KERN_ERR PFX "START method I/O %X is not available.\n", WDT_START);
release_region(WDT_STOP, 1); res = -EIO;
#endif goto out_nostartreg;
misc_deregister(&ibwdt_miscdev); }
return -EIO; res = register_reboot_notifier(&ibwdt_notifier);
if (res) {
printk (KERN_ERR PFX "Failed to register reboot notifier.\n");
goto out_noreboot;
} }
register_reboot_notifier(&ibwdt_notifier);
return 0; return 0;
out_noreboot:
release_region(WDT_START, 1);
out_nostartreg:
#if WDT_START != WDT_STOP
release_region(WDT_STOP, 1);
#endif
out_nostopreg:
misc_deregister(&ibwdt_miscdev);
out_nomisc:
return res;
} }
static void __exit static void __exit
......
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