Commit c6cb13ae authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] misc_register patch

Make sure that we first do a register_reboot_notifier before we
do a misc_register. A misc_register opens the interface to
userspace and it's best to do this as the last action.
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 01c785dc
...@@ -413,18 +413,18 @@ static int __init watchdog_init(void) ...@@ -413,18 +413,18 @@ static int __init watchdog_init(void)
/* Calculate the watchdog's timeout */ /* Calculate the watchdog's timeout */
ali_settimer(timeout); ali_settimer(timeout);
ret = misc_register(&ali_miscdev); ret = register_reboot_notifier(&ali_notifier);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
WATCHDOG_MINOR, ret); ret);
goto out; goto out;
} }
ret = register_reboot_notifier(&ali_notifier); ret = misc_register(&ali_miscdev);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
ret); WATCHDOG_MINOR, ret);
goto unreg_miscdev; goto unreg_reboot;
} }
printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n", printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
...@@ -432,8 +432,8 @@ static int __init watchdog_init(void) ...@@ -432,8 +432,8 @@ static int __init watchdog_init(void)
out: out:
return ret; return ret;
unreg_miscdev: unreg_reboot:
misc_deregister(&ali_miscdev); unregister_reboot_notifier(&ali_notifier);
goto out; goto out;
} }
...@@ -449,8 +449,8 @@ static void __exit watchdog_exit(void) ...@@ -449,8 +449,8 @@ static void __exit watchdog_exit(void)
ali_stop(); ali_stop();
/* Deregister */ /* Deregister */
unregister_reboot_notifier(&ali_notifier);
misc_deregister(&ali_miscdev); misc_deregister(&ali_miscdev);
unregister_reboot_notifier(&ali_notifier);
pci_dev_put(ali_pci); pci_dev_put(ali_pci);
} }
......
...@@ -377,18 +377,18 @@ static int __init alim7101_wdt_init(void) ...@@ -377,18 +377,18 @@ static int __init alim7101_wdt_init(void)
timeout); timeout);
} }
rc = misc_register(&wdt_miscdev); rc = register_reboot_notifier(&wdt_notifier);
if (rc) { if (rc) {
printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
wdt_miscdev.minor, rc); rc);
goto err_out; goto err_out;
} }
rc = register_reboot_notifier(&wdt_notifier); rc = misc_register(&wdt_miscdev);
if (rc) { if (rc) {
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
rc); wdt_miscdev.minor, rc);
goto err_out_miscdev; goto err_out_reboot;
} }
if (nowayout) { if (nowayout) {
...@@ -399,8 +399,8 @@ static int __init alim7101_wdt_init(void) ...@@ -399,8 +399,8 @@ static int __init alim7101_wdt_init(void)
timeout, nowayout); timeout, nowayout);
return 0; return 0;
err_out_miscdev: err_out_reboot:
misc_deregister(&wdt_miscdev); unregister_reboot_notifier(&wdt_notifier);
err_out: err_out:
pci_dev_put(alim7101_pmu); pci_dev_put(alim7101_pmu);
return rc; return rc;
......
...@@ -359,20 +359,20 @@ static int __init sbc60xxwdt_init(void) ...@@ -359,20 +359,20 @@ static int __init sbc60xxwdt_init(void)
} }
} }
rc = misc_register(&wdt_miscdev); rc = register_reboot_notifier(&wdt_notifier);
if (rc) if (rc)
{ {
printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
wdt_miscdev.minor, rc); rc);
goto err_out_region2; goto err_out_region2;
} }
rc = register_reboot_notifier(&wdt_notifier); rc = misc_register(&wdt_miscdev);
if (rc) if (rc)
{ {
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
rc); wdt_miscdev.minor, rc);
goto err_out_miscdev; goto err_out_reboot;
} }
printk(KERN_INFO PFX "WDT driver for 60XX single board computer initialised. timeout=%d sec (nowayout=%d)\n", printk(KERN_INFO PFX "WDT driver for 60XX single board computer initialised. timeout=%d sec (nowayout=%d)\n",
...@@ -380,8 +380,8 @@ static int __init sbc60xxwdt_init(void) ...@@ -380,8 +380,8 @@ static int __init sbc60xxwdt_init(void)
return 0; return 0;
err_out_miscdev: err_out_reboot:
misc_deregister(&wdt_miscdev); unregister_reboot_notifier(&wdt_notifier);
err_out_region2: err_out_region2:
if ((wdt_stop != 0x45) && (wdt_stop != wdt_start)) if ((wdt_stop != 0x45) && (wdt_stop != wdt_start))
release_region(wdt_stop,1); release_region(wdt_stop,1);
......
...@@ -231,17 +231,17 @@ static int __init scx200_wdt_init(void) ...@@ -231,17 +231,17 @@ static int __init scx200_wdt_init(void)
sema_init(&open_semaphore, 1); sema_init(&open_semaphore, 1);
r = misc_register(&scx200_wdt_miscdev); r = register_reboot_notifier(&scx200_wdt_notifier);
if (r) { if (r) {
printk(KERN_ERR NAME ": unable to register reboot notifier");
release_region(scx200_cb_base + SCx200_WDT_OFFSET, release_region(scx200_cb_base + SCx200_WDT_OFFSET,
SCx200_WDT_SIZE); SCx200_WDT_SIZE);
return r; return r;
} }
r = register_reboot_notifier(&scx200_wdt_notifier); r = misc_register(&scx200_wdt_miscdev);
if (r) { if (r) {
printk(KERN_ERR NAME ": unable to register reboot notifier"); unregister_reboot_notifier(&scx200_wdt_notifier);
misc_deregister(&scx200_wdt_miscdev);
release_region(scx200_cb_base + SCx200_WDT_OFFSET, release_region(scx200_cb_base + SCx200_WDT_OFFSET,
SCx200_WDT_SIZE); SCx200_WDT_SIZE);
return r; return r;
...@@ -252,8 +252,8 @@ static int __init scx200_wdt_init(void) ...@@ -252,8 +252,8 @@ static int __init scx200_wdt_init(void)
static void __exit scx200_wdt_cleanup(void) static void __exit scx200_wdt_cleanup(void)
{ {
unregister_reboot_notifier(&scx200_wdt_notifier);
misc_deregister(&scx200_wdt_miscdev); misc_deregister(&scx200_wdt_miscdev);
unregister_reboot_notifier(&scx200_wdt_notifier);
release_region(scx200_cb_base + SCx200_WDT_OFFSET, release_region(scx200_cb_base + SCx200_WDT_OFFSET,
SCx200_WDT_SIZE); SCx200_WDT_SIZE);
} }
......
...@@ -373,20 +373,20 @@ static int __init w83877f_wdt_init(void) ...@@ -373,20 +373,20 @@ static int __init w83877f_wdt_init(void)
goto err_out_region1; goto err_out_region1;
} }
rc = misc_register(&wdt_miscdev); rc = register_reboot_notifier(&wdt_notifier);
if (rc) if (rc)
{ {
printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
wdt_miscdev.minor, rc); rc);
goto err_out_region2; goto err_out_region2;
} }
rc = register_reboot_notifier(&wdt_notifier); rc = misc_register(&wdt_miscdev);
if (rc) if (rc)
{ {
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
rc); wdt_miscdev.minor, rc);
goto err_out_miscdev; goto err_out_reboot;
} }
printk(KERN_INFO PFX "WDT driver for W83877F initialised. timeout=%d sec (nowayout=%d)\n", printk(KERN_INFO PFX "WDT driver for W83877F initialised. timeout=%d sec (nowayout=%d)\n",
...@@ -394,8 +394,8 @@ static int __init w83877f_wdt_init(void) ...@@ -394,8 +394,8 @@ static int __init w83877f_wdt_init(void)
return 0; return 0;
err_out_miscdev: err_out_reboot:
misc_deregister(&wdt_miscdev); unregister_reboot_notifier(&wdt_notifier);
err_out_region2: err_out_region2:
release_region(WDT_PING,1); release_region(WDT_PING,1);
err_out_region1: err_out_region1:
......
...@@ -494,20 +494,20 @@ static int __init w83977f_wdt_init(void) ...@@ -494,20 +494,20 @@ static int __init w83977f_wdt_init(void)
goto err_out; goto err_out;
} }
rc = misc_register(&wdt_miscdev); rc = register_reboot_notifier(&wdt_notifier);
if (rc) if (rc)
{ {
printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
wdt_miscdev.minor, rc); rc);
goto err_out_region; goto err_out_region;
} }
rc = register_reboot_notifier(&wdt_notifier); rc = misc_register(&wdt_miscdev);
if (rc) if (rc)
{ {
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
rc); wdt_miscdev.minor, rc);
goto err_out_miscdev; goto err_out_reboot;
} }
printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n", printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n",
...@@ -515,8 +515,8 @@ static int __init w83977f_wdt_init(void) ...@@ -515,8 +515,8 @@ static int __init w83977f_wdt_init(void)
return 0; return 0;
err_out_miscdev: err_out_reboot:
misc_deregister(&wdt_miscdev); unregister_reboot_notifier(&wdt_notifier);
err_out_region: err_out_region:
release_region(IO_INDEX_PORT,2); release_region(IO_INDEX_PORT,2);
err_out: err_out:
......
...@@ -470,20 +470,20 @@ static int __init wd977_init(void) ...@@ -470,20 +470,20 @@ static int __init wd977_init(void)
} }
} }
rc = misc_register(&wdt977_miscdev); rc = register_reboot_notifier(&wdt977_notifier);
if (rc) if (rc)
{ {
printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
wdt977_miscdev.minor, rc); rc);
goto err_out_region; goto err_out_region;
} }
rc = register_reboot_notifier(&wdt977_notifier); rc = misc_register(&wdt977_miscdev);
if (rc) if (rc)
{ {
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
rc); wdt977_miscdev.minor, rc);
goto err_out_miscdev; goto err_out_reboot;
} }
printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d, testmode=%i)\n", printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d, testmode=%i)\n",
...@@ -491,8 +491,8 @@ static int __init wd977_init(void) ...@@ -491,8 +491,8 @@ static int __init wd977_init(void)
return 0; return 0;
err_out_miscdev: err_out_reboot:
misc_deregister(&wdt977_miscdev); unregister_reboot_notifier(&wdt977_notifier);
err_out_region: err_out_region:
if (!machine_is_netwinder()) if (!machine_is_netwinder())
release_region(IO_INDEX_PORT,2); release_region(IO_INDEX_PORT,2);
......
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