summaryrefslogtreecommitdiffstats
path: root/drivers/char/wdt.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-10-05 01:18:40 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-10-05 01:18:40 +0000
commit012bb3e61e5eced6c610f9e036372bf0c8def2d1 (patch)
tree87efc733f9b164e8c85c0336f92c8fb7eff6d183 /drivers/char/wdt.c
parent625a1589d3d6464b5d90b8a0918789e3afffd220 (diff)
Merge with Linux 2.4.0-test9. Please check DECstation, I had a number
of rejects to fixup while integrating Linus patches. I also found that this kernel will only boot SMP on Origin; the UP kernel freeze soon after bootup with SCSI timeout messages. I commit this anyway since I found that the last CVS versions had the same problem.
Diffstat (limited to 'drivers/char/wdt.c')
-rw-r--r--drivers/char/wdt.c75
1 files changed, 54 insertions, 21 deletions
diff --git a/drivers/char/wdt.c b/drivers/char/wdt.c
index e55d94fe3..9600a5b17 100644
--- a/drivers/char/wdt.c
+++ b/drivers/char/wdt.c
@@ -26,6 +26,7 @@
* Alan Cox : Cleaned up copy/user stuff
* Tim Hockin : Added insmod parameters, comment cleanup
* Parameterized timeout
+ * Tigran Aivazian : Restructured wdt_init() to handle failures
*/
#include <linux/config.h>
@@ -49,7 +50,7 @@
#include <linux/reboot.h>
#include <linux/init.h>
-static int wdt_is_open=0;
+static int wdt_is_open;
/*
* You must set these - there is no sane way to probe for this board.
@@ -458,10 +459,6 @@ static struct notifier_block wdt_notifier=
0
};
-#ifdef MODULE
-
-#define wdt_init init_module
-
/**
* cleanup_module:
*
@@ -472,7 +469,7 @@ static struct notifier_block wdt_notifier=
* module in 60 seconds or reboot.
*/
-void cleanup_module(void)
+static void __exit wdt_exit(void)
{
misc_deregister(&wdt_miscdev);
#ifdef CONFIG_WDT_501
@@ -483,8 +480,6 @@ void cleanup_module(void)
free_irq(irq, NULL);
}
-#endif
-
/**
* wdt_init:
*
@@ -493,20 +488,58 @@ void cleanup_module(void)
* The open() function will actually kick the board off.
*/
-int __init wdt_init(void)
+static int __init wdt_init(void)
{
- printk(KERN_INFO "WDT500/501-P driver 0.07 at %X (Interrupt %d)\n", io,irq);
- if(request_irq(irq, wdt_interrupt, SA_INTERRUPT, "wdt501p", &wdt_miscdev))
- {
- printk(KERN_ERR "IRQ %d is not free.\n", irq);
- return -EIO;
+ int ret;
+
+ ret = misc_register(&wdt_miscdev);
+ if (ret) {
+ printk(KERN_ERR "wdt: can't misc_register on minor=%d\n", WATCHDOG_MINOR);
+ goto out;
}
- misc_register(&wdt_miscdev);
-#ifdef CONFIG_WDT_501
- misc_register(&temp_miscdev);
-#endif
- request_region(io, 8, "wdt501p");
- register_reboot_notifier(&wdt_notifier);
- return 0;
+ ret = request_irq(irq, wdt_interrupt, SA_INTERRUPT, "wdt501p", NULL);
+ if(ret) {
+ printk(KERN_ERR "wdt: IRQ %d is not free.\n", irq);
+ goto outmisc;
+ }
+ if (!request_region(io, 8, "wdt501p")) {
+ printk(KERN_ERR "wdt: IO %X is not free.\n", io);
+ ret = -EBUSY;
+ goto outirq;
+ }
+ ret = register_reboot_notifier(&wdt_notifier);
+ if(ret) {
+ printk(KERN_ERR "wdt: can't register reboot notifier (err=%d)\n", ret);
+ goto outreg;
+ }
+
+#ifdef CONFIG_WDT_501
+ ret = misc_register(&temp_miscdev);
+ if (ret) {
+ printk(KERN_ERR "wdt: can't misc_register (temp) on minor=%d\n", TEMP_MINOR);
+ goto outrbt;
+ }
+#endif
+
+ ret = 0;
+ printk(KERN_INFO "WDT500/501-P driver 0.07 at %X (Interrupt %d)\n", io, irq);
+out:
+ return ret;
+
+#ifdef CONFIG_WDT_501
+outrbt:
+ unregister_reboot_notifier(&wdt_notifier);
+#endif
+
+outreg:
+ release_region(io,8);
+outirq:
+ free_irq(irq, NULL);
+outmisc:
+ misc_deregister(&wdt_miscdev);
+ goto out;
}
+module_init(wdt_init);
+module_exit(wdt_exit);
+