Commit 469957af authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] w83877f_wdt patch

cleanup comments and trailing spaces
eliminate extra spin_unlock
add KERN_* tags to printks
added extra printk's to report what problem occured
parent b0e7cd75
/* /*
* W83877F Computer Watchdog Timer driver for Linux 2.4.x * W83877F Computer Watchdog Timer driver
* *
* Based on acquirewdt.c by Alan Cox, * Based on acquirewdt.c by Alan Cox,
* and sbc60xxwdt.c by Jakob Oestergaard <jakob@ostenfeld.dk> * and sbc60xxwdt.c by Jakob Oestergaard <jakob@unthought.net>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -17,22 +17,12 @@ ...@@ -17,22 +17,12 @@
* *
* 4/19 - 2001 [Initial revision] * 4/19 - 2001 [Initial revision]
* 9/27 - 2001 Added spinlocking * 9/27 - 2001 Added spinlocking
* * 4/12 - 2002 [rob@osinvestor.com] Eliminate extra comments
* * Eliminate fop_read
* Theory of operation: * Eliminate extra spin_unlock
* A Watchdog Timer (WDT) is a hardware circuit that can * Added KERN_* tags to printks
* reset the computer system in case of a software fault. * 09/8 - 2003 [wim@iguana.be] cleanup of trailing spaces
* You probably knew that already. * added extra printk's for startup problems
*
* Usually a userspace daemon will notify the kernel WDT driver
* via the /proc/watchdog special device file that userspace is
* still alive, at regular intervals. When such a notification
* occurs, the driver will usually tell the hardware watchdog
* that everything is in order, and that the watchdog should wait
* for yet another little while to reset the system.
* If userspace fails (RAM error, kernel bug, whatever), the
* notifications cease to occur, and the hardware watchdog will
* reset the system (causing a reboot) after the timeout occurs.
* *
* This WDT driver is different from most other Linux WDT * This WDT driver is different from most other Linux WDT
* drivers in that the driver will ping the watchdog by itself, * drivers in that the driver will ping the watchdog by itself,
...@@ -42,6 +32,7 @@ ...@@ -42,6 +32,7 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
...@@ -57,6 +48,7 @@ ...@@ -57,6 +48,7 @@
#include <asm/system.h> #include <asm/system.h>
#define OUR_NAME "w83877f_wdt" #define OUR_NAME "w83877f_wdt"
#define PFX OUR_NAME ": "
#define ENABLE_W83877F_PORT 0x3F0 #define ENABLE_W83877F_PORT 0x3F0
#define ENABLE_W83877F 0x87 #define ENABLE_W83877F 0x87
...@@ -112,7 +104,7 @@ static void wdt_timer_ping(unsigned long data) ...@@ -112,7 +104,7 @@ static void wdt_timer_ping(unsigned long data)
spin_unlock(&wdt_spinlock); spin_unlock(&wdt_spinlock);
} else { } else {
printk(OUR_NAME ": Heartbeat lost! Will not ping the watchdog\n"); printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n");
} }
} }
...@@ -152,7 +144,7 @@ static void wdt_startup(void) ...@@ -152,7 +144,7 @@ static void wdt_startup(void)
wdt_change(WDT_ENABLE); wdt_change(WDT_ENABLE);
printk(OUR_NAME ": Watchdog timer is now enabled.\n"); printk(KERN_INFO PFX "Watchdog timer is now enabled.\n");
} }
static void wdt_turnoff(void) static void wdt_turnoff(void)
...@@ -162,7 +154,7 @@ static void wdt_turnoff(void) ...@@ -162,7 +154,7 @@ static void wdt_turnoff(void)
wdt_change(WDT_DISABLE); wdt_change(WDT_DISABLE);
printk(OUR_NAME ": Watchdog timer is now disabled...\n"); printk(KERN_INFO PFX "Watchdog timer is now disabled...\n");
} }
...@@ -209,8 +201,6 @@ static int fop_open(struct inode * inode, struct file * file) ...@@ -209,8 +201,6 @@ static int fop_open(struct inode * inode, struct file * file)
case WATCHDOG_MINOR: case WATCHDOG_MINOR:
/* Just in case we're already talking to someone... */ /* Just in case we're already talking to someone... */
if(test_and_set_bit(0, &wdt_is_open)) { if(test_and_set_bit(0, &wdt_is_open)) {
/* Davej: Is this unlock bogus? */
spin_unlock(&wdt_spinlock);
return -EBUSY; return -EBUSY;
} }
/* Good, fire up the show */ /* Good, fire up the show */
...@@ -230,7 +220,7 @@ static int fop_close(struct inode * inode, struct file * file) ...@@ -230,7 +220,7 @@ static int fop_close(struct inode * inode, struct file * file)
wdt_turnoff(); wdt_turnoff();
else { else {
del_timer(&timer); del_timer(&timer);
printk(OUR_NAME ": device file closed unexpectedly. Will not stop the WDT!\n"); printk(KERN_CRIT PFX "device file closed unexpectedly. Will not stop the WDT!\n");
} }
} }
clear_bit(0, &wdt_is_open); clear_bit(0, &wdt_is_open);
...@@ -244,7 +234,7 @@ static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -244,7 +234,7 @@ static int fop_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
{ {
.options = WDIOF_MAGICCLOSE, .options = WDIOF_MAGICCLOSE,
.firmware_version = 1, .firmware_version = 1,
.identity = "W83877F" .identity = "W83877F",
}; };
switch(cmd) switch(cmd)
...@@ -265,13 +255,13 @@ static struct file_operations wdt_fops = { ...@@ -265,13 +255,13 @@ static struct file_operations wdt_fops = {
.write = fop_write, .write = fop_write,
.open = fop_open, .open = fop_open,
.release = fop_close, .release = fop_close,
.ioctl = fop_ioctl .ioctl = fop_ioctl,
}; };
static struct miscdevice wdt_miscdev = { static struct miscdevice wdt_miscdev = {
.minor = WATCHDOG_MINOR, .minor = WATCHDOG_MINOR,
.name = "watchdog", .name = "watchdog",
.fops = &wdt_fops .fops = &wdt_fops,
}; };
/* /*
...@@ -295,7 +285,7 @@ static struct notifier_block wdt_notifier= ...@@ -295,7 +285,7 @@ static struct notifier_block wdt_notifier=
{ {
.notifier_call = wdt_notify_sys, .notifier_call = wdt_notify_sys,
.next = NULL, .next = NULL,
.priority = 0 .priority = 0,
}; };
static void __exit w83877f_wdt_unload(void) static void __exit w83877f_wdt_unload(void)
...@@ -317,9 +307,20 @@ static int __init w83877f_wdt_init(void) ...@@ -317,9 +307,20 @@ static int __init w83877f_wdt_init(void)
spin_lock_init(&wdt_spinlock); spin_lock_init(&wdt_spinlock);
if (!request_region(ENABLE_W83877F_PORT, 2, "W83877F WDT")) if (!request_region(ENABLE_W83877F_PORT, 2, "W83877F WDT"))
{
printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",
ENABLE_W83877F_PORT);
rc = -EIO;
goto err_out; goto err_out;
}
if (!request_region(WDT_PING, 1, "W8387FF WDT")) if (!request_region(WDT_PING, 1, "W8387FF WDT"))
{
printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",
WDT_PING);
rc = -EIO;
goto err_out_region1; goto err_out_region1;
}
init_timer(&timer); init_timer(&timer);
timer.function = wdt_timer_ping; timer.function = wdt_timer_ping;
...@@ -327,13 +328,21 @@ static int __init w83877f_wdt_init(void) ...@@ -327,13 +328,21 @@ static int __init w83877f_wdt_init(void)
rc = misc_register(&wdt_miscdev); rc = misc_register(&wdt_miscdev);
if (rc) if (rc)
{
printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
wdt_miscdev.minor, rc);
goto err_out_region2; goto err_out_region2;
}
rc = register_reboot_notifier(&wdt_notifier); rc = register_reboot_notifier(&wdt_notifier);
if (rc) if (rc)
{
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
rc);
goto err_out_miscdev; goto err_out_miscdev;
}
printk(KERN_INFO OUR_NAME ": WDT driver for W83877F initialised.\n"); printk(KERN_INFO PFX "WDT driver for W83877F initialised.\n");
return 0; return 0;
......
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