2.1.55 patch for Berkshire Products WDT

Richard Gooch (rgooch@atnf.CSIRO.AU)
Sat, 13 Sep 1997 10:01:31 +1000


Hi, Linus. Can you please apply the following patch to 2.1.55? It
does similar fixups to the driver for the Berkshire Products watchdog
timer as did my patch for 2.0.30 which you applied. This one is even
better because it actually obeys CONFIG_WATCHDOG_NOWAYOUT.

Without this patch the watchdog has a nasty tendancy to do a delayed
reboot after you've started a reboot cycle: not fun when the kernel is
just starting to boot...

Regards,

Richard....

diff -urN linux-2.1.55/drivers/char/pcwd.c linux/drivers/char/pcwd.c
--- linux-2.1.55/drivers/char/pcwd.c Thu Apr 24 12:01:17 1997
+++ linux/drivers/char/pcwd.c Fri Sep 12 18:22:41 1997
@@ -28,6 +28,7 @@
* drivers to panic the system if it's overheating at bootup.
* 961118 Changed some verbiage on some of the output, tidied up
* code bits, and added compatibility to 2.1.x.
+ * 970912 Enabled board on open and disable on close.
*/

#include <linux/module.h>
@@ -209,9 +210,6 @@
{
int wdrst_stat;

- if (!is_open)
- return;
-
wdrst_stat = inb_p(current_readport);
wdrst_stat &= 0x0F;

@@ -235,6 +233,8 @@
"PCWD."
};

+ if (!is_open)
+ return -EIO;
switch(cmd) {
default:
return -ENOIOCTLCMD;
@@ -363,6 +363,8 @@

static long pcwd_write(struct inode *inode, struct file *file, const char *buf, unsigned long len)
{
+ if (!is_open)
+ return -EIO;
if (len)
{
pcwd_send_heartbeat();
@@ -373,7 +375,13 @@

static int pcwd_open(struct inode *ino, struct file *filep)
{
+ if (is_open)
+ return -EIO;
MOD_INC_USE_COUNT;
+ /* Enable the port */
+ if (revision == PCWD_REVISION_C)
+ outb_p(0x00, current_readport + 3);
+ is_open = 1;
return(0);
}

@@ -383,6 +391,8 @@
unsigned short c = inb(current_readport);
unsigned char cp;

+ if (!is_open)
+ return -EIO;
switch(MINOR(inode->i_rdev))
{
case TEMP_MINOR:
@@ -397,7 +407,15 @@

static int pcwd_close(struct inode *ino, struct file *filep)
{
+ is_open = 0;
MOD_DEC_USE_COUNT;
+#ifndef CONFIG_WATCHDOG_NOWAYOUT
+ /* Disable the board */
+ if (revision == PCWD_REVISION_C) {
+ outb_p(0xA5, current_readport + 3);
+ outb_p(0xA5, current_readport + 3);
+ }
+#endif
return 0;
}

@@ -531,8 +549,6 @@
}
#endif

- is_open = 1;
-
#ifdef PCWD_BLIND
current_readport = PCWD_BLIND;
#endif
@@ -571,6 +587,11 @@
#ifdef MODULE
void cleanup_module(void)
{
+ /* Disable the board */
+ if (revision == PCWD_REVISION_C) {
+ outb_p(0xA5, current_readport + 3);
+ outb_p(0xA5, current_readport + 3);
+ }
misc_deregister(&pcwd_miscdev);
if (supports_temp)
misc_deregister(&temp_miscdev);