Re: [PATCH] add watchdog driver IT8716 IT8718 IT8726 IT8712J/K

From: Wim Van Sebroeck
Date: Thu Sep 18 2008 - 05:08:28 EST


Hi Oliver,

> But first: Add support for it8718, which made the driver slightly more
> complex.
> Now the driver supports it8716, it8718, it8726, it8712-j and it8712-k,
> which are all 16-bit watchdog timer on ITE lpc-super-io-chips.

I added it into my linux-2.6-watchdog-mm tree. I noticed that the initialization
sequence should be done differenly (the misc_device should be registered last
because that opens up userspace to your driver).

Could you therefor test my patch and 2 check if the "misc_register(&wdt_miscdev);"
can be moved after the "/* Initialize CIR to use it as keepalive source */" part
(just before the printk(...)?

Thanks in advance,
Wim.

-------------------------------------------------------------------------------------
commit b8a047e5a678357ef2bc8c79ce539957579965dd
Author: Wim Van Sebroeck <wim@xxxxxxxxx>
Date: Thu Sep 18 08:58:27 2008 +0000

[WATCHDOG] it87_wdt.c - fix initialization sequence

register_miscdevice gives userspace access to the device (via /dev/watchdog).
It should therfore be done after the setting og the default value for the timeout
and after the reboot_notifier registration.

Signed-off-by: Wim Van Sebroeck <wim@xxxxxxxxx>

diff --git a/drivers/watchdog/it87_wdt.c b/drivers/watchdog/it87_wdt.c
index cbf5e83..5cd8473 100644
--- a/drivers/watchdog/it87_wdt.c
+++ b/drivers/watchdog/it87_wdt.c
@@ -625,26 +625,26 @@ static int __init it87_wdt_init(void)
spin_unlock_irqrestore(&spinlock, flags);
}

- rc = misc_register(&wdt_miscdev);
- if (rc) {
- printk(KERN_ERR PFX
- "Cannot register miscdev on minor=%d (err=%d)\n",
- wdt_miscdev.minor, rc);
- goto err_out_region;
+ if (timeout < 1 || timeout > 65535) {
+ timeout = DEFAULT_TIMEOUT;
+ printk(KERN_WARNING PFX
+ "Timeout value out of range, use default %d sec\n",
+ DEFAULT_TIMEOUT);
}

rc = register_reboot_notifier(&wdt_notifier);
if (rc) {
printk(KERN_ERR PFX
"Cannot register reboot notifier (err=%d)\n", rc);
- goto err_out_miscdev;
+ goto err_out_region;
}

- if (timeout < 1 || timeout > 65535) {
- timeout = DEFAULT_TIMEOUT;
- printk(KERN_WARNING PFX
- "Timeout value out of range, use default %d sec\n",
- DEFAULT_TIMEOUT);
+ rc = misc_register(&wdt_miscdev);
+ if (rc) {
+ printk(KERN_ERR PFX
+ "Cannot register miscdev on minor=%d (err=%d)\n",
+ wdt_miscdev.minor, rc);
+ goto err_out_reboot;
}

/* Initialize CIR to use it as keepalive source */
@@ -665,8 +665,8 @@ static int __init it87_wdt_init(void)

return 0;

-err_out_miscdev:
- misc_deregister(&wdt_miscdev);
+err_out_reboot:
+ unregister_reboot_notifier(&wdt_notifier);
err_out_region:
release_region(base, test_bit(WDTS_USE_GP, &wdt_status) ? 1 : 8);
if (!test_bit(WDTS_USE_GP, &wdt_status)) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/