aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-03-28 16:29:51 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-03-28 16:29:51 -0400
commited40d0c472b136682b2fcba05f89762859c7374f (patch)
tree076b83a26bcd63d6158463735dd34c10bbc591dc /drivers/watchdog
parent9e495834e59ca9b29f1a1f63b9f5533bb022ac49 (diff)
parent5d80f8e5a9dc9c9a94d4aeaa567e219a808b8a4a (diff)
Merge branch 'origin' into devel
Conflicts: sound/soc/pxa/pxa2xx-i2s.c
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/Kconfig15
-rw-r--r--drivers/watchdog/acquirewdt.c8
-rw-r--r--drivers/watchdog/advantechwdt.c7
-rw-r--r--drivers/watchdog/alim1535_wdt.c20
-rw-r--r--drivers/watchdog/alim7101_wdt.c6
-rw-r--r--drivers/watchdog/at91sam9_wdt.c2
-rw-r--r--drivers/watchdog/cpwd.c101
-rw-r--r--drivers/watchdog/davinci_wdt.c45
-rw-r--r--drivers/watchdog/eurotechwdt.c22
-rw-r--r--drivers/watchdog/geodewdt.c11
-rw-r--r--drivers/watchdog/hpwdt.c20
-rw-r--r--drivers/watchdog/i6300esb.c101
-rw-r--r--drivers/watchdog/iTCO_vendor_support.c6
-rw-r--r--drivers/watchdog/iTCO_wdt.c15
-rw-r--r--drivers/watchdog/it87_wdt.c12
-rw-r--r--drivers/watchdog/mpc5200_wdt.c4
-rw-r--r--drivers/watchdog/mpcore_wdt.c2
-rw-r--r--drivers/watchdog/mtx-1_wdt.c2
-rw-r--r--drivers/watchdog/orion5x_wdt.c76
-rw-r--r--drivers/watchdog/pc87413_wdt.c6
-rw-r--r--drivers/watchdog/pcwd.c44
-rw-r--r--drivers/watchdog/pcwd_pci.c108
-rw-r--r--drivers/watchdog/pcwd_usb.c175
-rw-r--r--drivers/watchdog/pnx4008_wdt.c18
-rw-r--r--drivers/watchdog/rc32434_wdt.c153
-rw-r--r--drivers/watchdog/riowd.c23
-rw-r--r--drivers/watchdog/rm9k_wdt.c27
-rw-r--r--drivers/watchdog/sa1100_wdt.c6
-rw-r--r--drivers/watchdog/sbc60xxwdt.c2
-rw-r--r--drivers/watchdog/sbc8360.c12
-rw-r--r--drivers/watchdog/sbc_epx_c3.c3
-rw-r--r--drivers/watchdog/sc1200wdt.c7
-rw-r--r--drivers/watchdog/sc520_wdt.c9
-rw-r--r--drivers/watchdog/smsc37b787_wdt.c30
-rw-r--r--drivers/watchdog/softdog.c5
-rw-r--r--drivers/watchdog/w83697hf_wdt.c3
-rw-r--r--drivers/watchdog/w83697ug_wdt.c23
-rw-r--r--drivers/watchdog/w83977f_wdt.c2
-rw-r--r--drivers/watchdog/wd501p.h24
-rw-r--r--drivers/watchdog/wdt.c152
-rw-r--r--drivers/watchdog/wdt977.c2
41 files changed, 758 insertions, 551 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 325c10ff6a2c..55f64af072a4 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -940,21 +940,6 @@ config WDT
940 To compile this driver as a module, choose M here: the 940 To compile this driver as a module, choose M here: the
941 module will be called wdt. 941 module will be called wdt.
942 942
943config WDT_501
944 bool "WDT501 features"
945 depends on WDT
946 help
947 Saying Y here and creating a character special file /dev/temperature
948 with major number 10 and minor number 131 ("man mknod") will give
949 you a thermometer inside your computer: reading from
950 /dev/temperature yields one byte, the temperature in degrees
951 Fahrenheit. This works only if you have a WDT501P watchdog board
952 installed.
953
954 If you want to enable the Fan Tachometer on the WDT501P, then you
955 can do this via the tachometer parameter. Only do this if you have a
956 fan tachometer actually set up.
957
958# 943#
959# PCI-based Watchdog Cards 944# PCI-based Watchdog Cards
960# 945#
diff --git a/drivers/watchdog/acquirewdt.c b/drivers/watchdog/acquirewdt.c
index 3e57aa4d643a..4d18c874d963 100644
--- a/drivers/watchdog/acquirewdt.c
+++ b/drivers/watchdog/acquirewdt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Acquire Single Board Computer Watchdog Timer driver 2 * Acquire Single Board Computer Watchdog Timer driver
3 * 3 *
4 * Based on wdt.c. Original copyright messages: 4 * Based on wdt.c. Original copyright messages:
5 * 5 *
6 * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>, 6 * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>,
7 * All Rights Reserved. 7 * All Rights Reserved.
@@ -17,9 +17,9 @@
17 * 17 *
18 * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> 18 * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
19 * 19 *
20 * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> 20 * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
21 * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT 21 * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
22 * Can't add timeout - driver doesn't allow changing value 22 * Can't add timeout - driver doesn't allow changing value
23 */ 23 */
24 24
25/* 25/*
diff --git a/drivers/watchdog/advantechwdt.c b/drivers/watchdog/advantechwdt.c
index a1d7856ea6e0..824d076a5cd6 100644
--- a/drivers/watchdog/advantechwdt.c
+++ b/drivers/watchdog/advantechwdt.c
@@ -138,7 +138,9 @@ static long advwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
138 void __user *argp = (void __user *)arg; 138 void __user *argp = (void __user *)arg;
139 int __user *p = argp; 139 int __user *p = argp;
140 static struct watchdog_info ident = { 140 static struct watchdog_info ident = {
141 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, 141 .options = WDIOF_KEEPALIVEPING |
142 WDIOF_SETTIMEOUT |
143 WDIOF_MAGICCLOSE,
142 .firmware_version = 1, 144 .firmware_version = 1,
143 .identity = WATCHDOG_NAME, 145 .identity = WATCHDOG_NAME,
144 }; 146 };
@@ -259,7 +261,8 @@ static int __devinit advwdt_probe(struct platform_device *dev)
259 goto unreg_stop; 261 goto unreg_stop;
260 } 262 }
261 263
262 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 264 /* Check that the heartbeat value is within it's range ;
265 * if not reset to the default */
263 if (advwdt_set_heartbeat(timeout)) { 266 if (advwdt_set_heartbeat(timeout)) {
264 advwdt_set_heartbeat(WATCHDOG_TIMEOUT); 267 advwdt_set_heartbeat(WATCHDOG_TIMEOUT);
265 printk(KERN_INFO PFX 268 printk(KERN_INFO PFX
diff --git a/drivers/watchdog/alim1535_wdt.c b/drivers/watchdog/alim1535_wdt.c
index 2a7690ecf97d..937a80fb61e1 100644
--- a/drivers/watchdog/alim1535_wdt.c
+++ b/drivers/watchdog/alim1535_wdt.c
@@ -60,7 +60,7 @@ static void ali_start(void)
60 60
61 pci_read_config_dword(ali_pci, 0xCC, &val); 61 pci_read_config_dword(ali_pci, 0xCC, &val);
62 val &= ~0x3F; /* Mask count */ 62 val &= ~0x3F; /* Mask count */
63 val |= (1<<25) | ali_timeout_bits; 63 val |= (1 << 25) | ali_timeout_bits;
64 pci_write_config_dword(ali_pci, 0xCC, val); 64 pci_write_config_dword(ali_pci, 0xCC, val);
65 65
66 spin_unlock(&ali_lock); 66 spin_unlock(&ali_lock);
@@ -79,8 +79,8 @@ static void ali_stop(void)
79 spin_lock(&ali_lock); 79 spin_lock(&ali_lock);
80 80
81 pci_read_config_dword(ali_pci, 0xCC, &val); 81 pci_read_config_dword(ali_pci, 0xCC, &val);
82 val &= ~0x3F; /* Mask count to zero (disabled) */ 82 val &= ~0x3F; /* Mask count to zero (disabled) */
83 val &= ~(1<<25);/* and for safety mask the reset enable */ 83 val &= ~(1 << 25); /* and for safety mask the reset enable */
84 pci_write_config_dword(ali_pci, 0xCC, val); 84 pci_write_config_dword(ali_pci, 0xCC, val);
85 85
86 spin_unlock(&ali_lock); 86 spin_unlock(&ali_lock);
@@ -89,7 +89,7 @@ static void ali_stop(void)
89/* 89/*
90 * ali_keepalive - send a keepalive to the watchdog 90 * ali_keepalive - send a keepalive to the watchdog
91 * 91 *
92 * Send a keepalive to the timer (actually we restart the timer). 92 * Send a keepalive to the timer (actually we restart the timer).
93 */ 93 */
94 94
95static void ali_keepalive(void) 95static void ali_keepalive(void)
@@ -109,11 +109,11 @@ static int ali_settimer(int t)
109 if (t < 0) 109 if (t < 0)
110 return -EINVAL; 110 return -EINVAL;
111 else if (t < 60) 111 else if (t < 60)
112 ali_timeout_bits = t|(1<<6); 112 ali_timeout_bits = t|(1 << 6);
113 else if (t < 3600) 113 else if (t < 3600)
114 ali_timeout_bits = (t/60)|(1<<7); 114 ali_timeout_bits = (t / 60)|(1 << 7);
115 else if (t < 18000) 115 else if (t < 18000)
116 ali_timeout_bits = (t/300)|(1<<6)|(1<<7); 116 ali_timeout_bits = (t / 300)|(1 << 6)|(1 << 7);
117 else 117 else
118 return -EINVAL; 118 return -EINVAL;
119 119
@@ -138,7 +138,7 @@ static int ali_settimer(int t)
138 */ 138 */
139 139
140static ssize_t ali_write(struct file *file, const char __user *data, 140static ssize_t ali_write(struct file *file, const char __user *data,
141 size_t len, loff_t *ppos) 141 size_t len, loff_t *ppos)
142{ 142{
143 /* See if we got the magic character 'V' and reload the timer */ 143 /* See if we got the magic character 'V' and reload the timer */
144 if (len) { 144 if (len) {
@@ -348,9 +348,9 @@ static int __init ali_find_watchdog(void)
348 /* Timer bits */ 348 /* Timer bits */
349 wdog &= ~0x3F; 349 wdog &= ~0x3F;
350 /* Issued events */ 350 /* Issued events */
351 wdog &= ~((1<<27)|(1<<26)|(1<<25)|(1<<24)); 351 wdog &= ~((1 << 27)|(1 << 26)|(1 << 25)|(1 << 24));
352 /* No monitor bits */ 352 /* No monitor bits */
353 wdog &= ~((1<<16)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)); 353 wdog &= ~((1 << 16)|(1 << 13)|(1 << 12)|(1 << 11)|(1 << 10)|(1 << 9));
354 354
355 pci_write_config_dword(pdev, 0xCC, wdog); 355 pci_write_config_dword(pdev, 0xCC, wdog);
356 356
diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c
index a045ef869439..90f98df5f106 100644
--- a/drivers/watchdog/alim7101_wdt.c
+++ b/drivers/watchdog/alim7101_wdt.c
@@ -355,7 +355,8 @@ static int __init alim7101_wdt_init(void)
355 alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, 355 alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,
356 NULL); 356 NULL);
357 if (!alim7101_pmu) { 357 if (!alim7101_pmu) {
358 printk(KERN_INFO PFX "ALi M7101 PMU not present - WDT not set\n"); 358 printk(KERN_INFO PFX
359 "ALi M7101 PMU not present - WDT not set\n");
359 return -EBUSY; 360 return -EBUSY;
360 } 361 }
361 362
@@ -399,7 +400,8 @@ static int __init alim7101_wdt_init(void)
399 400
400 rc = misc_register(&wdt_miscdev); 401 rc = misc_register(&wdt_miscdev);
401 if (rc) { 402 if (rc) {
402 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 403 printk(KERN_ERR PFX
404 "cannot register miscdev on minor=%d (err=%d)\n",
403 wdt_miscdev.minor, rc); 405 wdt_miscdev.minor, rc);
404 goto err_out_reboot; 406 goto err_out_reboot;
405 } 407 }
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index a56ac84381b1..435b0573fb0a 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -201,7 +201,7 @@ static long at91_wdt_ioctl(struct file *file,
201 * Pat the watchdog whenever device is written to. 201 * Pat the watchdog whenever device is written to.
202 */ 202 */
203static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len, 203static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len,
204 loff_t *ppos) 204 loff_t *ppos)
205{ 205{
206 if (!len) 206 if (!len)
207 return 0; 207 return 0;
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c
index 084dfe9cecfb..41070e4771a0 100644
--- a/drivers/watchdog/cpwd.c
+++ b/drivers/watchdog/cpwd.c
@@ -1,13 +1,13 @@
1/* cpwd.c - driver implementation for hardware watchdog 1/* cpwd.c - driver implementation for hardware watchdog
2 * timers found on Sun Microsystems CP1400 and CP1500 boards. 2 * timers found on Sun Microsystems CP1400 and CP1500 boards.
3 * 3 *
4 * This device supports both the generic Linux watchdog 4 * This device supports both the generic Linux watchdog
5 * interface and Solaris-compatible ioctls as best it is 5 * interface and Solaris-compatible ioctls as best it is
6 * able. 6 * able.
7 * 7 *
8 * NOTE: CP1400 systems appear to have a defective intr_mask 8 * NOTE: CP1400 systems appear to have a defective intr_mask
9 * register on the PLD, preventing the disabling of 9 * register on the PLD, preventing the disabling of
10 * timer interrupts. We use a timer to periodically 10 * timer interrupts. We use a timer to periodically
11 * reset 'stopped' watchdogs on affected platforms. 11 * reset 'stopped' watchdogs on affected platforms.
12 * 12 *
13 * Copyright (c) 2000 Eric Brower (ebrower@usa.net) 13 * Copyright (c) 2000 Eric Brower (ebrower@usa.net)
@@ -28,10 +28,9 @@
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/of.h> 29#include <linux/of.h>
30#include <linux/of_device.h> 30#include <linux/of_device.h>
31#include <linux/uaccess.h>
31 32
32#include <asm/irq.h> 33#include <asm/irq.h>
33#include <asm/uaccess.h>
34
35#include <asm/watchdog.h> 34#include <asm/watchdog.h>
36 35
37#define DRIVER_NAME "cpwd" 36#define DRIVER_NAME "cpwd"
@@ -43,8 +42,8 @@
43#define WD_BLIMIT 0xFFFF 42#define WD_BLIMIT 0xFFFF
44 43
45#define WD0_MINOR 212 44#define WD0_MINOR 212
46#define WD1_MINOR 213 45#define WD1_MINOR 213
47#define WD2_MINOR 214 46#define WD2_MINOR 214
48 47
49/* Internal driver definitions. */ 48/* Internal driver definitions. */
50#define WD0_ID 0 49#define WD0_ID 0
@@ -91,16 +90,16 @@ struct cpwd {
91 90
92static struct cpwd *cpwd_device; 91static struct cpwd *cpwd_device;
93 92
94/* Sun uses Altera PLD EPF8820ATC144-4 93/* Sun uses Altera PLD EPF8820ATC144-4
95 * providing three hardware watchdogs: 94 * providing three hardware watchdogs:
96 * 95 *
97 * 1) RIC - sends an interrupt when triggered 96 * 1) RIC - sends an interrupt when triggered
98 * 2) XIR - asserts XIR_B_RESET when triggered, resets CPU 97 * 2) XIR - asserts XIR_B_RESET when triggered, resets CPU
99 * 3) POR - asserts POR_B_RESET when triggered, resets CPU, backplane, board 98 * 3) POR - asserts POR_B_RESET when triggered, resets CPU, backplane, board
100 * 99 *
101 *** Timer register block definition (struct wd_timer_regblk) 100 *** Timer register block definition (struct wd_timer_regblk)
102 * 101 *
103 * dcntr and limit registers (halfword access): 102 * dcntr and limit registers (halfword access):
104 * ------------------- 103 * -------------------
105 * | 15 | ...| 1 | 0 | 104 * | 15 | ...| 1 | 0 |
106 * ------------------- 105 * -------------------
@@ -108,7 +107,8 @@ static struct cpwd *cpwd_device;
108 * ------------------- 107 * -------------------
109 * dcntr - Current 16-bit downcounter value. 108 * dcntr - Current 16-bit downcounter value.
110 * When downcounter reaches '0' watchdog expires. 109 * When downcounter reaches '0' watchdog expires.
111 * Reading this register resets downcounter with 'limit' value. 110 * Reading this register resets downcounter with
111 * 'limit' value.
112 * limit - 16-bit countdown value in 1/10th second increments. 112 * limit - 16-bit countdown value in 1/10th second increments.
113 * Writing this register begins countdown with input value. 113 * Writing this register begins countdown with input value.
114 * Reading from this register does not affect counter. 114 * Reading from this register does not affect counter.
@@ -158,11 +158,11 @@ static int wd0_timeout = 0;
158static int wd1_timeout = 0; 158static int wd1_timeout = 0;
159static int wd2_timeout = 0; 159static int wd2_timeout = 0;
160 160
161module_param (wd0_timeout, int, 0); 161module_param(wd0_timeout, int, 0);
162MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs"); 162MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs");
163module_param (wd1_timeout, int, 0); 163module_param(wd1_timeout, int, 0);
164MODULE_PARM_DESC(wd1_timeout, "Default watchdog1 timeout in 1/10secs"); 164MODULE_PARM_DESC(wd1_timeout, "Default watchdog1 timeout in 1/10secs");
165module_param (wd2_timeout, int, 0); 165module_param(wd2_timeout, int, 0);
166MODULE_PARM_DESC(wd2_timeout, "Default watchdog2 timeout in 1/10secs"); 166MODULE_PARM_DESC(wd2_timeout, "Default watchdog2 timeout in 1/10secs");
167 167
168MODULE_AUTHOR("Eric Brower <ebrower@usa.net>"); 168MODULE_AUTHOR("Eric Brower <ebrower@usa.net>");
@@ -201,9 +201,9 @@ static u8 cpwd_readb(void __iomem *addr)
201static void cpwd_toggleintr(struct cpwd *p, int index, int enable) 201static void cpwd_toggleintr(struct cpwd *p, int index, int enable)
202{ 202{
203 unsigned char curregs = cpwd_readb(p->regs + PLD_IMASK); 203 unsigned char curregs = cpwd_readb(p->regs + PLD_IMASK);
204 unsigned char setregs = 204 unsigned char setregs =
205 (index == -1) ? 205 (index == -1) ?
206 (WD0_INTR_MASK | WD1_INTR_MASK | WD2_INTR_MASK) : 206 (WD0_INTR_MASK | WD1_INTR_MASK | WD2_INTR_MASK) :
207 (p->devs[index].intr_mask); 207 (p->devs[index].intr_mask);
208 208
209 if (enable == WD_INTR_ON) 209 if (enable == WD_INTR_ON)
@@ -303,24 +303,24 @@ static int cpwd_getstatus(struct cpwd *p, int index)
303 unsigned char ret = WD_STOPPED; 303 unsigned char ret = WD_STOPPED;
304 304
305 /* determine STOPPED */ 305 /* determine STOPPED */
306 if (!stat) 306 if (!stat)
307 return ret; 307 return ret;
308 308
309 /* determine EXPIRED vs FREERUN vs RUNNING */ 309 /* determine EXPIRED vs FREERUN vs RUNNING */
310 else if (WD_S_EXPIRED & stat) { 310 else if (WD_S_EXPIRED & stat) {
311 ret = WD_EXPIRED; 311 ret = WD_EXPIRED;
312 } else if(WD_S_RUNNING & stat) { 312 } else if (WD_S_RUNNING & stat) {
313 if (intr & p->devs[index].intr_mask) { 313 if (intr & p->devs[index].intr_mask) {
314 ret = WD_FREERUN; 314 ret = WD_FREERUN;
315 } else { 315 } else {
316 /* Fudge WD_EXPIRED status for defective CP1400-- 316 /* Fudge WD_EXPIRED status for defective CP1400--
317 * IF timer is running 317 * IF timer is running
318 * AND brokenstop is set 318 * AND brokenstop is set
319 * AND an interrupt has been serviced 319 * AND an interrupt has been serviced
320 * we are WD_EXPIRED. 320 * we are WD_EXPIRED.
321 * 321 *
322 * IF timer is running 322 * IF timer is running
323 * AND brokenstop is set 323 * AND brokenstop is set
324 * AND no interrupt has been serviced 324 * AND no interrupt has been serviced
325 * we are WD_FREERUN. 325 * we are WD_FREERUN.
326 */ 326 */
@@ -329,7 +329,8 @@ static int cpwd_getstatus(struct cpwd *p, int index)
329 if (p->devs[index].runstatus & WD_STAT_SVCD) { 329 if (p->devs[index].runstatus & WD_STAT_SVCD) {
330 ret = WD_EXPIRED; 330 ret = WD_EXPIRED;
331 } else { 331 } else {
332 /* we could as well pretend we are expired */ 332 /* we could as well pretend
333 * we are expired */
333 ret = WD_FREERUN; 334 ret = WD_FREERUN;
334 } 335 }
335 } else { 336 } else {
@@ -342,7 +343,7 @@ static int cpwd_getstatus(struct cpwd *p, int index)
342 if (p->devs[index].runstatus & WD_STAT_SVCD) 343 if (p->devs[index].runstatus & WD_STAT_SVCD)
343 ret |= WD_SERVICED; 344 ret |= WD_SERVICED;
344 345
345 return(ret); 346 return ret;
346} 347}
347 348
348static irqreturn_t cpwd_interrupt(int irq, void *dev_id) 349static irqreturn_t cpwd_interrupt(int irq, void *dev_id)
@@ -367,22 +368,22 @@ static int cpwd_open(struct inode *inode, struct file *f)
367 struct cpwd *p = cpwd_device; 368 struct cpwd *p = cpwd_device;
368 369
369 lock_kernel(); 370 lock_kernel();
370 switch(iminor(inode)) { 371 switch (iminor(inode)) {
371 case WD0_MINOR: 372 case WD0_MINOR:
372 case WD1_MINOR: 373 case WD1_MINOR:
373 case WD2_MINOR: 374 case WD2_MINOR:
374 break; 375 break;
375 376
376 default: 377 default:
377 unlock_kernel(); 378 unlock_kernel();
378 return -ENODEV; 379 return -ENODEV;
379 } 380 }
380 381
381 /* Register IRQ on first open of device */ 382 /* Register IRQ on first open of device */
382 if (!p->initialized) { 383 if (!p->initialized) {
383 if (request_irq(p->irq, &cpwd_interrupt, 384 if (request_irq(p->irq, &cpwd_interrupt,
384 IRQF_SHARED, DRIVER_NAME, p)) { 385 IRQF_SHARED, DRIVER_NAME, p)) {
385 printk(KERN_ERR PFX "Cannot register IRQ %d\n", 386 printk(KERN_ERR PFX "Cannot register IRQ %d\n",
386 p->irq); 387 p->irq);
387 unlock_kernel(); 388 unlock_kernel();
388 return -EBUSY; 389 return -EBUSY;
@@ -400,8 +401,7 @@ static int cpwd_release(struct inode *inode, struct file *file)
400 return 0; 401 return 0;
401} 402}
402 403
403static int cpwd_ioctl(struct inode *inode, struct file *file, 404static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
404 unsigned int cmd, unsigned long arg)
405{ 405{
406 static struct watchdog_info info = { 406 static struct watchdog_info info = {
407 .options = WDIOF_SETTIMEOUT, 407 .options = WDIOF_SETTIMEOUT,
@@ -409,6 +409,7 @@ static int cpwd_ioctl(struct inode *inode, struct file *file,
409 .identity = DRIVER_NAME, 409 .identity = DRIVER_NAME,
410 }; 410 };
411 void __user *argp = (void __user *)arg; 411 void __user *argp = (void __user *)arg;
412 struct inode *inode = file->f_path.dentry->d_inode;
412 int index = iminor(inode) - WD0_MINOR; 413 int index = iminor(inode) - WD0_MINOR;
413 struct cpwd *p = cpwd_device; 414 struct cpwd *p = cpwd_device;
414 int setopt = 0; 415 int setopt = 0;
@@ -442,7 +443,7 @@ static int cpwd_ioctl(struct inode *inode, struct file *file,
442 cpwd_starttimer(p, index); 443 cpwd_starttimer(p, index);
443 } else { 444 } else {
444 return -EINVAL; 445 return -EINVAL;
445 } 446 }
446 break; 447 break;
447 448
448 /* Solaris-compatible IOCTLs */ 449 /* Solaris-compatible IOCTLs */
@@ -458,7 +459,7 @@ static int cpwd_ioctl(struct inode *inode, struct file *file,
458 459
459 case WIOCSTOP: 460 case WIOCSTOP:
460 if (p->enabled) 461 if (p->enabled)
461 return(-EINVAL); 462 return -EINVAL;
462 463
463 cpwd_stoptimer(p, index); 464 cpwd_stoptimer(p, index);
464 break; 465 break;
@@ -481,7 +482,7 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd,
481 case WIOCSTOP: 482 case WIOCSTOP:
482 case WIOCGSTAT: 483 case WIOCGSTAT:
483 lock_kernel(); 484 lock_kernel();
484 rval = cpwd_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); 485 rval = cpwd_ioctl(file, cmd, arg);
485 unlock_kernel(); 486 unlock_kernel();
486 break; 487 break;
487 488
@@ -493,7 +494,7 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd,
493 return rval; 494 return rval;
494} 495}
495 496
496static ssize_t cpwd_write(struct file *file, const char __user *buf, 497static ssize_t cpwd_write(struct file *file, const char __user *buf,
497 size_t count, loff_t *ppos) 498 size_t count, loff_t *ppos)
498{ 499{
499 struct inode *inode = file->f_path.dentry->d_inode; 500 struct inode *inode = file->f_path.dentry->d_inode;
@@ -508,20 +509,20 @@ static ssize_t cpwd_write(struct file *file, const char __user *buf,
508 return 0; 509 return 0;
509} 510}
510 511
511static ssize_t cpwd_read(struct file * file, char __user *buffer, 512static ssize_t cpwd_read(struct file *file, char __user *buffer,
512 size_t count, loff_t *ppos) 513 size_t count, loff_t *ppos)
513{ 514{
514 return -EINVAL; 515 return -EINVAL;
515} 516}
516 517
517static const struct file_operations cpwd_fops = { 518static const struct file_operations cpwd_fops = {
518 .owner = THIS_MODULE, 519 .owner = THIS_MODULE,
519 .ioctl = cpwd_ioctl, 520 .unlocked_ioctl = cpwd_ioctl,
520 .compat_ioctl = cpwd_compat_ioctl, 521 .compat_ioctl = cpwd_compat_ioctl,
521 .open = cpwd_open, 522 .open = cpwd_open,
522 .write = cpwd_write, 523 .write = cpwd_write,
523 .read = cpwd_read, 524 .read = cpwd_read,
524 .release = cpwd_release, 525 .release = cpwd_release,
525}; 526};
526 527
527static int __devinit cpwd_probe(struct of_device *op, 528static int __devinit cpwd_probe(struct of_device *op,
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index 2e1360286732..c51d0b0ea0c4 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -24,7 +24,7 @@
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/uaccess.h> 25#include <linux/uaccess.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <mach/hardware.h> 27#include <linux/device.h>
28 28
29#define MODULE_NAME "DAVINCI-WDT: " 29#define MODULE_NAME "DAVINCI-WDT: "
30 30
@@ -75,9 +75,9 @@ static void wdt_service(void)
75 spin_lock(&io_lock); 75 spin_lock(&io_lock);
76 76
77 /* put watchdog in service state */ 77 /* put watchdog in service state */
78 davinci_writel(WDKEY_SEQ0, wdt_base + WDTCR); 78 iowrite32(WDKEY_SEQ0, wdt_base + WDTCR);
79 /* put watchdog in active state */ 79 /* put watchdog in active state */
80 davinci_writel(WDKEY_SEQ1, wdt_base + WDTCR); 80 iowrite32(WDKEY_SEQ1, wdt_base + WDTCR);
81 81
82 spin_unlock(&io_lock); 82 spin_unlock(&io_lock);
83} 83}
@@ -90,29 +90,29 @@ static void wdt_enable(void)
90 spin_lock(&io_lock); 90 spin_lock(&io_lock);
91 91
92 /* disable, internal clock source */ 92 /* disable, internal clock source */
93 davinci_writel(0, wdt_base + TCR); 93 iowrite32(0, wdt_base + TCR);
94 /* reset timer, set mode to 64-bit watchdog, and unreset */ 94 /* reset timer, set mode to 64-bit watchdog, and unreset */
95 davinci_writel(0, wdt_base + TGCR); 95 iowrite32(0, wdt_base + TGCR);
96 tgcr = TIMMODE_64BIT_WDOG | TIM12RS_UNRESET | TIM34RS_UNRESET; 96 tgcr = TIMMODE_64BIT_WDOG | TIM12RS_UNRESET | TIM34RS_UNRESET;
97 davinci_writel(tgcr, wdt_base + TGCR); 97 iowrite32(tgcr, wdt_base + TGCR);
98 /* clear counter regs */ 98 /* clear counter regs */
99 davinci_writel(0, wdt_base + TIM12); 99 iowrite32(0, wdt_base + TIM12);
100 davinci_writel(0, wdt_base + TIM34); 100 iowrite32(0, wdt_base + TIM34);
101 /* set timeout period */ 101 /* set timeout period */
102 timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) & 0xffffffff); 102 timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) & 0xffffffff);
103 davinci_writel(timer_margin, wdt_base + PRD12); 103 iowrite32(timer_margin, wdt_base + PRD12);
104 timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) >> 32); 104 timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) >> 32);
105 davinci_writel(timer_margin, wdt_base + PRD34); 105 iowrite32(timer_margin, wdt_base + PRD34);
106 /* enable run continuously */ 106 /* enable run continuously */
107 davinci_writel(ENAMODE12_PERIODIC, wdt_base + TCR); 107 iowrite32(ENAMODE12_PERIODIC, wdt_base + TCR);
108 /* Once the WDT is in pre-active state write to 108 /* Once the WDT is in pre-active state write to
109 * TIM12, TIM34, PRD12, PRD34, TCR, TGCR, WDTCR are 109 * TIM12, TIM34, PRD12, PRD34, TCR, TGCR, WDTCR are
110 * write protected (except for the WDKEY field) 110 * write protected (except for the WDKEY field)
111 */ 111 */
112 /* put watchdog in pre-active state */ 112 /* put watchdog in pre-active state */
113 davinci_writel(WDKEY_SEQ0 | WDEN, wdt_base + WDTCR); 113 iowrite32(WDKEY_SEQ0 | WDEN, wdt_base + WDTCR);
114 /* put watchdog in active state */ 114 /* put watchdog in active state */
115 davinci_writel(WDKEY_SEQ1 | WDEN, wdt_base + WDTCR); 115 iowrite32(WDKEY_SEQ1 | WDEN, wdt_base + WDTCR);
116 116
117 spin_unlock(&io_lock); 117 spin_unlock(&io_lock);
118} 118}
@@ -197,17 +197,16 @@ static int davinci_wdt_probe(struct platform_device *pdev)
197{ 197{
198 int ret = 0, size; 198 int ret = 0, size;
199 struct resource *res; 199 struct resource *res;
200 struct device *dev = &pdev->dev;
200 201
201 if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) 202 if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
202 heartbeat = DEFAULT_HEARTBEAT; 203 heartbeat = DEFAULT_HEARTBEAT;
203 204
204 printk(KERN_INFO MODULE_NAME 205 dev_info(dev, "heartbeat %d sec\n", heartbeat);
205 "DaVinci Watchdog Timer: heartbeat %d sec\n", heartbeat);
206 206
207 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 207 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
208 if (res == NULL) { 208 if (res == NULL) {
209 printk(KERN_INFO MODULE_NAME 209 dev_err(dev, "failed to get memory region resource\n");
210 "failed to get memory region resource\n");
211 return -ENOENT; 210 return -ENOENT;
212 } 211 }
213 212
@@ -215,20 +214,26 @@ static int davinci_wdt_probe(struct platform_device *pdev)
215 wdt_mem = request_mem_region(res->start, size, pdev->name); 214 wdt_mem = request_mem_region(res->start, size, pdev->name);
216 215
217 if (wdt_mem == NULL) { 216 if (wdt_mem == NULL) {
218 printk(KERN_INFO MODULE_NAME "failed to get memory region\n"); 217 dev_err(dev, "failed to get memory region\n");
219 return -ENOENT; 218 return -ENOENT;
220 } 219 }
221 wdt_base = (void __iomem *)(res->start); 220
221 wdt_base = ioremap(res->start, size);
222 if (!wdt_base) {
223 dev_err(dev, "failed to map memory region\n");
224 return -ENOMEM;
225 }
222 226
223 ret = misc_register(&davinci_wdt_miscdev); 227 ret = misc_register(&davinci_wdt_miscdev);
224 if (ret < 0) { 228 if (ret < 0) {
225 printk(KERN_ERR MODULE_NAME "cannot register misc device\n"); 229 dev_err(dev, "cannot register misc device\n");
226 release_resource(wdt_mem); 230 release_resource(wdt_mem);
227 kfree(wdt_mem); 231 kfree(wdt_mem);
228 } else { 232 } else {
229 set_bit(WDT_DEVICE_INITED, &wdt_status); 233 set_bit(WDT_DEVICE_INITED, &wdt_status);
230 } 234 }
231 235
236 iounmap(wdt_base);
232 return ret; 237 return ret;
233} 238}
234 239
diff --git a/drivers/watchdog/eurotechwdt.c b/drivers/watchdog/eurotechwdt.c
index a171fc6ae1cb..9add3541fb42 100644
--- a/drivers/watchdog/eurotechwdt.c
+++ b/drivers/watchdog/eurotechwdt.c
@@ -8,19 +8,19 @@
8 * Based on wdt.c. 8 * Based on wdt.c.
9 * Original copyright messages: 9 * Original copyright messages:
10 * 10 *
11 * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>, 11 * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
12 * All Rights Reserved. 12 * All Rights Reserved.
13 * 13 *
14 * This program is free software; you can redistribute it and/or 14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License 15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version. 17 * 2 of the License, or (at your option) any later version.
18 * 18 *
19 * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 19 * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
20 * warranty for any of this software. This material is provided 20 * warranty for any of this software. This material is provided
21 * "AS-IS" and at no charge. 21 * "AS-IS" and at no charge.
22 * 22 *
23 * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>* 23 * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>*
24 */ 24 */
25 25
26/* Changelog: 26/* Changelog:
@@ -37,7 +37,7 @@
37 * add expect_close support 37 * add expect_close support
38 * 38 *
39 * 2002.05.30 - Joel Becker <joel.becker@oracle.com> 39 * 2002.05.30 - Joel Becker <joel.becker@oracle.com>
40 * Added Matt Domsch's nowayout module option. 40 * Added Matt Domsch's nowayout module option.
41 */ 41 */
42 42
43/* 43/*
@@ -151,7 +151,7 @@ static void eurwdt_activate_timer(void)
151 if (irq == 0) 151 if (irq == 0)
152 printk(KERN_INFO ": interrupt disabled\n"); 152 printk(KERN_INFO ": interrupt disabled\n");
153 153
154 eurwdt_write_reg(WDT_TIMER_CFG, irq<<4); 154 eurwdt_write_reg(WDT_TIMER_CFG, irq << 4);
155 155
156 eurwdt_write_reg(WDT_UNIT_SEL, WDT_UNIT_SECS); /* we use seconds */ 156 eurwdt_write_reg(WDT_UNIT_SEL, WDT_UNIT_SECS); /* we use seconds */
157 eurwdt_set_timeout(0); /* the default timeout */ 157 eurwdt_set_timeout(0); /* the default timeout */
diff --git a/drivers/watchdog/geodewdt.c b/drivers/watchdog/geodewdt.c
index 6799a6de66fe..9acf0015a1e7 100644
--- a/drivers/watchdog/geodewdt.c
+++ b/drivers/watchdog/geodewdt.c
@@ -34,11 +34,15 @@
34 34
35static int timeout = WATCHDOG_TIMEOUT; 35static int timeout = WATCHDOG_TIMEOUT;
36module_param(timeout, int, 0); 36module_param(timeout, int, 0);
37MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=131, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) "."); 37MODULE_PARM_DESC(timeout,
38 "Watchdog timeout in seconds. 1<= timeout <=131, default="
39 __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
38 40
39static int nowayout = WATCHDOG_NOWAYOUT; 41static int nowayout = WATCHDOG_NOWAYOUT;
40module_param(nowayout, int, 0); 42module_param(nowayout, int, 0);
41MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 43MODULE_PARM_DESC(nowayout,
44 "Watchdog cannot be stopped once started (default="
45 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
42 46
43static struct platform_device *geodewdt_platform_device; 47static struct platform_device *geodewdt_platform_device;
44static unsigned long wdt_flags; 48static unsigned long wdt_flags;
@@ -269,7 +273,8 @@ static int __init geodewdt_init(void)
269 if (ret) 273 if (ret)
270 return ret; 274 return ret;
271 275
272 geodewdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); 276 geodewdt_platform_device = platform_device_register_simple(DRV_NAME,
277 -1, NULL, 0);
273 if (IS_ERR(geodewdt_platform_device)) { 278 if (IS_ERR(geodewdt_platform_device)) {
274 ret = PTR_ERR(geodewdt_platform_device); 279 ret = PTR_ERR(geodewdt_platform_device);
275 goto err; 280 goto err;
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 763c1ea5dce5..6cf155d6b350 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -47,6 +47,7 @@
47#define PCI_BIOS32_PARAGRAPH_LEN 16 47#define PCI_BIOS32_PARAGRAPH_LEN 16
48#define PCI_ROM_BASE1 0x000F0000 48#define PCI_ROM_BASE1 0x000F0000
49#define ROM_SIZE 0x10000 49#define ROM_SIZE 0x10000
50#define HPWDT_VERSION "1.01"
50 51
51struct bios32_service_dir { 52struct bios32_service_dir {
52 u32 signature; 53 u32 signature;
@@ -130,17 +131,14 @@ static void *cru_rom_addr;
130static struct cmn_registers cmn_regs; 131static struct cmn_registers cmn_regs;
131 132
132static struct pci_device_id hpwdt_devices[] = { 133static struct pci_device_id hpwdt_devices[] = {
133 { 134 { PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB203) },
134 .vendor = PCI_VENDOR_ID_COMPAQ, 135 { PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3306) },
135 .device = 0xB203,
136 .subvendor = PCI_ANY_ID,
137 .subdevice = PCI_ANY_ID,
138 },
139 {0}, /* terminate list */ 136 {0}, /* terminate list */
140}; 137};
141MODULE_DEVICE_TABLE(pci, hpwdt_devices); 138MODULE_DEVICE_TABLE(pci, hpwdt_devices);
142 139
143extern asmlinkage void asminline_call(struct cmn_registers *pi86Regs, unsigned long *pRomEntry); 140extern asmlinkage void asminline_call(struct cmn_registers *pi86Regs,
141 unsigned long *pRomEntry);
144 142
145#ifndef CONFIG_X86_64 143#ifndef CONFIG_X86_64
146/* --32 Bit Bios------------------------------------------------------------ */ 144/* --32 Bit Bios------------------------------------------------------------ */
@@ -605,7 +603,7 @@ static long hpwdt_ioctl(struct file *file, unsigned int cmd,
605/* 603/*
606 * Kernel interfaces 604 * Kernel interfaces
607 */ 605 */
608static struct file_operations hpwdt_fops = { 606static const struct file_operations hpwdt_fops = {
609 .owner = THIS_MODULE, 607 .owner = THIS_MODULE,
610 .llseek = no_llseek, 608 .llseek = no_llseek,
611 .write = hpwdt_write, 609 .write = hpwdt_write,
@@ -704,10 +702,11 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
704 } 702 }
705 703
706 printk(KERN_INFO 704 printk(KERN_INFO
707 "hp Watchdog Timer Driver: 1.00" 705 "hp Watchdog Timer Driver: %s"
708 ", timer margin: %d seconds (nowayout=%d)" 706 ", timer margin: %d seconds (nowayout=%d)"
709 ", allow kernel dump: %s (default = 0/OFF).\n", 707 ", allow kernel dump: %s (default = 0/OFF).\n",
710 soft_margin, nowayout, (allow_kdump == 0) ? "OFF" : "ON"); 708 HPWDT_VERSION, soft_margin, nowayout,
709 (allow_kdump == 0) ? "OFF" : "ON");
711 710
712 return 0; 711 return 0;
713 712
@@ -757,6 +756,7 @@ static int __init hpwdt_init(void)
757MODULE_AUTHOR("Tom Mingarelli"); 756MODULE_AUTHOR("Tom Mingarelli");
758MODULE_DESCRIPTION("hp watchdog driver"); 757MODULE_DESCRIPTION("hp watchdog driver");
759MODULE_LICENSE("GPL"); 758MODULE_LICENSE("GPL");
759MODULE_VERSION(HPWDT_VERSION);
760MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 760MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
761 761
762module_param(soft_margin, int, 0); 762module_param(soft_margin, int, 0);
diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c
index 74f951c18b90..2dbe83570d65 100644
--- a/drivers/watchdog/i6300esb.c
+++ b/drivers/watchdog/i6300esb.c
@@ -13,7 +13,7 @@
13 * 13 *
14 * The timer is implemented in the following I/O controller hubs: 14 * The timer is implemented in the following I/O controller hubs:
15 * (See the intel documentation on http://developer.intel.com.) 15 * (See the intel documentation on http://developer.intel.com.)
16 * 6300ESB chip : document number 300641-003 16 * 6300ESB chip : document number 300641-004
17 * 17 *
18 * 2004YYZZ Ross Biro 18 * 2004YYZZ Ross Biro
19 * Initial version 0.01 19 * Initial version 0.01
@@ -34,7 +34,7 @@
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/miscdevice.h> 35#include <linux/miscdevice.h>
36#include <linux/watchdog.h> 36#include <linux/watchdog.h>
37#include <linux/reboot.h> 37#include <linux/platform_device.h>
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/ioport.h> 40#include <linux/ioport.h>
@@ -42,7 +42,7 @@
42#include <linux/io.h> 42#include <linux/io.h>
43 43
44/* Module and version information */ 44/* Module and version information */
45#define ESB_VERSION "0.03" 45#define ESB_VERSION "0.04"
46#define ESB_MODULE_NAME "i6300ESB timer" 46#define ESB_MODULE_NAME "i6300ESB timer"
47#define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION 47#define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION
48#define PFX ESB_MODULE_NAME ": " 48#define PFX ESB_MODULE_NAME ": "
@@ -81,6 +81,7 @@ static unsigned long timer_alive;
81static struct pci_dev *esb_pci; 81static struct pci_dev *esb_pci;
82static unsigned short triggered; /* The status of the watchdog upon boot */ 82static unsigned short triggered; /* The status of the watchdog upon boot */
83static char esb_expect_close; 83static char esb_expect_close;
84static struct platform_device *esb_platform_device;
84 85
85/* module parameters */ 86/* module parameters */
86/* 30 sec default heartbeat (1 < heartbeat < 2*1023) */ 87/* 30 sec default heartbeat (1 < heartbeat < 2*1023) */
@@ -114,13 +115,18 @@ static inline void esb_unlock_registers(void)
114 writeb(ESB_UNLOCK2, ESB_RELOAD_REG); 115 writeb(ESB_UNLOCK2, ESB_RELOAD_REG);
115} 116}
116 117
117static void esb_timer_start(void) 118static int esb_timer_start(void)
118{ 119{
119 u8 val; 120 u8 val;
120 121
122 spin_lock(&esb_lock);
123 esb_unlock_registers();
124 writew(ESB_WDT_RELOAD, ESB_RELOAD_REG);
121 /* Enable or Enable + Lock? */ 125 /* Enable or Enable + Lock? */
122 val = 0x02 | (nowayout ? 0x01 : 0x00); 126 val = 0x02 | (nowayout ? 0x01 : 0x00);
123 pci_write_config_byte(esb_pci, ESB_LOCK_REG, val); 127 pci_write_config_byte(esb_pci, ESB_LOCK_REG, val);
128 spin_unlock(&esb_lock);
129 return 0;
124} 130}
125 131
126static int esb_timer_stop(void) 132static int esb_timer_stop(void)
@@ -207,7 +213,6 @@ static int esb_open(struct inode *inode, struct file *file)
207 return -EBUSY; 213 return -EBUSY;
208 214
209 /* Reload and activate timer */ 215 /* Reload and activate timer */
210 esb_timer_keepalive();
211 esb_timer_start(); 216 esb_timer_start();
212 217
213 return nonseekable_open(inode, file); 218 return nonseekable_open(inode, file);
@@ -240,7 +245,8 @@ static ssize_t esb_write(struct file *file, const char __user *data,
240 * five months ago... */ 245 * five months ago... */
241 esb_expect_close = 0; 246 esb_expect_close = 0;
242 247
243 /* scan to see whether or not we got the magic character */ 248 /* scan to see whether or not we got the
249 * magic character */
244 for (i = 0; i != len; i++) { 250 for (i = 0; i != len; i++) {
245 char c; 251 char c;
246 if (get_user(c, data + i)) 252 if (get_user(c, data + i))
@@ -292,7 +298,6 @@ static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
292 } 298 }
293 299
294 if (new_options & WDIOS_ENABLECARD) { 300 if (new_options & WDIOS_ENABLECARD) {
295 esb_timer_keepalive();
296 esb_timer_start(); 301 esb_timer_start();
297 retval = 0; 302 retval = 0;
298 } 303 }
@@ -319,19 +324,6 @@ static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
319} 324}
320 325
321/* 326/*
322 * Notify system
323 */
324
325static int esb_notify_sys(struct notifier_block *this,
326 unsigned long code, void *unused)
327{
328 if (code == SYS_DOWN || code == SYS_HALT)
329 esb_timer_stop(); /* Turn the WDT off */
330
331 return NOTIFY_DONE;
332}
333
334/*
335 * Kernel Interfaces 327 * Kernel Interfaces
336 */ 328 */
337 329
@@ -350,10 +342,6 @@ static struct miscdevice esb_miscdev = {
350 .fops = &esb_fops, 342 .fops = &esb_fops,
351}; 343};
352 344
353static struct notifier_block esb_notifier = {
354 .notifier_call = esb_notify_sys,
355};
356
357/* 345/*
358 * Data for PCI driver interface 346 * Data for PCI driver interface
359 * 347 *
@@ -372,7 +360,7 @@ MODULE_DEVICE_TABLE(pci, esb_pci_tbl);
372 * Init & exit routines 360 * Init & exit routines
373 */ 361 */
374 362
375static unsigned char __init esb_getdevice(void) 363static unsigned char __devinit esb_getdevice(void)
376{ 364{
377 u8 val1; 365 u8 val1;
378 unsigned short val2; 366 unsigned short val2;
@@ -443,7 +431,7 @@ err_devput:
443 return 0; 431 return 0;
444} 432}
445 433
446static int __init watchdog_init(void) 434static int __devinit esb_probe(struct platform_device *dev)
447{ 435{
448 int ret; 436 int ret;
449 437
@@ -459,19 +447,13 @@ static int __init watchdog_init(void)
459 "heartbeat value must be 1<heartbeat<2046, using %d\n", 447 "heartbeat value must be 1<heartbeat<2046, using %d\n",
460 heartbeat); 448 heartbeat);
461 } 449 }
462 ret = register_reboot_notifier(&esb_notifier);
463 if (ret != 0) {
464 printk(KERN_ERR PFX
465 "cannot register reboot notifier (err=%d)\n", ret);
466 goto err_unmap;
467 }
468 450
469 ret = misc_register(&esb_miscdev); 451 ret = misc_register(&esb_miscdev);
470 if (ret != 0) { 452 if (ret != 0) {
471 printk(KERN_ERR PFX 453 printk(KERN_ERR PFX
472 "cannot register miscdev on minor=%d (err=%d)\n", 454 "cannot register miscdev on minor=%d (err=%d)\n",
473 WATCHDOG_MINOR, ret); 455 WATCHDOG_MINOR, ret);
474 goto err_notifier; 456 goto err_unmap;
475 } 457 }
476 esb_timer_stop(); 458 esb_timer_stop();
477 printk(KERN_INFO PFX 459 printk(KERN_INFO PFX
@@ -479,8 +461,6 @@ static int __init watchdog_init(void)
479 BASEADDR, heartbeat, nowayout); 461 BASEADDR, heartbeat, nowayout);
480 return 0; 462 return 0;
481 463
482err_notifier:
483 unregister_reboot_notifier(&esb_notifier);
484err_unmap: 464err_unmap:
485 iounmap(BASEADDR); 465 iounmap(BASEADDR);
486/* err_release: */ 466/* err_release: */
@@ -492,7 +472,7 @@ err_unmap:
492 return ret; 472 return ret;
493} 473}
494 474
495static void __exit watchdog_cleanup(void) 475static int __devexit esb_remove(struct platform_device *dev)
496{ 476{
497 /* Stop the timer before we leave */ 477 /* Stop the timer before we leave */
498 if (!nowayout) 478 if (!nowayout)
@@ -500,11 +480,58 @@ static void __exit watchdog_cleanup(void)
500 480
501 /* Deregister */ 481 /* Deregister */
502 misc_deregister(&esb_miscdev); 482 misc_deregister(&esb_miscdev);
503 unregister_reboot_notifier(&esb_notifier);
504 iounmap(BASEADDR); 483 iounmap(BASEADDR);
505 pci_release_region(esb_pci, 0); 484 pci_release_region(esb_pci, 0);
506 pci_disable_device(esb_pci); 485 pci_disable_device(esb_pci);
507 pci_dev_put(esb_pci); 486 pci_dev_put(esb_pci);
487 return 0;
488}
489
490static void esb_shutdown(struct platform_device *dev)
491{
492 esb_timer_stop();
493}
494
495static struct platform_driver esb_platform_driver = {
496 .probe = esb_probe,
497 .remove = __devexit_p(esb_remove),
498 .shutdown = esb_shutdown,
499 .driver = {
500 .owner = THIS_MODULE,
501 .name = ESB_MODULE_NAME,
502 },
503};
504
505static int __init watchdog_init(void)
506{
507 int err;
508
509 printk(KERN_INFO PFX "Intel 6300ESB WatchDog Timer Driver v%s\n",
510 ESB_VERSION);
511
512 err = platform_driver_register(&esb_platform_driver);
513 if (err)
514 return err;
515
516 esb_platform_device = platform_device_register_simple(ESB_MODULE_NAME,
517 -1, NULL, 0);
518 if (IS_ERR(esb_platform_device)) {
519 err = PTR_ERR(esb_platform_device);
520 goto unreg_platform_driver;
521 }
522
523 return 0;
524
525unreg_platform_driver:
526 platform_driver_unregister(&esb_platform_driver);
527 return err;
528}
529
530static void __exit watchdog_cleanup(void)
531{
532 platform_device_unregister(esb_platform_device);
533 platform_driver_unregister(&esb_platform_driver);
534 printk(KERN_INFO PFX "Watchdog Module Unloaded.\n");
508} 535}
509 536
510module_init(watchdog_init); 537module_init(watchdog_init);
diff --git a/drivers/watchdog/iTCO_vendor_support.c b/drivers/watchdog/iTCO_vendor_support.c
index d8264ad0be41..d3c0f6de5523 100644
--- a/drivers/watchdog/iTCO_vendor_support.c
+++ b/drivers/watchdog/iTCO_vendor_support.c
@@ -47,7 +47,8 @@
47 47
48static int vendorsupport; 48static int vendorsupport;
49module_param(vendorsupport, int, 0); 49module_param(vendorsupport, int, 0);
50MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default=0 (none), 1=SuperMicro Pent3, 2=SuperMicro Pent4+"); 50MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default="
51 "0 (none), 1=SuperMicro Pent3, 2=SuperMicro Pent4+");
51 52
52/* 53/*
53 * Vendor Specific Support 54 * Vendor Specific Support
@@ -305,7 +306,8 @@ static void __exit iTCO_vendor_exit_module(void)
305module_init(iTCO_vendor_init_module); 306module_init(iTCO_vendor_init_module);
306module_exit(iTCO_vendor_exit_module); 307module_exit(iTCO_vendor_exit_module);
307 308
308MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>, R. Seretny <lkpatches@paypc.com>"); 309MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>, "
310 "R. Seretny <lkpatches@paypc.com>");
309MODULE_DESCRIPTION("Intel TCO Vendor Specific WatchDog Timer Driver Support"); 311MODULE_DESCRIPTION("Intel TCO Vendor Specific WatchDog Timer Driver Support");
310MODULE_VERSION(DRV_VERSION); 312MODULE_VERSION(DRV_VERSION);
311MODULE_LICENSE("GPL"); 313MODULE_LICENSE("GPL");
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 352334947ea3..648250b998c4 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -273,7 +273,9 @@ static struct platform_device *iTCO_wdt_platform_device;
273#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ 273#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */
274static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ 274static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */
275module_param(heartbeat, int, 0); 275module_param(heartbeat, int, 0);
276MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39 (TCO v1) or 613 (TCO v2), default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); 276MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
277 "(2<heartbeat<39 (TCO v1) or 613 (TCO v2), default="
278 __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
277 279
278static int nowayout = WATCHDOG_NOWAYOUT; 280static int nowayout = WATCHDOG_NOWAYOUT;
279module_param(nowayout, int, 0); 281module_param(nowayout, int, 0);
@@ -346,7 +348,8 @@ static int iTCO_wdt_start(void)
346 /* disable chipset's NO_REBOOT bit */ 348 /* disable chipset's NO_REBOOT bit */
347 if (iTCO_wdt_unset_NO_REBOOT_bit()) { 349 if (iTCO_wdt_unset_NO_REBOOT_bit()) {
348 spin_unlock(&iTCO_wdt_private.io_lock); 350 spin_unlock(&iTCO_wdt_private.io_lock);
349 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); 351 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, "
352 "reboot disabled by hardware\n");
350 return -EIO; 353 return -EIO;
351 } 354 }
352 355
@@ -669,7 +672,8 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
669 672
670 /* Check chipset's NO_REBOOT bit */ 673 /* Check chipset's NO_REBOOT bit */
671 if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) { 674 if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) {
672 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); 675 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, "
676 "reboot disabled by hardware\n");
673 ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ 677 ret = -ENODEV; /* Cannot reset NO_REBOOT bit */
674 goto out; 678 goto out;
675 } 679 }
@@ -716,8 +720,9 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
716 if not reset to the default */ 720 if not reset to the default */
717 if (iTCO_wdt_set_heartbeat(heartbeat)) { 721 if (iTCO_wdt_set_heartbeat(heartbeat)) {
718 iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT); 722 iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT);
719 printk(KERN_INFO PFX "heartbeat value must be 2 < heartbeat < 39 (TCO v1) or 613 (TCO v2), using %d\n", 723 printk(KERN_INFO PFX
720 heartbeat); 724 "heartbeat value must be 2 < heartbeat < 39 (TCO v1) "
725 "or 613 (TCO v2), using %d\n", heartbeat);
721 } 726 }
722 727
723 ret = misc_register(&iTCO_wdt_miscdev); 728 ret = misc_register(&iTCO_wdt_miscdev);
diff --git a/drivers/watchdog/it87_wdt.c b/drivers/watchdog/it87_wdt.c
index afb8af397a9f..cc133c531d08 100644
--- a/drivers/watchdog/it87_wdt.c
+++ b/drivers/watchdog/it87_wdt.c
@@ -188,8 +188,8 @@ static inline int superio_inb(int reg)
188 188
189static inline void superio_outb(int val, int reg) 189static inline void superio_outb(int val, int reg)
190{ 190{
191 outb(reg, REG); 191 outb(reg, REG);
192 outb(val, VAL); 192 outb(val, VAL);
193} 193}
194 194
195static inline int superio_inw(int reg) 195static inline int superio_inw(int reg)
@@ -204,10 +204,10 @@ static inline int superio_inw(int reg)
204 204
205static inline void superio_outw(int val, int reg) 205static inline void superio_outw(int val, int reg)
206{ 206{
207 outb(reg++, REG); 207 outb(reg++, REG);
208 outb(val >> 8, VAL); 208 outb(val >> 8, VAL);
209 outb(reg, REG); 209 outb(reg, REG);
210 outb(val, VAL); 210 outb(val, VAL);
211} 211}
212 212
213/* watchdog timer handling */ 213/* watchdog timer handling */
diff --git a/drivers/watchdog/mpc5200_wdt.c b/drivers/watchdog/mpc5200_wdt.c
index db91892558f2..465fe36adad4 100644
--- a/drivers/watchdog/mpc5200_wdt.c
+++ b/drivers/watchdog/mpc5200_wdt.c
@@ -9,8 +9,8 @@
9#include <asm/mpc52xx.h> 9#include <asm/mpc52xx.h>
10 10
11 11
12#define GPT_MODE_WDT (1<<15) 12#define GPT_MODE_WDT (1 << 15)
13#define GPT_MODE_CE (1<<12) 13#define GPT_MODE_CE (1 << 12)
14#define GPT_MODE_MS_TIMER (0x4) 14#define GPT_MODE_MS_TIMER (0x4)
15 15
16 16
diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c
index 1130ad697ce2..1512ab8b175b 100644
--- a/drivers/watchdog/mpcore_wdt.c
+++ b/drivers/watchdog/mpcore_wdt.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Based on the SoftDog driver: 6 * Based on the SoftDog driver:
7 * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>, 7 * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>,
8 * All Rights Reserved. 8 * All Rights Reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index 3acce623f209..539b6f6ba7f1 100644
--- a/drivers/watchdog/mtx-1_wdt.c
+++ b/drivers/watchdog/mtx-1_wdt.c
@@ -5,7 +5,7 @@
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * http://www.4g-systems.biz 6 * http://www.4g-systems.biz
7 * 7 *
8 * (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org> 8 * (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org>
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
diff --git a/drivers/watchdog/orion5x_wdt.c b/drivers/watchdog/orion5x_wdt.c
index b64ae1a17832..e81441f103dd 100644
--- a/drivers/watchdog/orion5x_wdt.c
+++ b/drivers/watchdog/orion5x_wdt.c
@@ -16,11 +16,13 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/miscdevice.h> 18#include <linux/miscdevice.h>
19#include <linux/platform_device.h>
19#include <linux/watchdog.h> 20#include <linux/watchdog.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/uaccess.h> 22#include <linux/uaccess.h>
22#include <linux/io.h> 23#include <linux/io.h>
23#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <plat/orion5x_wdt.h>
24 26
25/* 27/*
26 * Watchdog timer block registers. 28 * Watchdog timer block registers.
@@ -29,13 +31,14 @@
29#define WDT_EN 0x0010 31#define WDT_EN 0x0010
30#define WDT_VAL (TIMER_VIRT_BASE + 0x0024) 32#define WDT_VAL (TIMER_VIRT_BASE + 0x0024)
31 33
32#define ORION5X_TCLK 166666667 34#define WDT_MAX_CYCLE_COUNT 0xffffffff
33#define WDT_MAX_DURATION (0xffffffff / ORION5X_TCLK)
34#define WDT_IN_USE 0 35#define WDT_IN_USE 0
35#define WDT_OK_TO_CLOSE 1 36#define WDT_OK_TO_CLOSE 1
36 37
37static int nowayout = WATCHDOG_NOWAYOUT; 38static int nowayout = WATCHDOG_NOWAYOUT;
38static int heartbeat = WDT_MAX_DURATION; /* (seconds) */ 39static int heartbeat = -1; /* module parameter (seconds) */
40static unsigned int wdt_max_duration; /* (seconds) */
41static unsigned int wdt_tclk;
39static unsigned long wdt_status; 42static unsigned long wdt_status;
40static spinlock_t wdt_lock; 43static spinlock_t wdt_lock;
41 44
@@ -46,7 +49,7 @@ static void wdt_enable(void)
46 spin_lock(&wdt_lock); 49 spin_lock(&wdt_lock);
47 50
48 /* Set watchdog duration */ 51 /* Set watchdog duration */
49 writel(ORION5X_TCLK * heartbeat, WDT_VAL); 52 writel(wdt_tclk * heartbeat, WDT_VAL);
50 53
51 /* Clear watchdog timer interrupt */ 54 /* Clear watchdog timer interrupt */
52 reg = readl(BRIDGE_CAUSE); 55 reg = readl(BRIDGE_CAUSE);
@@ -88,7 +91,7 @@ static void wdt_disable(void)
88static int orion5x_wdt_get_timeleft(int *time_left) 91static int orion5x_wdt_get_timeleft(int *time_left)
89{ 92{
90 spin_lock(&wdt_lock); 93 spin_lock(&wdt_lock);
91 *time_left = readl(WDT_VAL) / ORION5X_TCLK; 94 *time_left = readl(WDT_VAL) / wdt_tclk;
92 spin_unlock(&wdt_lock); 95 spin_unlock(&wdt_lock);
93 return 0; 96 return 0;
94} 97}
@@ -158,7 +161,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
158 if (ret) 161 if (ret)
159 break; 162 break;
160 163
161 if (time <= 0 || time > WDT_MAX_DURATION) { 164 if (time <= 0 || time > wdt_max_duration) {
162 ret = -EINVAL; 165 ret = -EINVAL;
163 break; 166 break;
164 } 167 }
@@ -210,23 +213,69 @@ static struct miscdevice orion5x_wdt_miscdev = {
210 .fops = &orion5x_wdt_fops, 213 .fops = &orion5x_wdt_fops,
211}; 214};
212 215
213static int __init orion5x_wdt_init(void) 216static int __devinit orion5x_wdt_probe(struct platform_device *pdev)
214{ 217{
218 struct orion5x_wdt_platform_data *pdata = pdev->dev.platform_data;
215 int ret; 219 int ret;
216 220
217 spin_lock_init(&wdt_lock); 221 if (pdata) {
222 wdt_tclk = pdata->tclk;
223 } else {
224 printk(KERN_ERR "Orion5x Watchdog misses platform data\n");
225 return -ENODEV;
226 }
227
228 if (orion5x_wdt_miscdev.parent)
229 return -EBUSY;
230 orion5x_wdt_miscdev.parent = &pdev->dev;
231
232 wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk;
233 if (heartbeat <= 0 || heartbeat > wdt_max_duration)
234 heartbeat = wdt_max_duration;
218 235
219 ret = misc_register(&orion5x_wdt_miscdev); 236 ret = misc_register(&orion5x_wdt_miscdev);
220 if (ret == 0) 237 if (ret)
221 printk("Orion5x Watchdog Timer: heartbeat %d sec\n", 238 return ret;
222 heartbeat); 239
240 printk(KERN_INFO "Orion5x Watchdog Timer: Initial timeout %d sec%s\n",
241 heartbeat, nowayout ? ", nowayout" : "");
242 return 0;
243}
244
245static int __devexit orion5x_wdt_remove(struct platform_device *pdev)
246{
247 int ret;
248
249 if (test_bit(WDT_IN_USE, &wdt_status)) {
250 wdt_disable();
251 clear_bit(WDT_IN_USE, &wdt_status);
252 }
253
254 ret = misc_deregister(&orion5x_wdt_miscdev);
255 if (!ret)
256 orion5x_wdt_miscdev.parent = NULL;
223 257
224 return ret; 258 return ret;
225} 259}
226 260
261static struct platform_driver orion5x_wdt_driver = {
262 .probe = orion5x_wdt_probe,
263 .remove = __devexit_p(orion5x_wdt_remove),
264 .driver = {
265 .owner = THIS_MODULE,
266 .name = "orion5x_wdt",
267 },
268};
269
270static int __init orion5x_wdt_init(void)
271{
272 spin_lock_init(&wdt_lock);
273 return platform_driver_register(&orion5x_wdt_driver);
274}
275
227static void __exit orion5x_wdt_exit(void) 276static void __exit orion5x_wdt_exit(void)
228{ 277{
229 misc_deregister(&orion5x_wdt_miscdev); 278 platform_driver_unregister(&orion5x_wdt_driver);
230} 279}
231 280
232module_init(orion5x_wdt_init); 281module_init(orion5x_wdt_init);
@@ -236,8 +285,7 @@ MODULE_AUTHOR("Sylver Bruneau <sylver.bruneau@googlemail.com>");
236MODULE_DESCRIPTION("Orion5x Processor Watchdog"); 285MODULE_DESCRIPTION("Orion5x Processor Watchdog");
237 286
238module_param(heartbeat, int, 0); 287module_param(heartbeat, int, 0);
239MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default is " 288MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds");
240 __MODULE_STRING(WDT_MAX_DURATION) ")");
241 289
242module_param(nowayout, int, 0); 290module_param(nowayout, int, 0);
243MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); 291MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
diff --git a/drivers/watchdog/pc87413_wdt.c b/drivers/watchdog/pc87413_wdt.c
index 484c215e9f3f..1a2b916e3f8d 100644
--- a/drivers/watchdog/pc87413_wdt.c
+++ b/drivers/watchdog/pc87413_wdt.c
@@ -536,7 +536,8 @@ static int __init pc87413_init(void)
536 536
537 ret = misc_register(&pc87413_miscdev); 537 ret = misc_register(&pc87413_miscdev);
538 if (ret != 0) { 538 if (ret != 0) {
539 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 539 printk(KERN_ERR PFX
540 "cannot register miscdev on minor=%d (err=%d)\n",
540 WATCHDOG_MINOR, ret); 541 WATCHDOG_MINOR, ret);
541 unregister_reboot_notifier(&pc87413_notifier); 542 unregister_reboot_notifier(&pc87413_notifier);
542 return ret; 543 return ret;
@@ -574,7 +575,8 @@ static void __exit pc87413_exit(void)
574module_init(pc87413_init); 575module_init(pc87413_init);
575module_exit(pc87413_exit); 576module_exit(pc87413_exit);
576 577
577MODULE_AUTHOR("Sven Anders <anders@anduras.de>, Marcus Junker <junker@anduras.de>,"); 578MODULE_AUTHOR("Sven Anders <anders@anduras.de>, "
579 "Marcus Junker <junker@anduras.de>,");
578MODULE_DESCRIPTION("PC87413 WDT driver"); 580MODULE_DESCRIPTION("PC87413 WDT driver");
579MODULE_LICENSE("GPL"); 581MODULE_LICENSE("GPL");
580 582
diff --git a/drivers/watchdog/pcwd.c b/drivers/watchdog/pcwd.c
index 9e1331a3b215..aa9512321f3a 100644
--- a/drivers/watchdog/pcwd.c
+++ b/drivers/watchdog/pcwd.c
@@ -24,25 +24,25 @@
24 * version reporting. Added read routine for temperature. 24 * version reporting. Added read routine for temperature.
25 * Removed some extra defines, added an autodetect Revision 25 * Removed some extra defines, added an autodetect Revision
26 * routine. 26 * routine.
27 * 961006 Revised some documentation, fixed some cosmetic bugs. Made 27 * 961006 Revised some documentation, fixed some cosmetic bugs. Made
28 * drivers to panic the system if it's overheating at bootup. 28 * drivers to panic the system if it's overheating at bootup.
29 * 961118 Changed some verbiage on some of the output, tidied up 29 * 961118 Changed some verbiage on some of the output, tidied up
30 * code bits, and added compatibility to 2.1.x. 30 * code bits, and added compatibility to 2.1.x.
31 * 970912 Enabled board on open and disable on close. 31 * 970912 Enabled board on open and disable on close.
32 * 971107 Took account of recent VFS changes (broke read). 32 * 971107 Took account of recent VFS changes (broke read).
33 * 971210 Disable board on initialisation in case board already ticking. 33 * 971210 Disable board on initialisation in case board already ticking.
34 * 971222 Changed open/close for temperature handling 34 * 971222 Changed open/close for temperature handling
35 * Michael Meskes <meskes@debian.org>. 35 * Michael Meskes <meskes@debian.org>.
36 * 980112 Used minor numbers from include/linux/miscdevice.h 36 * 980112 Used minor numbers from include/linux/miscdevice.h
37 * 990403 Clear reset status after reading control status register in 37 * 990403 Clear reset status after reading control status register in
38 * pcwd_showprevstate(). [Marc Boucher <marc@mbsi.ca>] 38 * pcwd_showprevstate(). [Marc Boucher <marc@mbsi.ca>]
39 * 990605 Made changes to code to support Firmware 1.22a, added 39 * 990605 Made changes to code to support Firmware 1.22a, added
40 * fairly useless proc entry. 40 * fairly useless proc entry.
41 * 990610 removed said useless proc code for the merge <alan> 41 * 990610 removed said useless proc code for the merge <alan>
42 * 000403 Removed last traces of proc code. <davej> 42 * 000403 Removed last traces of proc code. <davej>
43 * 011214 Added nowayout module option to override 43 * 011214 Added nowayout module option to override
44 * CONFIG_WATCHDOG_NOWAYOUT <Matt_Domsch@dell.com> 44 * CONFIG_WATCHDOG_NOWAYOUT <Matt_Domsch@dell.com>
45 * Added timeout module option to override default 45 * Added timeout module option to override default
46 */ 46 */
47 47
48/* 48/*
@@ -76,8 +76,7 @@
76#define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" 76#define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog"
77#define WATCHDOG_NAME "pcwd" 77#define WATCHDOG_NAME "pcwd"
78#define PFX WATCHDOG_NAME ": " 78#define PFX WATCHDOG_NAME ": "
79#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n" 79#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION "\n"
80#define WD_VER WATCHDOG_VERSION " (" WATCHDOG_DATE ")"
81 80
82/* 81/*
83 * It should be noted that PCWD_REVISION_B was removed because A and B 82 * It should be noted that PCWD_REVISION_B was removed because A and B
@@ -200,7 +199,9 @@ MODULE_PARM_DESC(debug,
200#define WATCHDOG_HEARTBEAT 0 199#define WATCHDOG_HEARTBEAT 0
201static int heartbeat = WATCHDOG_HEARTBEAT; 200static int heartbeat = WATCHDOG_HEARTBEAT;
202module_param(heartbeat, int, 0); 201module_param(heartbeat, int, 0);
203MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2 <= heartbeat <= 7200 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); 202MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
203 "(2 <= heartbeat <= 7200 or 0=delay-time from dip-switches, default="
204 __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
204 205
205static int nowayout = WATCHDOG_NOWAYOUT; 206static int nowayout = WATCHDOG_NOWAYOUT;
206module_param(nowayout, int, 0); 207module_param(nowayout, int, 0);
@@ -239,7 +240,8 @@ static int send_isa_command(int cmd)
239 } 240 }
240 241
241 if (debug >= DEBUG) 242 if (debug >= DEBUG)
242 printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n", 243 printk(KERN_DEBUG PFX "received following data for "
244 "cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n",
243 cmd, port0, last_port0); 245 cmd, port0, last_port0);
244 246
245 return port0; 247 return port0;
@@ -339,10 +341,12 @@ static void pcwd_show_card_info(void)
339 pcwd_private.io_addr); 341 pcwd_private.io_addr);
340 else if (pcwd_private.revision == PCWD_REVISION_C) { 342 else if (pcwd_private.revision == PCWD_REVISION_C) {
341 pcwd_get_firmware(); 343 pcwd_get_firmware();
342 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n", 344 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port "
345 "0x%04x (Firmware version: %s)\n",
343 pcwd_private.io_addr, pcwd_private.fw_ver_str); 346 pcwd_private.io_addr, pcwd_private.fw_ver_str);
344 option_switches = pcwd_get_option_switches(); 347 option_switches = pcwd_get_option_switches();
345 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", 348 printk(KERN_INFO PFX "Option switches (0x%02x): "
349 "Temperature Reset Enable=%s, Power On Delay=%s\n",
346 option_switches, 350 option_switches,
347 ((option_switches & 0x10) ? "ON" : "OFF"), 351 ((option_switches & 0x10) ? "ON" : "OFF"),
348 ((option_switches & 0x08) ? "ON" : "OFF")); 352 ((option_switches & 0x08) ? "ON" : "OFF"));
@@ -358,7 +362,8 @@ static void pcwd_show_card_info(void)
358 printk(KERN_INFO PFX "Temperature Option Detected\n"); 362 printk(KERN_INFO PFX "Temperature Option Detected\n");
359 363
360 if (pcwd_private.boot_status & WDIOF_CARDRESET) 364 if (pcwd_private.boot_status & WDIOF_CARDRESET)
361 printk(KERN_INFO PFX "Previous reboot was caused by the card\n"); 365 printk(KERN_INFO PFX
366 "Previous reboot was caused by the card\n");
362 367
363 if (pcwd_private.boot_status & WDIOF_OVERHEAT) { 368 if (pcwd_private.boot_status & WDIOF_OVERHEAT) {
364 printk(KERN_EMERG PFX 369 printk(KERN_EMERG PFX
@@ -871,7 +876,7 @@ static int __devinit pcwd_isa_probe(struct device *dev, unsigned int id)
871 cards_found++; 876 cards_found++;
872 if (cards_found == 1) 877 if (cards_found == 1)
873 printk(KERN_INFO PFX "v%s Ken Hollis (kenji@bitgate.com)\n", 878 printk(KERN_INFO PFX "v%s Ken Hollis (kenji@bitgate.com)\n",
874 WD_VER); 879 WATCHDOG_VERSION);
875 880
876 if (cards_found > 1) { 881 if (cards_found > 1) {
877 printk(KERN_ERR PFX "This driver only supports 1 device\n"); 882 printk(KERN_ERR PFX "This driver only supports 1 device\n");
@@ -1026,7 +1031,8 @@ static void __exit pcwd_cleanup_module(void)
1026module_init(pcwd_init_module); 1031module_init(pcwd_init_module);
1027module_exit(pcwd_cleanup_module); 1032module_exit(pcwd_cleanup_module);
1028 1033
1029MODULE_AUTHOR("Ken Hollis <kenji@bitgate.com>, Wim Van Sebroeck <wim@iguana.be>"); 1034MODULE_AUTHOR("Ken Hollis <kenji@bitgate.com>, "
1035 "Wim Van Sebroeck <wim@iguana.be>");
1030MODULE_DESCRIPTION("Berkshire ISA-PC Watchdog driver"); 1036MODULE_DESCRIPTION("Berkshire ISA-PC Watchdog driver");
1031MODULE_VERSION(WATCHDOG_VERSION); 1037MODULE_VERSION(WATCHDOG_VERSION);
1032MODULE_LICENSE("GPL"); 1038MODULE_LICENSE("GPL");
diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
index 5d76422c402c..698f51bff1bc 100644
--- a/drivers/watchdog/pcwd_pci.c
+++ b/drivers/watchdog/pcwd_pci.c
@@ -24,7 +24,8 @@
24 * A bells and whistles driver is available from: 24 * A bells and whistles driver is available from:
25 * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/ 25 * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/
26 * 26 *
27 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ 27 * More info available at
28 * http://www.berkprod.com/ or http://www.pcwatchdog.com/
28 */ 29 */
29 30
30/* 31/*
@@ -51,11 +52,10 @@
51 52
52/* Module and version information */ 53/* Module and version information */
53#define WATCHDOG_VERSION "1.03" 54#define WATCHDOG_VERSION "1.03"
54#define WATCHDOG_DATE "21 Jan 2007"
55#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" 55#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog"
56#define WATCHDOG_NAME "pcwd_pci" 56#define WATCHDOG_NAME "pcwd_pci"
57#define PFX WATCHDOG_NAME ": " 57#define PFX WATCHDOG_NAME ": "
58#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n" 58#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION "\n"
59 59
60/* Stuff for the PCI ID's */ 60/* Stuff for the PCI ID's */
61#ifndef PCI_VENDOR_ID_QUICKLOGIC 61#ifndef PCI_VENDOR_ID_QUICKLOGIC
@@ -76,7 +76,8 @@
76#define WD_PCI_TTRP 0x04 /* Temperature Trip status */ 76#define WD_PCI_TTRP 0x04 /* Temperature Trip status */
77#define WD_PCI_RL2A 0x08 /* Relay 2 Active */ 77#define WD_PCI_RL2A 0x08 /* Relay 2 Active */
78#define WD_PCI_RL1A 0x10 /* Relay 1 Active */ 78#define WD_PCI_RL1A 0x10 /* Relay 1 Active */
79#define WD_PCI_R2DS 0x40 /* Relay 2 Disable Temperature-trip/reset */ 79#define WD_PCI_R2DS 0x40 /* Relay 2 Disable Temperature-trip /
80 reset */
80#define WD_PCI_RLY2 0x80 /* Activate Relay 2 on the board */ 81#define WD_PCI_RLY2 0x80 /* Activate Relay 2 on the board */
81/* Port 2 : Control Status #2 */ 82/* Port 2 : Control Status #2 */
82#define WD_PCI_WDIS 0x10 /* Watchdog Disable */ 83#define WD_PCI_WDIS 0x10 /* Watchdog Disable */
@@ -114,12 +115,18 @@ static int cards_found;
114static int temp_panic; 115static int temp_panic;
115static unsigned long is_active; 116static unsigned long is_active;
116static char expect_release; 117static char expect_release;
117static struct { /* this is private data for each PCI-PC watchdog card */ 118/* this is private data for each PCI-PC watchdog card */
118 int supports_temp; /* Wether or not the card has a temperature device */ 119static struct {
119 int boot_status; /* The card's boot status */ 120 /* Wether or not the card has a temperature device */
120 unsigned long io_addr; /* The cards I/O address */ 121 int supports_temp;
121 spinlock_t io_lock; /* the lock for io operations */ 122 /* The card's boot status */
122 struct pci_dev *pdev; /* the PCI-device */ 123 int boot_status;
124 /* The cards I/O address */
125 unsigned long io_addr;
126 /* the lock for io operations */
127 spinlock_t io_lock;
128 /* the PCI-device */
129 struct pci_dev *pdev;
123} pcipcwd_private; 130} pcipcwd_private;
124 131
125/* module parameters */ 132/* module parameters */
@@ -130,14 +137,18 @@ static int debug = QUIET;
130module_param(debug, int, 0); 137module_param(debug, int, 0);
131MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); 138MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)");
132 139
133#define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ 140#define WATCHDOG_HEARTBEAT 0 /* default heartbeat =
141 delay-time from dip-switches */
134static int heartbeat = WATCHDOG_HEARTBEAT; 142static int heartbeat = WATCHDOG_HEARTBEAT;
135module_param(heartbeat, int, 0); 143module_param(heartbeat, int, 0);
136MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); 144MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
145 "(0<heartbeat<65536 or 0=delay-time from dip-switches, default="
146 __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
137 147
138static int nowayout = WATCHDOG_NOWAYOUT; 148static int nowayout = WATCHDOG_NOWAYOUT;
139module_param(nowayout, int, 0); 149module_param(nowayout, int, 0);
140MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 150MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
151 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
141 152
142/* 153/*
143 * Internal functions 154 * Internal functions
@@ -148,8 +159,8 @@ static int send_command(int cmd, int *msb, int *lsb)
148 int got_response, count; 159 int got_response, count;
149 160
150 if (debug >= DEBUG) 161 if (debug >= DEBUG)
151 printk(KERN_DEBUG PFX "sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n", 162 printk(KERN_DEBUG PFX "sending following data "
152 cmd, *msb, *lsb); 163 "cmd=0x%02x msb=0x%02x lsb=0x%02x\n", cmd, *msb, *lsb);
153 164
154 spin_lock(&pcipcwd_private.io_lock); 165 spin_lock(&pcipcwd_private.io_lock);
155 /* If a command requires data it should be written first. 166 /* If a command requires data it should be written first.
@@ -166,17 +177,20 @@ static int send_command(int cmd, int *msb, int *lsb)
166 * the WRSP bit in port 2 and give it a max. timeout of 177 * the WRSP bit in port 2 and give it a max. timeout of
167 * PCI_COMMAND_TIMEOUT to process */ 178 * PCI_COMMAND_TIMEOUT to process */
168 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; 179 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
169 for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response); count++) { 180 for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response);
181 count++) {
170 mdelay(1); 182 mdelay(1);
171 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; 183 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
172 } 184 }
173 185
174 if (debug >= DEBUG) { 186 if (debug >= DEBUG) {
175 if (got_response) { 187 if (got_response) {
176 printk(KERN_DEBUG PFX "time to process command was: %d ms\n", 188 printk(KERN_DEBUG PFX
189 "time to process command was: %d ms\n",
177 count); 190 count);
178 } else { 191 } else {
179 printk(KERN_DEBUG PFX "card did not respond on command!\n"); 192 printk(KERN_DEBUG PFX
193 "card did not respond on command!\n");
180 } 194 }
181 } 195 }
182 196
@@ -189,7 +203,8 @@ static int send_command(int cmd, int *msb, int *lsb)
189 inb_p(pcipcwd_private.io_addr + 6); 203 inb_p(pcipcwd_private.io_addr + 6);
190 204
191 if (debug >= DEBUG) 205 if (debug >= DEBUG)
192 printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n", 206 printk(KERN_DEBUG PFX "received following data for "
207 "cmd=0x%02x: msb=0x%02x lsb=0x%02x\n",
193 cmd, *msb, *lsb); 208 cmd, *msb, *lsb);
194 } 209 }
195 210
@@ -218,7 +233,8 @@ static void pcipcwd_show_card_info(void)
218 char fw_ver_str[20]; /* The cards firmware version */ 233 char fw_ver_str[20]; /* The cards firmware version */
219 int option_switches; 234 int option_switches;
220 235
221 got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor); 236 got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major,
237 &fw_rev_minor);
222 if (got_fw_rev) 238 if (got_fw_rev)
223 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor); 239 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
224 else 240 else
@@ -227,23 +243,27 @@ static void pcipcwd_show_card_info(void)
227 /* Get switch settings */ 243 /* Get switch settings */
228 option_switches = pcipcwd_get_option_switches(); 244 option_switches = pcipcwd_get_option_switches();
229 245
230 printk(KERN_INFO PFX "Found card at port 0x%04x (Firmware: %s) %s temp option\n", 246 printk(KERN_INFO PFX "Found card at port "
247 "0x%04x (Firmware: %s) %s temp option\n",
231 (int) pcipcwd_private.io_addr, fw_ver_str, 248 (int) pcipcwd_private.io_addr, fw_ver_str,
232 (pcipcwd_private.supports_temp ? "with" : "without")); 249 (pcipcwd_private.supports_temp ? "with" : "without"));
233 250
234 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", 251 printk(KERN_INFO PFX "Option switches (0x%02x): "
252 "Temperature Reset Enable=%s, Power On Delay=%s\n",
235 option_switches, 253 option_switches,
236 ((option_switches & 0x10) ? "ON" : "OFF"), 254 ((option_switches & 0x10) ? "ON" : "OFF"),
237 ((option_switches & 0x08) ? "ON" : "OFF")); 255 ((option_switches & 0x08) ? "ON" : "OFF"));
238 256
239 if (pcipcwd_private.boot_status & WDIOF_CARDRESET) 257 if (pcipcwd_private.boot_status & WDIOF_CARDRESET)
240 printk(KERN_INFO PFX "Previous reset was caused by the Watchdog card\n"); 258 printk(KERN_INFO PFX
259 "Previous reset was caused by the Watchdog card\n");
241 260
242 if (pcipcwd_private.boot_status & WDIOF_OVERHEAT) 261 if (pcipcwd_private.boot_status & WDIOF_OVERHEAT)
243 printk(KERN_INFO PFX "Card sensed a CPU Overheat\n"); 262 printk(KERN_INFO PFX "Card sensed a CPU Overheat\n");
244 263
245 if (pcipcwd_private.boot_status == 0) 264 if (pcipcwd_private.boot_status == 0)
246 printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n"); 265 printk(KERN_INFO PFX
266 "No previous trip detected - Cold boot or reset\n");
247} 267}
248 268
249static int pcipcwd_start(void) 269static int pcipcwd_start(void)
@@ -283,7 +303,8 @@ static int pcipcwd_stop(void)
283 spin_unlock(&pcipcwd_private.io_lock); 303 spin_unlock(&pcipcwd_private.io_lock);
284 304
285 if (!(stat_reg & WD_PCI_WDIS)) { 305 if (!(stat_reg & WD_PCI_WDIS)) {
286 printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n"); 306 printk(KERN_ERR PFX
307 "Card did not acknowledge disable attempt\n");
287 return -1; 308 return -1;
288 } 309 }
289 310
@@ -364,7 +385,8 @@ static int pcipcwd_clear_status(void)
364 } 385 }
365 386
366 /* clear trip status & LED and keep mode of relay 2 */ 387 /* clear trip status & LED and keep mode of relay 2 */
367 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1); 388 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP,
389 pcipcwd_private.io_addr + 1);
368 390
369 /* clear reset counter */ 391 /* clear reset counter */
370 msb = 0; 392 msb = 0;
@@ -437,7 +459,8 @@ static ssize_t pcipcwd_write(struct file *file, const char __user *data,
437 * five months ago... */ 459 * five months ago... */
438 expect_release = 0; 460 expect_release = 0;
439 461
440 /* scan to see whether or not we got the magic character */ 462 /* scan to see whether or not we got the
463 * magic character */
441 for (i = 0; i != len; i++) { 464 for (i = 0; i != len; i++) {
442 char c; 465 char c;
443 if (get_user(c, data + i)) 466 if (get_user(c, data + i))
@@ -531,7 +554,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
531 return -EFAULT; 554 return -EFAULT;
532 555
533 if (pcipcwd_set_heartbeat(new_heartbeat)) 556 if (pcipcwd_set_heartbeat(new_heartbeat))
534 return -EINVAL; 557 return -EINVAL;
535 558
536 pcipcwd_keepalive(); 559 pcipcwd_keepalive();
537 /* Fall */ 560 /* Fall */
@@ -560,7 +583,8 @@ static int pcipcwd_open(struct inode *inode, struct file *file)
560 /* /dev/watchdog can only be opened once */ 583 /* /dev/watchdog can only be opened once */
561 if (test_and_set_bit(0, &is_active)) { 584 if (test_and_set_bit(0, &is_active)) {
562 if (debug >= VERBOSE) 585 if (debug >= VERBOSE)
563 printk(KERN_ERR PFX "Attempt to open already opened device.\n"); 586 printk(KERN_ERR PFX
587 "Attempt to open already opened device.\n");
564 return -EBUSY; 588 return -EBUSY;
565 } 589 }
566 590
@@ -578,7 +602,8 @@ static int pcipcwd_release(struct inode *inode, struct file *file)
578 if (expect_release == 42) { 602 if (expect_release == 42) {
579 pcipcwd_stop(); 603 pcipcwd_stop();
580 } else { 604 } else {
581 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); 605 printk(KERN_CRIT PFX
606 "Unexpected close, not stopping watchdog!\n");
582 pcipcwd_keepalive(); 607 pcipcwd_keepalive();
583 } 608 }
584 expect_release = 0; 609 expect_release = 0;
@@ -621,7 +646,8 @@ static int pcipcwd_temp_release(struct inode *inode, struct file *file)
621 * Notify system 646 * Notify system
622 */ 647 */
623 648
624static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) 649static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code,
650 void *unused)
625{ 651{
626 if (code == SYS_DOWN || code == SYS_HALT) 652 if (code == SYS_DOWN || code == SYS_HALT)
627 pcipcwd_stop(); /* Turn the WDT off */ 653 pcipcwd_stop(); /* Turn the WDT off */
@@ -722,34 +748,38 @@ static int __devinit pcipcwd_card_init(struct pci_dev *pdev,
722 748
723 /* If heartbeat = 0 then we use the heartbeat from the dip-switches */ 749 /* If heartbeat = 0 then we use the heartbeat from the dip-switches */
724 if (heartbeat == 0) 750 if (heartbeat == 0)
725 heartbeat = heartbeat_tbl[(pcipcwd_get_option_switches() & 0x07)]; 751 heartbeat =
752 heartbeat_tbl[(pcipcwd_get_option_switches() & 0x07)];
726 753
727 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 754 /* Check that the heartbeat value is within it's range ;
755 * if not reset to the default */
728 if (pcipcwd_set_heartbeat(heartbeat)) { 756 if (pcipcwd_set_heartbeat(heartbeat)) {
729 pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT); 757 pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT);
730 printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n", 758 printk(KERN_INFO PFX
759 "heartbeat value must be 0<heartbeat<65536, using %d\n",
731 WATCHDOG_HEARTBEAT); 760 WATCHDOG_HEARTBEAT);
732 } 761 }
733 762
734 ret = register_reboot_notifier(&pcipcwd_notifier); 763 ret = register_reboot_notifier(&pcipcwd_notifier);
735 if (ret != 0) { 764 if (ret != 0) {
736 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", 765 printk(KERN_ERR PFX
737 ret); 766 "cannot register reboot notifier (err=%d)\n", ret);
738 goto err_out_release_region; 767 goto err_out_release_region;
739 } 768 }
740 769
741 if (pcipcwd_private.supports_temp) { 770 if (pcipcwd_private.supports_temp) {
742 ret = misc_register(&pcipcwd_temp_miscdev); 771 ret = misc_register(&pcipcwd_temp_miscdev);
743 if (ret != 0) { 772 if (ret != 0) {
744 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 773 printk(KERN_ERR PFX "cannot register miscdev on "
745 TEMP_MINOR, ret); 774 "minor=%d (err=%d)\n", TEMP_MINOR, ret);
746 goto err_out_unregister_reboot; 775 goto err_out_unregister_reboot;
747 } 776 }
748 } 777 }
749 778
750 ret = misc_register(&pcipcwd_miscdev); 779 ret = misc_register(&pcipcwd_miscdev);
751 if (ret != 0) { 780 if (ret != 0) {
752 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 781 printk(KERN_ERR PFX
782 "cannot register miscdev on minor=%d (err=%d)\n",
753 WATCHDOG_MINOR, ret); 783 WATCHDOG_MINOR, ret);
754 goto err_out_misc_deregister; 784 goto err_out_misc_deregister;
755 } 785 }
diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index afb089695da8..052fe451851f 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -51,12 +51,11 @@
51 51
52/* Use our own dbg macro */ 52/* Use our own dbg macro */
53#undef dbg 53#undef dbg
54#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG PFX format "\n" , ## arg); } while (0) 54#define dbg(format, arg...) \
55 55 do { if (debug) printk(KERN_DEBUG PFX format "\n" , ## arg); } while (0)
56 56
57/* Module and Version Information */ 57/* Module and Version Information */
58#define DRIVER_VERSION "1.02" 58#define DRIVER_VERSION "1.02"
59#define DRIVER_DATE "21 Jan 2007"
60#define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>" 59#define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>"
61#define DRIVER_DESC "Berkshire USB-PC Watchdog driver" 60#define DRIVER_DESC "Berkshire USB-PC Watchdog driver"
62#define DRIVER_LICENSE "GPL" 61#define DRIVER_LICENSE "GPL"
@@ -73,14 +72,18 @@ MODULE_ALIAS_MISCDEV(TEMP_MINOR);
73module_param(debug, int, 0); 72module_param(debug, int, 0);
74MODULE_PARM_DESC(debug, "Debug enabled or not"); 73MODULE_PARM_DESC(debug, "Debug enabled or not");
75 74
76#define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ 75#define WATCHDOG_HEARTBEAT 0 /* default heartbeat =
76 delay-time from dip-switches */
77static int heartbeat = WATCHDOG_HEARTBEAT; 77static int heartbeat = WATCHDOG_HEARTBEAT;
78module_param(heartbeat, int, 0); 78module_param(heartbeat, int, 0);
79MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); 79MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
80 "(0<heartbeat<65536 or 0=delay-time from dip-switches, default="
81 __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
80 82
81static int nowayout = WATCHDOG_NOWAYOUT; 83static int nowayout = WATCHDOG_NOWAYOUT;
82module_param(nowayout, int, 0); 84module_param(nowayout, int, 0);
83MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 85MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
86 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
84 87
85/* The vendor and product id's for the USB-PC Watchdog card */ 88/* The vendor and product id's for the USB-PC Watchdog card */
86#define USB_PCWD_VENDOR_ID 0x0c98 89#define USB_PCWD_VENDOR_ID 0x0c98
@@ -91,20 +94,21 @@ static struct usb_device_id usb_pcwd_table[] = {
91 { USB_DEVICE(USB_PCWD_VENDOR_ID, USB_PCWD_PRODUCT_ID) }, 94 { USB_DEVICE(USB_PCWD_VENDOR_ID, USB_PCWD_PRODUCT_ID) },
92 { } /* Terminating entry */ 95 { } /* Terminating entry */
93}; 96};
94MODULE_DEVICE_TABLE (usb, usb_pcwd_table); 97MODULE_DEVICE_TABLE(usb, usb_pcwd_table);
95 98
96/* according to documentation max. time to process a command for the USB 99/* according to documentation max. time to process a command for the USB
97 * watchdog card is 100 or 200 ms, so we give it 250 ms to do it's job */ 100 * watchdog card is 100 or 200 ms, so we give it 250 ms to do it's job */
98#define USB_COMMAND_TIMEOUT 250 101#define USB_COMMAND_TIMEOUT 250
99 102
100/* Watchdog's internal commands */ 103/* Watchdog's internal commands */
101#define CMD_READ_TEMP 0x02 /* Read Temperature; Re-trigger Watchdog */ 104#define CMD_READ_TEMP 0x02 /* Read Temperature;
105 Re-trigger Watchdog */
102#define CMD_TRIGGER CMD_READ_TEMP 106#define CMD_TRIGGER CMD_READ_TEMP
103#define CMD_GET_STATUS 0x04 /* Get Status Information */ 107#define CMD_GET_STATUS 0x04 /* Get Status Information */
104#define CMD_GET_FIRMWARE_VERSION 0x08 /* Get Firmware Version */ 108#define CMD_GET_FIRMWARE_VERSION 0x08 /* Get Firmware Version */
105#define CMD_GET_DIP_SWITCH_SETTINGS 0x0c /* Get Dip Switch Settings */ 109#define CMD_GET_DIP_SWITCH_SETTINGS 0x0c /* Get Dip Switch Settings */
106#define CMD_READ_WATCHDOG_TIMEOUT 0x18 /* Read Current Watchdog Time */ 110#define CMD_READ_WATCHDOG_TIMEOUT 0x18 /* Read Current Watchdog Time */
107#define CMD_WRITE_WATCHDOG_TIMEOUT 0x19 /* Write Current Watchdog Time */ 111#define CMD_WRITE_WATCHDOG_TIMEOUT 0x19 /* Write Current WatchdogTime */
108#define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */ 112#define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */
109#define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG 113#define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG
110 114
@@ -129,23 +133,36 @@ static char expect_release;
129 133
130/* Structure to hold all of our device specific stuff */ 134/* Structure to hold all of our device specific stuff */
131struct usb_pcwd_private { 135struct usb_pcwd_private {
132 struct usb_device *udev; /* save off the usb device pointer */ 136 /* save off the usb device pointer */
133 struct usb_interface *interface; /* the interface for this device */ 137 struct usb_device *udev;
134 138 /* the interface for this device */
135 unsigned int interface_number; /* the interface number used for cmd's */ 139 struct usb_interface *interface;
136 140
137 unsigned char *intr_buffer; /* the buffer to intr data */ 141 /* the interface number used for cmd's */
138 dma_addr_t intr_dma; /* the dma address for the intr buffer */ 142 unsigned int interface_number;
139 size_t intr_size; /* the size of the intr buffer */ 143
140 struct urb *intr_urb; /* the urb used for the intr pipe */ 144 /* the buffer to intr data */
141 145 unsigned char *intr_buffer;
142 unsigned char cmd_command; /* The command that is reported back */ 146 /* the dma address for the intr buffer */
143 unsigned char cmd_data_msb; /* The data MSB that is reported back */ 147 dma_addr_t intr_dma;
144 unsigned char cmd_data_lsb; /* The data LSB that is reported back */ 148 /* the size of the intr buffer */
145 atomic_t cmd_received; /* true if we received a report after a command */ 149 size_t intr_size;
146 150 /* the urb used for the intr pipe */
147 int exists; /* Wether or not the device exists */ 151 struct urb *intr_urb;
148 struct mutex mtx; /* locks this structure */ 152
153 /* The command that is reported back */
154 unsigned char cmd_command;
155 /* The data MSB that is reported back */
156 unsigned char cmd_data_msb;
157 /* The data LSB that is reported back */
158 unsigned char cmd_data_lsb;
159 /* true if we received a report after a command */
160 atomic_t cmd_received;
161
162 /* Wether or not the device exists */
163 int exists;
164 /* locks this structure */
165 struct mutex mtx;
149}; 166};
150static struct usb_pcwd_private *usb_pcwd_device; 167static struct usb_pcwd_private *usb_pcwd_device;
151 168
@@ -153,7 +170,8 @@ static struct usb_pcwd_private *usb_pcwd_device;
153static DEFINE_MUTEX(disconnect_mutex); 170static DEFINE_MUTEX(disconnect_mutex);
154 171
155/* local function prototypes */ 172/* local function prototypes */
156static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_device_id *id); 173static int usb_pcwd_probe(struct usb_interface *interface,
174 const struct usb_device_id *id);
157static void usb_pcwd_disconnect(struct usb_interface *interface); 175static void usb_pcwd_disconnect(struct usb_interface *interface);
158 176
159/* usb specific object needed to register this driver with the usb subsystem */ 177/* usb specific object needed to register this driver with the usb subsystem */
@@ -167,7 +185,8 @@ static struct usb_driver usb_pcwd_driver = {
167 185
168static void usb_pcwd_intr_done(struct urb *urb) 186static void usb_pcwd_intr_done(struct urb *urb)
169{ 187{
170 struct usb_pcwd_private *usb_pcwd = (struct usb_pcwd_private *)urb->context; 188 struct usb_pcwd_private *usb_pcwd =
189 (struct usb_pcwd_private *)urb->context;
171 unsigned char *data = usb_pcwd->intr_buffer; 190 unsigned char *data = usb_pcwd->intr_buffer;
172 int retval; 191 int retval;
173 192
@@ -178,11 +197,13 @@ static void usb_pcwd_intr_done(struct urb *urb)
178 case -ENOENT: 197 case -ENOENT:
179 case -ESHUTDOWN: 198 case -ESHUTDOWN:
180 /* this urb is terminated, clean up */ 199 /* this urb is terminated, clean up */
181 dbg("%s - urb shutting down with status: %d", __func__, urb->status); 200 dbg("%s - urb shutting down with status: %d", __func__,
201 urb->status);
182 return; 202 return;
183 /* -EPIPE: should clear the halt */ 203 /* -EPIPE: should clear the halt */
184 default: /* error */ 204 default: /* error */
185 dbg("%s - nonzero urb status received: %d", __func__, urb->status); 205 dbg("%s - nonzero urb status received: %d", __func__,
206 urb->status);
186 goto resubmit; 207 goto resubmit;
187 } 208 }
188 209
@@ -199,22 +220,23 @@ static void usb_pcwd_intr_done(struct urb *urb)
199resubmit: 220resubmit:
200 retval = usb_submit_urb(urb, GFP_ATOMIC); 221 retval = usb_submit_urb(urb, GFP_ATOMIC);
201 if (retval) 222 if (retval)
202 printk(KERN_ERR PFX "can't resubmit intr, usb_submit_urb failed with result %d\n", 223 printk(KERN_ERR PFX "can't resubmit intr, "
203 retval); 224 "usb_submit_urb failed with result %d\n", retval);
204} 225}
205 226
206static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, unsigned char cmd, 227static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
207 unsigned char *msb, unsigned char *lsb) 228 unsigned char cmd, unsigned char *msb, unsigned char *lsb)
208{ 229{
209 int got_response, count; 230 int got_response, count;
210 unsigned char buf[6]; 231 unsigned char buf[6];
211 232
212 /* We will not send any commands if the USB PCWD device does not exist */ 233 /* We will not send any commands if the USB PCWD device does
234 * not exist */
213 if ((!usb_pcwd) || (!usb_pcwd->exists)) 235 if ((!usb_pcwd) || (!usb_pcwd->exists))
214 return -1; 236 return -1;
215 237
216 /* The USB PC Watchdog uses a 6 byte report format. The board currently uses 238 /* The USB PC Watchdog uses a 6 byte report format.
217 * only 3 of the six bytes of the report. */ 239 * The board currently uses only 3 of the six bytes of the report. */
218 buf[0] = cmd; /* Byte 0 = CMD */ 240 buf[0] = cmd; /* Byte 0 = CMD */
219 buf[1] = *msb; /* Byte 1 = Data MSB */ 241 buf[1] = *msb; /* Byte 1 = Data MSB */
220 buf[2] = *lsb; /* Byte 2 = Data LSB */ 242 buf[2] = *lsb; /* Byte 2 = Data LSB */
@@ -229,12 +251,14 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, unsigned cha
229 HID_REQ_SET_REPORT, HID_DT_REPORT, 251 HID_REQ_SET_REPORT, HID_DT_REPORT,
230 0x0200, usb_pcwd->interface_number, buf, sizeof(buf), 252 0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
231 USB_COMMAND_TIMEOUT) != sizeof(buf)) { 253 USB_COMMAND_TIMEOUT) != sizeof(buf)) {
232 dbg("usb_pcwd_send_command: error in usb_control_msg for cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb); 254 dbg("usb_pcwd_send_command: error in usb_control_msg for "
255 "cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb);
233 } 256 }
234 /* wait till the usb card processed the command, 257 /* wait till the usb card processed the command,
235 * with a max. timeout of USB_COMMAND_TIMEOUT */ 258 * with a max. timeout of USB_COMMAND_TIMEOUT */
236 got_response = 0; 259 got_response = 0;
237 for (count = 0; (count < USB_COMMAND_TIMEOUT) && (!got_response); count++) { 260 for (count = 0; (count < USB_COMMAND_TIMEOUT) && (!got_response);
261 count++) {
238 mdelay(1); 262 mdelay(1);
239 if (atomic_read(&usb_pcwd->cmd_received)) 263 if (atomic_read(&usb_pcwd->cmd_received))
240 got_response = 1; 264 got_response = 1;
@@ -256,10 +280,12 @@ static int usb_pcwd_start(struct usb_pcwd_private *usb_pcwd)
256 int retval; 280 int retval;
257 281
258 /* Enable Watchdog */ 282 /* Enable Watchdog */
259 retval = usb_pcwd_send_command(usb_pcwd, CMD_ENABLE_WATCHDOG, &msb, &lsb); 283 retval = usb_pcwd_send_command(usb_pcwd, CMD_ENABLE_WATCHDOG,
284 &msb, &lsb);
260 285
261 if ((retval == 0) || (lsb == 0)) { 286 if ((retval == 0) || (lsb == 0)) {
262 printk(KERN_ERR PFX "Card did not acknowledge enable attempt\n"); 287 printk(KERN_ERR PFX
288 "Card did not acknowledge enable attempt\n");
263 return -1; 289 return -1;
264 } 290 }
265 291
@@ -273,10 +299,12 @@ static int usb_pcwd_stop(struct usb_pcwd_private *usb_pcwd)
273 int retval; 299 int retval;
274 300
275 /* Disable Watchdog */ 301 /* Disable Watchdog */
276 retval = usb_pcwd_send_command(usb_pcwd, CMD_DISABLE_WATCHDOG, &msb, &lsb); 302 retval = usb_pcwd_send_command(usb_pcwd, CMD_DISABLE_WATCHDOG,
303 &msb, &lsb);
277 304
278 if ((retval == 0) || (lsb != 0)) { 305 if ((retval == 0) || (lsb != 0)) {
279 printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n"); 306 printk(KERN_ERR PFX
307 "Card did not acknowledge disable attempt\n");
280 return -1; 308 return -1;
281 } 309 }
282 310
@@ -308,7 +336,8 @@ static int usb_pcwd_set_heartbeat(struct usb_pcwd_private *usb_pcwd, int t)
308 return 0; 336 return 0;
309} 337}
310 338
311static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temperature) 339static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd,
340 int *temperature)
312{ 341{
313 unsigned char msb, lsb; 342 unsigned char msb, lsb;
314 343
@@ -323,7 +352,8 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temp
323 return 0; 352 return 0;
324} 353}
325 354
326static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_left) 355static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd,
356 int *time_left)
327{ 357{
328 unsigned char msb, lsb; 358 unsigned char msb, lsb;
329 359
@@ -341,7 +371,7 @@ static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_le
341 */ 371 */
342 372
343static ssize_t usb_pcwd_write(struct file *file, const char __user *data, 373static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
344 size_t len, loff_t *ppos) 374 size_t len, loff_t *ppos)
345{ 375{
346 /* See if we got the magic character 'V' and reload the timer */ 376 /* See if we got the magic character 'V' and reload the timer */
347 if (len) { 377 if (len) {
@@ -352,7 +382,8 @@ static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
352 * five months ago... */ 382 * five months ago... */
353 expect_release = 0; 383 expect_release = 0;
354 384
355 /* scan to see whether or not we got the magic character */ 385 /* scan to see whether or not we got the
386 * magic character */
356 for (i = 0; i != len; i++) { 387 for (i = 0; i != len; i++) {
357 char c; 388 char c;
358 if (get_user(c, data + i)) 389 if (get_user(c, data + i))
@@ -431,7 +462,7 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd,
431 return -EFAULT; 462 return -EFAULT;
432 463
433 if (usb_pcwd_set_heartbeat(usb_pcwd_device, new_heartbeat)) 464 if (usb_pcwd_set_heartbeat(usb_pcwd_device, new_heartbeat))
434 return -EINVAL; 465 return -EINVAL;
435 466
436 usb_pcwd_keepalive(usb_pcwd_device); 467 usb_pcwd_keepalive(usb_pcwd_device);
437 /* Fall */ 468 /* Fall */
@@ -475,7 +506,8 @@ static int usb_pcwd_release(struct inode *inode, struct file *file)
475 if (expect_release == 42) { 506 if (expect_release == 42) {
476 usb_pcwd_stop(usb_pcwd_device); 507 usb_pcwd_stop(usb_pcwd_device);
477 } else { 508 } else {
478 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); 509 printk(KERN_CRIT PFX
510 "Unexpected close, not stopping watchdog!\n");
479 usb_pcwd_keepalive(usb_pcwd_device); 511 usb_pcwd_keepalive(usb_pcwd_device);
480 } 512 }
481 expect_release = 0; 513 expect_release = 0;
@@ -515,7 +547,8 @@ static int usb_pcwd_temperature_release(struct inode *inode, struct file *file)
515 * Notify system 547 * Notify system
516 */ 548 */
517 549
518static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) 550static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code,
551 void *unused)
519{ 552{
520 if (code == SYS_DOWN || code == SYS_HALT) 553 if (code == SYS_DOWN || code == SYS_HALT)
521 usb_pcwd_stop(usb_pcwd_device); /* Turn the WDT off */ 554 usb_pcwd_stop(usb_pcwd_device); /* Turn the WDT off */
@@ -578,7 +611,8 @@ static inline void usb_pcwd_delete(struct usb_pcwd_private *usb_pcwd)
578 * Called by the usb core when a new device is connected that it thinks 611 * Called by the usb core when a new device is connected that it thinks
579 * this driver might be interested in. 612 * this driver might be interested in.
580 */ 613 */
581static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_device_id *id) 614static int usb_pcwd_probe(struct usb_interface *interface,
615 const struct usb_device_id *id)
582{ 616{
583 struct usb_device *udev = interface_to_usbdev(interface); 617 struct usb_device *udev = interface_to_usbdev(interface);
584 struct usb_host_interface *iface_desc; 618 struct usb_host_interface *iface_desc;
@@ -602,16 +636,15 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
602 636
603 /* check out that we have a HID device */ 637 /* check out that we have a HID device */
604 if (!(iface_desc->desc.bInterfaceClass == USB_CLASS_HID)) { 638 if (!(iface_desc->desc.bInterfaceClass == USB_CLASS_HID)) {
605 printk(KERN_ERR PFX "The device isn't a Human Interface Device\n"); 639 printk(KERN_ERR PFX
640 "The device isn't a Human Interface Device\n");
606 return -ENODEV; 641 return -ENODEV;
607 } 642 }
608 643
609 /* check out the endpoint: it has to be Interrupt & IN */ 644 /* check out the endpoint: it has to be Interrupt & IN */
610 endpoint = &iface_desc->endpoint[0].desc; 645 endpoint = &iface_desc->endpoint[0].desc;
611 646
612 if (!((endpoint->bEndpointAddress & USB_DIR_IN) && 647 if (!usb_endpoint_is_int_in(endpoint)) {
613 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
614 == USB_ENDPOINT_XFER_INT))) {
615 /* we didn't find a Interrupt endpoint with direction IN */ 648 /* we didn't find a Interrupt endpoint with direction IN */
616 printk(KERN_ERR PFX "Couldn't find an INTR & IN endpoint\n"); 649 printk(KERN_ERR PFX "Couldn't find an INTR & IN endpoint\n");
617 return -ENODEV; 650 return -ENODEV;
@@ -634,10 +667,12 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
634 usb_pcwd->udev = udev; 667 usb_pcwd->udev = udev;
635 usb_pcwd->interface = interface; 668 usb_pcwd->interface = interface;
636 usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber; 669 usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber;
637 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8); 670 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ?
671 le16_to_cpu(endpoint->wMaxPacketSize) : 8);
638 672
639 /* set up the memory buffer's */ 673 /* set up the memory buffer's */
640 usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, GFP_ATOMIC, &usb_pcwd->intr_dma); 674 usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size,
675 GFP_ATOMIC, &usb_pcwd->intr_dma);
641 if (!usb_pcwd->intr_buffer) { 676 if (!usb_pcwd->intr_buffer) {
642 printk(KERN_ERR PFX "Out of memory\n"); 677 printk(KERN_ERR PFX "Out of memory\n");
643 goto error; 678 goto error;
@@ -671,7 +706,8 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
671 usb_pcwd_stop(usb_pcwd); 706 usb_pcwd_stop(usb_pcwd);
672 707
673 /* Get the Firmware Version */ 708 /* Get the Firmware Version */
674 got_fw_rev = usb_pcwd_send_command(usb_pcwd, CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor); 709 got_fw_rev = usb_pcwd_send_command(usb_pcwd, CMD_GET_FIRMWARE_VERSION,
710 &fw_rev_major, &fw_rev_minor);
675 if (got_fw_rev) 711 if (got_fw_rev)
676 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor); 712 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
677 else 713 else
@@ -681,9 +717,11 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
681 fw_ver_str); 717 fw_ver_str);
682 718
683 /* Get switch settings */ 719 /* Get switch settings */
684 usb_pcwd_send_command(usb_pcwd, CMD_GET_DIP_SWITCH_SETTINGS, &dummy, &option_switches); 720 usb_pcwd_send_command(usb_pcwd, CMD_GET_DIP_SWITCH_SETTINGS, &dummy,
721 &option_switches);
685 722
686 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", 723 printk(KERN_INFO PFX "Option switches (0x%02x): "
724 "Temperature Reset Enable=%s, Power On Delay=%s\n",
687 option_switches, 725 option_switches,
688 ((option_switches & 0x10) ? "ON" : "OFF"), 726 ((option_switches & 0x10) ? "ON" : "OFF"),
689 ((option_switches & 0x08) ? "ON" : "OFF")); 727 ((option_switches & 0x08) ? "ON" : "OFF"));
@@ -692,30 +730,35 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
692 if (heartbeat == 0) 730 if (heartbeat == 0)
693 heartbeat = heartbeat_tbl[(option_switches & 0x07)]; 731 heartbeat = heartbeat_tbl[(option_switches & 0x07)];
694 732
695 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 733 /* Check that the heartbeat value is within it's range ;
734 * if not reset to the default */
696 if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) { 735 if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) {
697 usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT); 736 usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT);
698 printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n", 737 printk(KERN_INFO PFX
738 "heartbeat value must be 0<heartbeat<65536, using %d\n",
699 WATCHDOG_HEARTBEAT); 739 WATCHDOG_HEARTBEAT);
700 } 740 }
701 741
702 retval = register_reboot_notifier(&usb_pcwd_notifier); 742 retval = register_reboot_notifier(&usb_pcwd_notifier);
703 if (retval != 0) { 743 if (retval != 0) {
704 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", 744 printk(KERN_ERR PFX
745 "cannot register reboot notifier (err=%d)\n",
705 retval); 746 retval);
706 goto error; 747 goto error;
707 } 748 }
708 749
709 retval = misc_register(&usb_pcwd_temperature_miscdev); 750 retval = misc_register(&usb_pcwd_temperature_miscdev);
710 if (retval != 0) { 751 if (retval != 0) {
711 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 752 printk(KERN_ERR PFX
753 "cannot register miscdev on minor=%d (err=%d)\n",
712 TEMP_MINOR, retval); 754 TEMP_MINOR, retval);
713 goto err_out_unregister_reboot; 755 goto err_out_unregister_reboot;
714 } 756 }
715 757
716 retval = misc_register(&usb_pcwd_miscdev); 758 retval = misc_register(&usb_pcwd_miscdev);
717 if (retval != 0) { 759 if (retval != 0) {
718 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 760 printk(KERN_ERR PFX
761 "cannot register miscdev on minor=%d (err=%d)\n",
719 WATCHDOG_MINOR, retval); 762 WATCHDOG_MINOR, retval);
720 goto err_out_misc_deregister; 763 goto err_out_misc_deregister;
721 } 764 }
@@ -801,7 +844,7 @@ static int __init usb_pcwd_init(void)
801 return result; 844 return result;
802 } 845 }
803 846
804 printk(KERN_INFO PFX DRIVER_DESC " v" DRIVER_VERSION " (" DRIVER_DATE ")\n"); 847 printk(KERN_INFO PFX DRIVER_DESC " v" DRIVER_VERSION "\n");
805 return 0; 848 return 0;
806} 849}
807 850
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index 6d9f3d4a9987..64135195f827 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -54,22 +54,22 @@
54 54
55/* WDTIM_CTRL bit definitions */ 55/* WDTIM_CTRL bit definitions */
56#define COUNT_ENAB 1 56#define COUNT_ENAB 1
57#define RESET_COUNT (1<<1) 57#define RESET_COUNT (1 << 1)
58#define DEBUG_EN (1<<2) 58#define DEBUG_EN (1 << 2)
59 59
60/* WDTIM_MCTRL bit definitions */ 60/* WDTIM_MCTRL bit definitions */
61#define MR0_INT 1 61#define MR0_INT 1
62#undef RESET_COUNT0 62#undef RESET_COUNT0
63#define RESET_COUNT0 (1<<2) 63#define RESET_COUNT0 (1 << 2)
64#define STOP_COUNT0 (1<<2) 64#define STOP_COUNT0 (1 << 2)
65#define M_RES1 (1<<3) 65#define M_RES1 (1 << 3)
66#define M_RES2 (1<<4) 66#define M_RES2 (1 << 4)
67#define RESFRC1 (1<<5) 67#define RESFRC1 (1 << 5)
68#define RESFRC2 (1<<6) 68#define RESFRC2 (1 << 6)
69 69
70/* WDTIM_EMR bit definitions */ 70/* WDTIM_EMR bit definitions */
71#define EXT_MATCH0 1 71#define EXT_MATCH0 1
72#define MATCH_OUTPUT_HIGH (2<<4) /*a MATCH_CTRL setting */ 72#define MATCH_OUTPUT_HIGH (2 << 4) /*a MATCH_CTRL setting */
73 73
74/* WDTIM_RES bit definitions */ 74/* WDTIM_RES bit definitions */
75#define WDOG_RESET 1 /* read only */ 75#define WDOG_RESET 1 /* read only */
diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c
index f3553fa40b17..f6cccc9df022 100644
--- a/drivers/watchdog/rc32434_wdt.c
+++ b/drivers/watchdog/rc32434_wdt.c
@@ -17,27 +17,29 @@
17 * 17 *
18 */ 18 */
19 19
20#include <linux/module.h> 20#include <linux/module.h> /* For module specific items */
21#include <linux/types.h> 21#include <linux/moduleparam.h> /* For new moduleparam's */
22#include <linux/kernel.h> 22#include <linux/types.h> /* For standard types (like size_t) */
23#include <linux/fs.h> 23#include <linux/errno.h> /* For the -ENODEV/... values */
24#include <linux/mm.h> 24#include <linux/kernel.h> /* For printk/panic/... */
25#include <linux/miscdevice.h> 25#include <linux/fs.h> /* For file operations */
26#include <linux/watchdog.h> 26#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV
27#include <linux/reboot.h> 27 (WATCHDOG_MINOR) */
28#include <linux/smp_lock.h> 28#include <linux/watchdog.h> /* For the watchdog specific items */
29#include <linux/init.h> 29#include <linux/init.h> /* For __init/__exit/... */
30#include <linux/platform_device.h> 30#include <linux/platform_device.h> /* For platform_driver framework */
31#include <linux/uaccess.h> 31#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */
32 32#include <linux/uaccess.h> /* For copy_to_user/put_user/... */
33#include <asm/bootinfo.h> 33
34#include <asm/time.h> 34#include <asm/mach-rc32434/integ.h> /* For the Watchdog registers */
35#include <asm/mach-rc32434/integ.h> 35
36 36#define PFX KBUILD_MODNAME ": "
37#define VERSION "0.4" 37
38#define VERSION "1.0"
38 39
39static struct { 40static struct {
40 unsigned long inuse; 41 unsigned long inuse;
42 spinlock_t io_lock;
41} rc32434_wdt_device; 43} rc32434_wdt_device;
42 44
43static struct integ __iomem *wdt_reg; 45static struct integ __iomem *wdt_reg;
@@ -58,6 +60,9 @@ extern unsigned int idt_cpu_freq;
58#define WATCHDOG_TIMEOUT 20 60#define WATCHDOG_TIMEOUT 20
59 61
60static int timeout = WATCHDOG_TIMEOUT; 62static int timeout = WATCHDOG_TIMEOUT;
63module_param(timeout, int, 0);
64MODULE_PARM_DESC(timeout, "Watchdog timeout value, in seconds (default="
65 WATCHDOG_TIMEOUT ")");
61 66
62static int nowayout = WATCHDOG_NOWAYOUT; 67static int nowayout = WATCHDOG_NOWAYOUT;
63module_param(nowayout, int, 0); 68module_param(nowayout, int, 0);
@@ -68,10 +73,29 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
68#define SET_BITS(addr, or, nand) \ 73#define SET_BITS(addr, or, nand) \
69 writel((readl(&addr) | or) & ~nand, &addr) 74 writel((readl(&addr) | or) & ~nand, &addr)
70 75
76static int rc32434_wdt_set(int new_timeout)
77{
78 int max_to = WTCOMP2SEC((u32)-1);
79
80 if (new_timeout < 0 || new_timeout > max_to) {
81 printk(KERN_ERR PFX "timeout value must be between 0 and %d",
82 max_to);
83 return -EINVAL;
84 }
85 timeout = new_timeout;
86 spin_lock(&rc32434_wdt_device.io_lock);
87 writel(SEC2WTCOMP(timeout), &wdt_reg->wtcompare);
88 spin_unlock(&rc32434_wdt_device.io_lock);
89
90 return 0;
91}
92
71static void rc32434_wdt_start(void) 93static void rc32434_wdt_start(void)
72{ 94{
73 u32 or, nand; 95 u32 or, nand;
74 96
97 spin_lock(&rc32434_wdt_device.io_lock);
98
75 /* zero the counter before enabling */ 99 /* zero the counter before enabling */
76 writel(0, &wdt_reg->wtcount); 100 writel(0, &wdt_reg->wtcount);
77 101
@@ -85,38 +109,35 @@ static void rc32434_wdt_start(void)
85 109
86 SET_BITS(wdt_reg->errcs, or, nand); 110 SET_BITS(wdt_reg->errcs, or, nand);
87 111
112 /* set the timeout (either default or based on module param) */
113 rc32434_wdt_set(timeout);
114
88 /* reset WTC timeout bit and enable WDT */ 115 /* reset WTC timeout bit and enable WDT */
89 nand = 1 << RC32434_WTC_TO; 116 nand = 1 << RC32434_WTC_TO;
90 or = 1 << RC32434_WTC_EN; 117 or = 1 << RC32434_WTC_EN;
91 118
92 SET_BITS(wdt_reg->wtc, or, nand); 119 SET_BITS(wdt_reg->wtc, or, nand);
120
121 spin_unlock(&rc32434_wdt_device.io_lock);
122 printk(KERN_INFO PFX "Started watchdog timer.\n");
93} 123}
94 124
95static void rc32434_wdt_stop(void) 125static void rc32434_wdt_stop(void)
96{ 126{
127 spin_lock(&rc32434_wdt_device.io_lock);
128
97 /* Disable WDT */ 129 /* Disable WDT */
98 SET_BITS(wdt_reg->wtc, 0, 1 << RC32434_WTC_EN); 130 SET_BITS(wdt_reg->wtc, 0, 1 << RC32434_WTC_EN);
99}
100
101static int rc32434_wdt_set(int new_timeout)
102{
103 int max_to = WTCOMP2SEC((u32)-1);
104
105 if (new_timeout < 0 || new_timeout > max_to) {
106 printk(KERN_ERR KBUILD_MODNAME
107 ": timeout value must be between 0 and %d",
108 max_to);
109 return -EINVAL;
110 }
111 timeout = new_timeout;
112 writel(SEC2WTCOMP(timeout), &wdt_reg->wtcompare);
113 131
114 return 0; 132 spin_unlock(&rc32434_wdt_device.io_lock);
133 printk(KERN_INFO PFX "Stopped watchdog timer.\n");
115} 134}
116 135
117static void rc32434_wdt_ping(void) 136static void rc32434_wdt_ping(void)
118{ 137{
138 spin_lock(&rc32434_wdt_device.io_lock);
119 writel(0, &wdt_reg->wtcount); 139 writel(0, &wdt_reg->wtcount);
140 spin_unlock(&rc32434_wdt_device.io_lock);
120} 141}
121 142
122static int rc32434_wdt_open(struct inode *inode, struct file *file) 143static int rc32434_wdt_open(struct inode *inode, struct file *file)
@@ -137,11 +158,10 @@ static int rc32434_wdt_release(struct inode *inode, struct file *file)
137{ 158{
138 if (expect_close == 42) { 159 if (expect_close == 42) {
139 rc32434_wdt_stop(); 160 rc32434_wdt_stop();
140 printk(KERN_INFO KBUILD_MODNAME ": disabling watchdog timer\n");
141 module_put(THIS_MODULE); 161 module_put(THIS_MODULE);
142 } else { 162 } else {
143 printk(KERN_CRIT KBUILD_MODNAME 163 printk(KERN_CRIT PFX
144 ": device closed unexpectedly. WDT will not stop !\n"); 164 "device closed unexpectedly. WDT will not stop!\n");
145 rc32434_wdt_ping(); 165 rc32434_wdt_ping();
146 } 166 }
147 clear_bit(0, &rc32434_wdt_device.inuse); 167 clear_bit(0, &rc32434_wdt_device.inuse);
@@ -185,8 +205,9 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
185 .identity = "RC32434_WDT Watchdog", 205 .identity = "RC32434_WDT Watchdog",
186 }; 206 };
187 switch (cmd) { 207 switch (cmd) {
188 case WDIOC_KEEPALIVE: 208 case WDIOC_GETSUPPORT:
189 rc32434_wdt_ping(); 209 if (copy_to_user(argp, &ident, sizeof(ident)))
210 return -EFAULT;
190 break; 211 break;
191 case WDIOC_GETSTATUS: 212 case WDIOC_GETSTATUS:
192 case WDIOC_GETBOOTSTATUS: 213 case WDIOC_GETBOOTSTATUS:
@@ -194,10 +215,6 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
194 if (copy_to_user(argp, &value, sizeof(int))) 215 if (copy_to_user(argp, &value, sizeof(int)))
195 return -EFAULT; 216 return -EFAULT;
196 break; 217 break;
197 case WDIOC_GETSUPPORT:
198 if (copy_to_user(argp, &ident, sizeof(ident)))
199 return -EFAULT;
200 break;
201 case WDIOC_SETOPTIONS: 218 case WDIOC_SETOPTIONS:
202 if (copy_from_user(&value, argp, sizeof(int))) 219 if (copy_from_user(&value, argp, sizeof(int)))
203 return -EFAULT; 220 return -EFAULT;
@@ -212,6 +229,9 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
212 return -EINVAL; 229 return -EINVAL;
213 } 230 }
214 break; 231 break;
232 case WDIOC_KEEPALIVE:
233 rc32434_wdt_ping();
234 break;
215 case WDIOC_SETTIMEOUT: 235 case WDIOC_SETTIMEOUT:
216 if (copy_from_user(&new_timeout, argp, sizeof(int))) 236 if (copy_from_user(&new_timeout, argp, sizeof(int)))
217 return -EFAULT; 237 return -EFAULT;
@@ -227,7 +247,7 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
227 return 0; 247 return 0;
228} 248}
229 249
230static struct file_operations rc32434_wdt_fops = { 250static const struct file_operations rc32434_wdt_fops = {
231 .owner = THIS_MODULE, 251 .owner = THIS_MODULE,
232 .llseek = no_llseek, 252 .llseek = no_llseek,
233 .write = rc32434_wdt_write, 253 .write = rc32434_wdt_write,
@@ -242,8 +262,8 @@ static struct miscdevice rc32434_wdt_miscdev = {
242 .fops = &rc32434_wdt_fops, 262 .fops = &rc32434_wdt_fops,
243}; 263};
244 264
245static char banner[] __devinitdata = KERN_INFO KBUILD_MODNAME 265static char banner[] __devinitdata = KERN_INFO PFX
246 ": Watchdog Timer version " VERSION ", timer margin: %d sec\n"; 266 "Watchdog Timer version " VERSION ", timer margin: %d sec\n";
247 267
248static int __devinit rc32434_wdt_probe(struct platform_device *pdev) 268static int __devinit rc32434_wdt_probe(struct platform_device *pdev)
249{ 269{
@@ -252,22 +272,33 @@ static int __devinit rc32434_wdt_probe(struct platform_device *pdev)
252 272
253 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb532_wdt_res"); 273 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb532_wdt_res");
254 if (!r) { 274 if (!r) {
255 printk(KERN_ERR KBUILD_MODNAME 275 printk(KERN_ERR PFX "failed to retrieve resources\n");
256 "failed to retrieve resources\n");
257 return -ENODEV; 276 return -ENODEV;
258 } 277 }
259 278
260 wdt_reg = ioremap_nocache(r->start, r->end - r->start); 279 wdt_reg = ioremap_nocache(r->start, r->end - r->start);
261 if (!wdt_reg) { 280 if (!wdt_reg) {
262 printk(KERN_ERR KBUILD_MODNAME 281 printk(KERN_ERR PFX "failed to remap I/O resources\n");
263 "failed to remap I/O resources\n");
264 return -ENXIO; 282 return -ENXIO;
265 } 283 }
266 284
285 spin_lock_init(&rc32434_wdt_device.io_lock);
286
287 /* Make sure the watchdog is not running */
288 rc32434_wdt_stop();
289
290 /* Check that the heartbeat value is within it's range;
291 * if not reset to the default */
292 if (rc32434_wdt_set(timeout)) {
293 rc32434_wdt_set(WATCHDOG_TIMEOUT);
294 printk(KERN_INFO PFX
295 "timeout value must be between 0 and %d\n",
296 WTCOMP2SEC((u32)-1));
297 }
298
267 ret = misc_register(&rc32434_wdt_miscdev); 299 ret = misc_register(&rc32434_wdt_miscdev);
268 if (ret < 0) { 300 if (ret < 0) {
269 printk(KERN_ERR KBUILD_MODNAME 301 printk(KERN_ERR PFX "failed to register watchdog device\n");
270 "failed to register watchdog device\n");
271 goto unmap; 302 goto unmap;
272 } 303 }
273 304
@@ -287,22 +318,28 @@ static int __devexit rc32434_wdt_remove(struct platform_device *pdev)
287 return 0; 318 return 0;
288} 319}
289 320
290static struct platform_driver rc32434_wdt = { 321static void rc32434_wdt_shutdown(struct platform_device *pdev)
291 .probe = rc32434_wdt_probe, 322{
292 .remove = __devexit_p(rc32434_wdt_remove), 323 rc32434_wdt_stop();
293 .driver = { 324}
294 .name = "rc32434_wdt", 325
326static struct platform_driver rc32434_wdt_driver = {
327 .probe = rc32434_wdt_probe,
328 .remove = __devexit_p(rc32434_wdt_remove),
329 .shutdown = rc32434_wdt_shutdown,
330 .driver = {
331 .name = "rc32434_wdt",
295 } 332 }
296}; 333};
297 334
298static int __init rc32434_wdt_init(void) 335static int __init rc32434_wdt_init(void)
299{ 336{
300 return platform_driver_register(&rc32434_wdt); 337 return platform_driver_register(&rc32434_wdt_driver);
301} 338}
302 339
303static void __exit rc32434_wdt_exit(void) 340static void __exit rc32434_wdt_exit(void)
304{ 341{
305 platform_driver_unregister(&rc32434_wdt); 342 platform_driver_unregister(&rc32434_wdt_driver);
306} 343}
307 344
308module_init(rc32434_wdt_init); 345module_init(rc32434_wdt_init);
diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c
index 09cb1833ea27..1e8f02f440e6 100644
--- a/drivers/watchdog/riowd.c
+++ b/drivers/watchdog/riowd.c
@@ -14,9 +14,8 @@
14#include <linux/watchdog.h> 14#include <linux/watchdog.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h> 16#include <linux/of_device.h>
17 17#include <linux/io.h>
18#include <asm/io.h> 18#include <linux/uaccess.h>
19#include <asm/uaccess.h>
20 19
21 20
22/* RIO uses the NatSemi Super I/O power management logical device 21/* RIO uses the NatSemi Super I/O power management logical device
@@ -86,8 +85,7 @@ static int riowd_release(struct inode *inode, struct file *filp)
86 return 0; 85 return 0;
87} 86}
88 87
89static int riowd_ioctl(struct inode *inode, struct file *filp, 88static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
90 unsigned int cmd, unsigned long arg)
91{ 89{
92 static struct watchdog_info info = { 90 static struct watchdog_info info = {
93 .options = WDIOF_SETTIMEOUT, 91 .options = WDIOF_SETTIMEOUT,
@@ -147,7 +145,8 @@ static int riowd_ioctl(struct inode *inode, struct file *filp,
147 return 0; 145 return 0;
148} 146}
149 147
150static ssize_t riowd_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 148static ssize_t riowd_write(struct file *file, const char __user *buf,
149 size_t count, loff_t *ppos)
151{ 150{
152 struct riowd *p = riowd_device; 151 struct riowd *p = riowd_device;
153 152
@@ -160,12 +159,12 @@ static ssize_t riowd_write(struct file *file, const char __user *buf, size_t cou
160} 159}
161 160
162static const struct file_operations riowd_fops = { 161static const struct file_operations riowd_fops = {
163 .owner = THIS_MODULE, 162 .owner = THIS_MODULE,
164 .llseek = no_llseek, 163 .llseek = no_llseek,
165 .ioctl = riowd_ioctl, 164 .unlocked_ioctl = riowd_ioctl,
166 .open = riowd_open, 165 .open = riowd_open,
167 .write = riowd_write, 166 .write = riowd_write,
168 .release = riowd_release, 167 .release = riowd_release,
169}; 168};
170 169
171static struct miscdevice riowd_miscdev = { 170static struct miscdevice riowd_miscdev = {
diff --git a/drivers/watchdog/rm9k_wdt.c b/drivers/watchdog/rm9k_wdt.c
index f1ae3729a19e..cce1982a1b58 100644
--- a/drivers/watchdog/rm9k_wdt.c
+++ b/drivers/watchdog/rm9k_wdt.c
@@ -59,8 +59,8 @@ static long wdt_gpi_ioctl(struct file *, unsigned int, unsigned long);
59static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *); 59static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *);
60static const struct resource *wdt_gpi_get_resource(struct platform_device *, 60static const struct resource *wdt_gpi_get_resource(struct platform_device *,
61 const char *, unsigned int); 61 const char *, unsigned int);
62static int __init wdt_gpi_probe(struct device *); 62static int __init wdt_gpi_probe(struct platform_device *);
63static int __exit wdt_gpi_remove(struct device *); 63static int __exit wdt_gpi_remove(struct platform_device *);
64 64
65 65
66static const char wdt_gpi_name[] = "wdt_gpi"; 66static const char wdt_gpi_name[] = "wdt_gpi";
@@ -346,10 +346,9 @@ static const struct resource *wdt_gpi_get_resource(struct platform_device *pdv,
346} 346}
347 347
348/* No hotplugging on the platform bus - use __init */ 348/* No hotplugging on the platform bus - use __init */
349static int __init wdt_gpi_probe(struct device *dev) 349static int __init wdt_gpi_probe(struct platform_device *pdv)
350{ 350{
351 int res; 351 int res;
352 struct platform_device * const pdv = to_platform_device(dev);
353 const struct resource 352 const struct resource
354 * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS, 353 * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS,
355 IORESOURCE_MEM), 354 IORESOURCE_MEM),
@@ -374,7 +373,7 @@ static int __init wdt_gpi_probe(struct device *dev)
374 return res; 373 return res;
375} 374}
376 375
377static int __exit wdt_gpi_remove(struct device *dev) 376static int __exit wdt_gpi_remove(struct platform_device *dev)
378{ 377{
379 int res; 378 int res;
380 379
@@ -387,15 +386,13 @@ static int __exit wdt_gpi_remove(struct device *dev)
387 386
388 387
389/* Device driver init & exit */ 388/* Device driver init & exit */
390static struct device_driver wdt_gpi_driver = { 389static struct platform_driver wgt_gpi_driver = {
391 .name = (char *) wdt_gpi_name, 390 .driver = {
392 .bus = &platform_bus_type, 391 .name = wdt_gpi_name,
393 .owner = THIS_MODULE, 392 .owner = THIS_MODULE,
393 },
394 .probe = wdt_gpi_probe, 394 .probe = wdt_gpi_probe,
395 .remove = __exit_p(wdt_gpi_remove), 395 .remove = __devexit_p(wdt_gpi_remove),
396 .shutdown = NULL,
397 .suspend = NULL,
398 .resume = NULL,
399}; 396};
400 397
401static int __init wdt_gpi_init_module(void) 398static int __init wdt_gpi_init_module(void)
@@ -403,12 +400,12 @@ static int __init wdt_gpi_init_module(void)
403 atomic_set(&opencnt, 1); 400 atomic_set(&opencnt, 1);
404 if (timeout > MAX_TIMEOUT_SECONDS) 401 if (timeout > MAX_TIMEOUT_SECONDS)
405 timeout = MAX_TIMEOUT_SECONDS; 402 timeout = MAX_TIMEOUT_SECONDS;
406 return driver_register(&wdt_gpi_driver); 403 return platform_driver_register(&wdt_gpi_driver);
407} 404}
408 405
409static void __exit wdt_gpi_cleanup_module(void) 406static void __exit wdt_gpi_cleanup_module(void)
410{ 407{
411 driver_unregister(&wdt_gpi_driver); 408 platform_driver_unregister(&wdt_gpi_driver);
412} 409}
413 410
414module_init(wdt_gpi_init_module); 411module_init(wdt_gpi_init_module);
diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
index 4b84f296d30c..ee1caae4d33b 100644
--- a/drivers/watchdog/sa1100_wdt.c
+++ b/drivers/watchdog/sa1100_wdt.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Watchdog driver for the SA11x0/PXA2xx 2 * Watchdog driver for the SA11x0/PXA2xx
3 * 3 *
4 * (c) Copyright 2000 Oleg Drokin <green@crimea.edu> 4 * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
5 * Based on SoftDog driver by Alan Cox <alan@lxorguk.ukuu.org.uk> 5 * Based on SoftDog driver by Alan Cox <alan@lxorguk.ukuu.org.uk>
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -15,7 +15,7 @@
15 * 15 *
16 * (c) Copyright 2000 Oleg Drokin <green@crimea.edu> 16 * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
17 * 17 *
18 * 27/11/2000 Initial release 18 * 27/11/2000 Initial release
19 */ 19 */
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
diff --git a/drivers/watchdog/sbc60xxwdt.c b/drivers/watchdog/sbc60xxwdt.c
index 3266daaaecf8..d1c390c7155c 100644
--- a/drivers/watchdog/sbc60xxwdt.c
+++ b/drivers/watchdog/sbc60xxwdt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * 60xx Single Board Computer Watchdog Timer driver for Linux 2.2.x 2 * 60xx Single Board Computer Watchdog Timer driver for Linux 2.2.x
3 * 3 *
4 * Based on acquirewdt.c by Alan Cox. 4 * Based on acquirewdt.c by Alan Cox.
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
diff --git a/drivers/watchdog/sbc8360.c b/drivers/watchdog/sbc8360.c
index ae74f6bcfa23..b6e6799ec45d 100644
--- a/drivers/watchdog/sbc8360.c
+++ b/drivers/watchdog/sbc8360.c
@@ -4,12 +4,12 @@
4 * (c) Copyright 2005 Webcon, Inc. 4 * (c) Copyright 2005 Webcon, Inc.
5 * 5 *
6 * Based on ib700wdt.c, which is based on advantechwdt.c which is based 6 * Based on ib700wdt.c, which is based on advantechwdt.c which is based
7 * on acquirewdt.c which is based on wdt.c. 7 * on acquirewdt.c which is based on wdt.c.
8 * 8 *
9 * (c) Copyright 2001 Charles Howes <chowes@vsol.net> 9 * (c) Copyright 2001 Charles Howes <chowes@vsol.net>
10 * 10 *
11 * Based on advantechwdt.c which is based on acquirewdt.c which 11 * Based on advantechwdt.c which is based on acquirewdt.c which
12 * is based on wdt.c. 12 * is based on wdt.c.
13 * 13 *
14 * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl> 14 * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl>
15 * 15 *
@@ -30,9 +30,9 @@
30 * 30 *
31 * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> 31 * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
32 * 32 *
33 * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> 33 * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
34 * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT 34 * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
35 * Added timeout module option to override default 35 * Added timeout module option to override default
36 * 36 *
37 */ 37 */
38 38
diff --git a/drivers/watchdog/sbc_epx_c3.c b/drivers/watchdog/sbc_epx_c3.c
index 06553debc7bc..e467ddcf796a 100644
--- a/drivers/watchdog/sbc_epx_c3.c
+++ b/drivers/watchdog/sbc_epx_c3.c
@@ -35,7 +35,8 @@ static int epx_c3_alive;
35 35
36static int nowayout = WATCHDOG_NOWAYOUT; 36static int nowayout = WATCHDOG_NOWAYOUT;
37module_param(nowayout, int, 0); 37module_param(nowayout, int, 0);
38MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 38MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
39 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
39 40
40#define EPXC3_WATCHDOG_CTL_REG 0x1ee /* write 1 to enable, 0 to disable */ 41#define EPXC3_WATCHDOG_CTL_REG 0x1ee /* write 1 to enable, 0 to disable */
41#define EPXC3_WATCHDOG_PET_REG 0x1ef /* write anything to pet once enabled */ 42#define EPXC3_WATCHDOG_PET_REG 0x1ef /* write anything to pet once enabled */
diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c
index 23da3ccd832a..b5e19c1820a2 100644
--- a/drivers/watchdog/sc1200wdt.c
+++ b/drivers/watchdog/sc1200wdt.c
@@ -71,7 +71,7 @@
71#define UART2_IRQ 0x04 /* Serial1 */ 71#define UART2_IRQ 0x04 /* Serial1 */
72/* 5 -7 are reserved */ 72/* 5 -7 are reserved */
73 73
74static char banner[] __initdata = KERN_INFO PFX SC1200_MODULE_VER; 74static char banner[] __initdata = PFX SC1200_MODULE_VER;
75static int timeout = 1; 75static int timeout = 1;
76static int io = -1; 76static int io = -1;
77static int io_len = 2; /* for non plug and play */ 77static int io_len = 2; /* for non plug and play */
@@ -392,7 +392,7 @@ static int __init sc1200wdt_init(void)
392{ 392{
393 int ret; 393 int ret;
394 394
395 printk("%s\n", banner); 395 printk(KERN_INFO "%s\n", banner);
396 396
397#if defined CONFIG_PNP 397#if defined CONFIG_PNP
398 if (isapnp) { 398 if (isapnp) {
@@ -477,6 +477,7 @@ module_init(sc1200wdt_init);
477module_exit(sc1200wdt_exit); 477module_exit(sc1200wdt_exit);
478 478
479MODULE_AUTHOR("Zwane Mwaikambo <zwane@commfireservices.com>"); 479MODULE_AUTHOR("Zwane Mwaikambo <zwane@commfireservices.com>");
480MODULE_DESCRIPTION("Driver for National Semiconductor PC87307/PC97307 watchdog component"); 480MODULE_DESCRIPTION(
481 "Driver for National Semiconductor PC87307/PC97307 watchdog component");
481MODULE_LICENSE("GPL"); 482MODULE_LICENSE("GPL");
482MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 483MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/watchdog/sc520_wdt.c b/drivers/watchdog/sc520_wdt.c
index a2b6c1067ec5..52b63f2f0dac 100644
--- a/drivers/watchdog/sc520_wdt.c
+++ b/drivers/watchdog/sc520_wdt.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * AMD Elan SC520 processor Watchdog Timer driver 2 * AMD Elan SC520 processor Watchdog Timer driver
3 * 3 *
4 * Based on acquirewdt.c by Alan Cox, 4 * Based on acquirewdt.c by Alan Cox,
5 * and sbc60xxwdt.c by Jakob Oestergaard <jakob@unthought.net> 5 * and sbc60xxwdt.c by Jakob Oestergaard <jakob@unthought.net>
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -11,7 +11,7 @@
11 * 11 *
12 * The authors do NOT admit liability nor provide warranty for 12 * The authors do NOT admit liability nor provide warranty for
13 * any of this software. This material is provided "AS-IS" in 13 * any of this software. This material is provided "AS-IS" in
14 * the hope that it may be useful for others. 14 * the hope that it may be useful for others.
15 * 15 *
16 * (c) Copyright 2001 Scott Jennings <linuxdrivers@oro.net> 16 * (c) Copyright 2001 Scott Jennings <linuxdrivers@oro.net>
17 * 9/27 - 2001 [Initial release] 17 * 9/27 - 2001 [Initial release]
@@ -438,6 +438,7 @@ module_init(sc520_wdt_init);
438module_exit(sc520_wdt_unload); 438module_exit(sc520_wdt_unload);
439 439
440MODULE_AUTHOR("Scott and Bill Jennings"); 440MODULE_AUTHOR("Scott and Bill Jennings");
441MODULE_DESCRIPTION("Driver for watchdog timer in AMD \"Elan\" SC520 uProcessor"); 441MODULE_DESCRIPTION(
442 "Driver for watchdog timer in AMD \"Elan\" SC520 uProcessor");
442MODULE_LICENSE("GPL"); 443MODULE_LICENSE("GPL");
443MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 444MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/watchdog/smsc37b787_wdt.c b/drivers/watchdog/smsc37b787_wdt.c
index 2e56cad77d19..8a1f0bc3e271 100644
--- a/drivers/watchdog/smsc37b787_wdt.c
+++ b/drivers/watchdog/smsc37b787_wdt.c
@@ -2,7 +2,7 @@
2 * SMsC 37B787 Watchdog Timer driver for Linux 2.6.x.x 2 * SMsC 37B787 Watchdog Timer driver for Linux 2.6.x.x
3 * 3 *
4 * Based on acquirewdt.c by Alan Cox <alan@lxorguk.ukuu.org.uk> 4 * Based on acquirewdt.c by Alan Cox <alan@lxorguk.ukuu.org.uk>
5 * and some other existing drivers 5 * and some other existing drivers
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -11,7 +11,7 @@
11 * 11 *
12 * The authors do NOT admit liability nor provide warranty for 12 * The authors do NOT admit liability nor provide warranty for
13 * any of this software. This material is provided "AS-IS" in 13 * any of this software. This material is provided "AS-IS" in
14 * the hope that it may be useful for others. 14 * the hope that it may be useful for others.
15 * 15 *
16 * (C) Copyright 2003-2006 Sven Anders <anders@anduras.de> 16 * (C) Copyright 2003-2006 Sven Anders <anders@anduras.de>
17 * 17 *
@@ -22,19 +22,19 @@
22 * 22 *
23 * Theory of operation: 23 * Theory of operation:
24 * 24 *
25 * A Watchdog Timer (WDT) is a hardware circuit that can 25 * A Watchdog Timer (WDT) is a hardware circuit that can
26 * reset the computer system in case of a software fault. 26 * reset the computer system in case of a software fault.
27 * You probably knew that already. 27 * You probably knew that already.
28 * 28 *
29 * Usually a userspace daemon will notify the kernel WDT driver 29 * Usually a userspace daemon will notify the kernel WDT driver
30 * via the /dev/watchdog special device file that userspace is 30 * via the /dev/watchdog special device file that userspace is
31 * still alive, at regular intervals. When such a notification 31 * still alive, at regular intervals. When such a notification
32 * occurs, the driver will usually tell the hardware watchdog 32 * occurs, the driver will usually tell the hardware watchdog
33 * that everything is in order, and that the watchdog should wait 33 * that everything is in order, and that the watchdog should wait
34 * for yet another little while to reset the system. 34 * for yet another little while to reset the system.
35 * If userspace fails (RAM error, kernel bug, whatever), the 35 * If userspace fails (RAM error, kernel bug, whatever), the
36 * notifications cease to occur, and the hardware watchdog will 36 * notifications cease to occur, and the hardware watchdog will
37 * reset the system (causing a reboot) after the timeout occurs. 37 * reset the system (causing a reboot) after the timeout occurs.
38 * 38 *
39 * Create device with: 39 * Create device with:
40 * mknod /dev/watchdog c 10 130 40 * mknod /dev/watchdog c 10 130
@@ -485,7 +485,7 @@ static long wb_smsc_wdt_ioctl(struct file *file,
485 case WDIOC_GETTIMEOUT: 485 case WDIOC_GETTIMEOUT:
486 new_timeout = timeout; 486 new_timeout = timeout;
487 if (unit == UNIT_MINUTE) 487 if (unit == UNIT_MINUTE)
488 new_timeout *= 60; 488 new_timeout *= 60;
489 return put_user(new_timeout, uarg.i); 489 return put_user(new_timeout, uarg.i);
490 default: 490 default:
491 return -ENOTTY; 491 return -ENOTTY;
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index 7204f9662114..ebcc9cea5e99 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * SoftDog 0.07: A Software Watchdog Device 2 * SoftDog 0.07: A Software Watchdog Device
3 * 3 *
4 * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>, All Rights Reserved. 4 * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>,
5 * All Rights Reserved.
5 * 6 *
6 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -32,7 +33,7 @@
32 * Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT. 33 * Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT.
33 * 34 *
34 * 20020530 Joel Becker <joel.becker@oracle.com> 35 * 20020530 Joel Becker <joel.becker@oracle.com>
35 * Added Matt Domsch's nowayout module option. 36 * Added Matt Domsch's nowayout module option.
36 */ 37 */
37 38
38#include <linux/module.h> 39#include <linux/module.h>
diff --git a/drivers/watchdog/w83697hf_wdt.c b/drivers/watchdog/w83697hf_wdt.c
index 3c7aa412b1f3..a9c7f352fcbf 100644
--- a/drivers/watchdog/w83697hf_wdt.c
+++ b/drivers/watchdog/w83697hf_wdt.c
@@ -462,6 +462,7 @@ module_init(wdt_init);
462module_exit(wdt_exit); 462module_exit(wdt_exit);
463 463
464MODULE_LICENSE("GPL"); 464MODULE_LICENSE("GPL");
465MODULE_AUTHOR("Marcus Junker <junker@anduras.de>, Samuel Tardieu <sam@rfc1149.net>"); 465MODULE_AUTHOR("Marcus Junker <junker@anduras.de>, "
466 "Samuel Tardieu <sam@rfc1149.net>");
466MODULE_DESCRIPTION("w83697hf/hg WDT driver"); 467MODULE_DESCRIPTION("w83697hf/hg WDT driver");
467MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 468MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/watchdog/w83697ug_wdt.c b/drivers/watchdog/w83697ug_wdt.c
index ada8ad82d993..883b5f79673a 100644
--- a/drivers/watchdog/w83697ug_wdt.c
+++ b/drivers/watchdog/w83697ug_wdt.c
@@ -2,7 +2,7 @@
2 * w83697ug/uf WDT driver 2 * w83697ug/uf WDT driver
3 * 3 *
4 * (c) Copyright 2008 Flemming Fransen <ff@nrvissing.net> 4 * (c) Copyright 2008 Flemming Fransen <ff@nrvissing.net>
5 * reused original code to supoprt w83697ug/uf. 5 * reused original code to support w83697ug/uf.
6 * 6 *
7 * Based on w83627hf_wdt.c which is based on advantechwdt.c 7 * Based on w83627hf_wdt.c which is based on advantechwdt.c
8 * which is based on wdt.c. 8 * which is based on wdt.c.
@@ -79,7 +79,7 @@ MODULE_PARM_DESC(nowayout,
79 (same as EFER) */ 79 (same as EFER) */
80#define WDT_EFDR (WDT_EFIR+1) /* Extended Function Data Register */ 80#define WDT_EFDR (WDT_EFIR+1) /* Extended Function Data Register */
81 81
82static void w83697ug_select_wd_register(void) 82static int w83697ug_select_wd_register(void)
83{ 83{
84 unsigned char c; 84 unsigned char c;
85 unsigned char version; 85 unsigned char version;
@@ -102,7 +102,7 @@ static void w83697ug_select_wd_register(void)
102 102
103 } else { 103 } else {
104 printk(KERN_ERR PFX "No W83697UG/UF could be found\n"); 104 printk(KERN_ERR PFX "No W83697UG/UF could be found\n");
105 return; 105 return -ENODEV;
106 } 106 }
107 107
108 outb_p(0x07, WDT_EFER); /* point to logical device number reg */ 108 outb_p(0x07, WDT_EFER); /* point to logical device number reg */
@@ -110,6 +110,8 @@ static void w83697ug_select_wd_register(void)
110 outb_p(0x30, WDT_EFER); /* select CR30 */ 110 outb_p(0x30, WDT_EFER); /* select CR30 */
111 c = inb_p(WDT_EFDR); 111 c = inb_p(WDT_EFDR);
112 outb_p(c || 0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */ 112 outb_p(c || 0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */
113
114 return 0;
113} 115}
114 116
115static void w83697ug_unselect_wd_register(void) 117static void w83697ug_unselect_wd_register(void)
@@ -117,11 +119,14 @@ static void w83697ug_unselect_wd_register(void)
117 outb_p(0xAA, WDT_EFER); /* Leave extended function mode */ 119 outb_p(0xAA, WDT_EFER); /* Leave extended function mode */
118} 120}
119 121
120static void w83697ug_init(void) 122static int w83697ug_init(void)
121{ 123{
124 int ret;
122 unsigned char t; 125 unsigned char t;
123 126
124 w83697ug_select_wd_register(); 127 ret = w83697ug_select_wd_register();
128 if (ret != 0)
129 return ret;
125 130
126 outb_p(0xF6, WDT_EFER); /* Select CRF6 */ 131 outb_p(0xF6, WDT_EFER); /* Select CRF6 */
127 t = inb_p(WDT_EFDR); /* read CRF6 */ 132 t = inb_p(WDT_EFDR); /* read CRF6 */
@@ -137,13 +142,15 @@ static void w83697ug_init(void)
137 outb_p(t, WDT_EFDR); /* Write back to CRF5 */ 142 outb_p(t, WDT_EFDR); /* Write back to CRF5 */
138 143
139 w83697ug_unselect_wd_register(); 144 w83697ug_unselect_wd_register();
145 return 0;
140} 146}
141 147
142static void wdt_ctrl(int timeout) 148static void wdt_ctrl(int timeout)
143{ 149{
144 spin_lock(&io_lock); 150 spin_lock(&io_lock);
145 151
146 w83697ug_select_wd_register(); 152 if (w83697ug_select_wd_register() < 0)
153 return;
147 154
148 outb_p(0xF4, WDT_EFER); /* Select CRF4 */ 155 outb_p(0xF4, WDT_EFER); /* Select CRF4 */
149 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF4 */ 156 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF4 */
@@ -347,7 +354,9 @@ static int __init wdt_init(void)
347 goto out; 354 goto out;
348 } 355 }
349 356
350 w83697ug_init(); 357 ret = w83697ug_init();
358 if (ret != 0)
359 goto unreg_regions;
351 360
352 ret = register_reboot_notifier(&wdt_notifier); 361 ret = register_reboot_notifier(&wdt_notifier);
353 if (ret != 0) { 362 if (ret != 0) {
diff --git a/drivers/watchdog/w83977f_wdt.c b/drivers/watchdog/w83977f_wdt.c
index 2525da5080ca..0560182a1d09 100644
--- a/drivers/watchdog/w83977f_wdt.c
+++ b/drivers/watchdog/w83977f_wdt.c
@@ -426,7 +426,7 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
426 return -EFAULT; 426 return -EFAULT;
427 427
428 if (wdt_set_timeout(new_timeout)) 428 if (wdt_set_timeout(new_timeout))
429 return -EINVAL; 429 return -EINVAL;
430 430
431 wdt_keepalive(); 431 wdt_keepalive();
432 /* Fall */ 432 /* Fall */
diff --git a/drivers/watchdog/wd501p.h b/drivers/watchdog/wd501p.h
index db34853c28ae..0e3a497d5626 100644
--- a/drivers/watchdog/wd501p.h
+++ b/drivers/watchdog/wd501p.h
@@ -11,9 +11,9 @@
11 * 11 *
12 * http://www.cymru.net 12 * http://www.cymru.net
13 * 13 *
14 * This driver is provided under the GNU General Public License, incorporated 14 * This driver is provided under the GNU General Public License,
15 * herein by reference. The driver is provided without warranty or 15 * incorporated herein by reference. The driver is provided without
16 * support. 16 * warranty or support.
17 * 17 *
18 * Release 0.04. 18 * Release 0.04.
19 * 19 *
@@ -39,13 +39,13 @@
39/* programmable outputs: */ 39/* programmable outputs: */
40#define WDT_PROGOUT (io+15) /* wr=enable, rd=disable */ 40#define WDT_PROGOUT (io+15) /* wr=enable, rd=disable */
41 41
42 /* FAN 501 500 */ 42 /* FAN 501 500 */
43#define WDC_SR_WCCR 1 /* Active low */ /* X X X */ 43#define WDC_SR_WCCR 1 /* Active low */ /* X X X */
44#define WDC_SR_TGOOD 2 /* X X - */ 44#define WDC_SR_TGOOD 2 /* X X - */
45#define WDC_SR_ISOI0 4 /* X X X */ 45#define WDC_SR_ISOI0 4 /* X X X */
46#define WDC_SR_ISII1 8 /* X X X */ 46#define WDC_SR_ISII1 8 /* X X X */
47#define WDC_SR_FANGOOD 16 /* X - - */ 47#define WDC_SR_FANGOOD 16 /* X - - */
48#define WDC_SR_PSUOVER 32 /* Active low */ /* X X - */ 48#define WDC_SR_PSUOVER 32 /* Active low */ /* X X - */
49#define WDC_SR_PSUUNDR 64 /* Active low */ /* X X - */ 49#define WDC_SR_PSUUNDR 64 /* Active low */ /* X X - */
50#define WDC_SR_IRQ 128 /* Active low */ /* X X X */ 50#define WDC_SR_IRQ 128 /* Active low */ /* X X X */
51 51
diff --git a/drivers/watchdog/wdt.c b/drivers/watchdog/wdt.c
index eddb9187e7b6..3bbefe9a2634 100644
--- a/drivers/watchdog/wdt.c
+++ b/drivers/watchdog/wdt.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Industrial Computer Source WDT500/501 driver 2 * Industrial Computer Source WDT501 driver
3 * 3 *
4 * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>, 4 * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
5 * All Rights Reserved. 5 * All Rights Reserved.
@@ -82,14 +82,16 @@ MODULE_PARM_DESC(io, "WDT io port (default=0x240)");
82module_param(irq, int, 0); 82module_param(irq, int, 0);
83MODULE_PARM_DESC(irq, "WDT irq (default=11)"); 83MODULE_PARM_DESC(irq, "WDT irq (default=11)");
84 84
85#ifdef CONFIG_WDT_501
86/* Support for the Fan Tachometer on the WDT501-P */ 85/* Support for the Fan Tachometer on the WDT501-P */
87static int tachometer; 86static int tachometer;
88
89module_param(tachometer, int, 0); 87module_param(tachometer, int, 0);
90MODULE_PARM_DESC(tachometer, 88MODULE_PARM_DESC(tachometer,
91 "WDT501-P Fan Tachometer support (0=disable, default=0)"); 89 "WDT501-P Fan Tachometer support (0=disable, default=0)");
92#endif /* CONFIG_WDT_501 */ 90
91static int type = 500;
92module_param(type, int, 0);
93MODULE_PARM_DESC(type,
94 "WDT501-P Card type (500 or 501 , default=500)");
93 95
94/* 96/*
95 * Programming support 97 * Programming support
@@ -158,7 +160,7 @@ static int wdt_stop(void)
158 * reloading the cascade counter. 160 * reloading the cascade counter.
159 */ 161 */
160 162
161static int wdt_ping(void) 163static void wdt_ping(void)
162{ 164{
163 unsigned long flags; 165 unsigned long flags;
164 spin_lock_irqsave(&wdt_lock, flags); 166 spin_lock_irqsave(&wdt_lock, flags);
@@ -169,7 +171,6 @@ static int wdt_ping(void)
169 wdt_ctr_load(1, wd_heartbeat); /* Heartbeat */ 171 wdt_ctr_load(1, wd_heartbeat); /* Heartbeat */
170 outb_p(0, WDT_DC); /* Enable watchdog */ 172 outb_p(0, WDT_DC); /* Enable watchdog */
171 spin_unlock_irqrestore(&wdt_lock, flags); 173 spin_unlock_irqrestore(&wdt_lock, flags);
172 return 0;
173} 174}
174 175
175/** 176/**
@@ -193,7 +194,6 @@ static int wdt_set_heartbeat(int t)
193 194
194/** 195/**
195 * wdt_get_status: 196 * wdt_get_status:
196 * @status: the new status.
197 * 197 *
198 * Extract the status information from a WDT watchdog device. There are 198 * Extract the status information from a WDT watchdog device. There are
199 * several board variants so we have to know which bits are valid. Some 199 * several board variants so we have to know which bits are valid. Some
@@ -202,36 +202,35 @@ static int wdt_set_heartbeat(int t)
202 * we then map the bits onto the status ioctl flags. 202 * we then map the bits onto the status ioctl flags.
203 */ 203 */
204 204
205static int wdt_get_status(int *status) 205static int wdt_get_status(void)
206{ 206{
207 unsigned char new_status; 207 unsigned char new_status;
208 int status = 0;
208 unsigned long flags; 209 unsigned long flags;
209 210
210 spin_lock_irqsave(&wdt_lock, flags); 211 spin_lock_irqsave(&wdt_lock, flags);
211 new_status = inb_p(WDT_SR); 212 new_status = inb_p(WDT_SR);
212 spin_unlock_irqrestore(&wdt_lock, flags); 213 spin_unlock_irqrestore(&wdt_lock, flags);
213 214
214 *status = 0;
215 if (new_status & WDC_SR_ISOI0) 215 if (new_status & WDC_SR_ISOI0)
216 *status |= WDIOF_EXTERN1; 216 status |= WDIOF_EXTERN1;
217 if (new_status & WDC_SR_ISII1) 217 if (new_status & WDC_SR_ISII1)
218 *status |= WDIOF_EXTERN2; 218 status |= WDIOF_EXTERN2;
219#ifdef CONFIG_WDT_501 219 if (type == 501) {
220 if (!(new_status & WDC_SR_TGOOD)) 220 if (!(new_status & WDC_SR_TGOOD))
221 *status |= WDIOF_OVERHEAT; 221 status |= WDIOF_OVERHEAT;
222 if (!(new_status & WDC_SR_PSUOVER)) 222 if (!(new_status & WDC_SR_PSUOVER))
223 *status |= WDIOF_POWEROVER; 223 status |= WDIOF_POWEROVER;
224 if (!(new_status & WDC_SR_PSUUNDR)) 224 if (!(new_status & WDC_SR_PSUUNDR))
225 *status |= WDIOF_POWERUNDER; 225 status |= WDIOF_POWERUNDER;
226 if (tachometer) { 226 if (tachometer) {
227 if (!(new_status & WDC_SR_FANGOOD)) 227 if (!(new_status & WDC_SR_FANGOOD))
228 *status |= WDIOF_FANFAULT; 228 status |= WDIOF_FANFAULT;
229 }
229 } 230 }
230#endif /* CONFIG_WDT_501 */ 231 return status;
231 return 0;
232} 232}
233 233
234#ifdef CONFIG_WDT_501
235/** 234/**
236 * wdt_get_temperature: 235 * wdt_get_temperature:
237 * 236 *
@@ -239,7 +238,7 @@ static int wdt_get_status(int *status)
239 * farenheit. It was designed by an imperial measurement luddite. 238 * farenheit. It was designed by an imperial measurement luddite.
240 */ 239 */
241 240
242static int wdt_get_temperature(int *temperature) 241static int wdt_get_temperature(void)
243{ 242{
244 unsigned short c; 243 unsigned short c;
245 unsigned long flags; 244 unsigned long flags;
@@ -247,10 +246,18 @@ static int wdt_get_temperature(int *temperature)
247 spin_lock_irqsave(&wdt_lock, flags); 246 spin_lock_irqsave(&wdt_lock, flags);
248 c = inb_p(WDT_RT); 247 c = inb_p(WDT_RT);
249 spin_unlock_irqrestore(&wdt_lock, flags); 248 spin_unlock_irqrestore(&wdt_lock, flags);
250 *temperature = (c * 11 / 15) + 7; 249 return (c * 11 / 15) + 7;
251 return 0; 250}
251
252static void wdt_decode_501(int status)
253{
254 if (!(status & WDC_SR_TGOOD))
255 printk(KERN_CRIT "Overheat alarm.(%d)\n", inb_p(WDT_RT));
256 if (!(status & WDC_SR_PSUOVER))
257 printk(KERN_CRIT "PSU over voltage.\n");
258 if (!(status & WDC_SR_PSUUNDR))
259 printk(KERN_CRIT "PSU under voltage.\n");
252} 260}
253#endif /* CONFIG_WDT_501 */
254 261
255/** 262/**
256 * wdt_interrupt: 263 * wdt_interrupt:
@@ -275,18 +282,13 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id)
275 282
276 printk(KERN_CRIT "WDT status %d\n", status); 283 printk(KERN_CRIT "WDT status %d\n", status);
277 284
278#ifdef CONFIG_WDT_501 285 if (type == 501) {
279 if (!(status & WDC_SR_TGOOD)) 286 wdt_decode_501(status);
280 printk(KERN_CRIT "Overheat alarm.(%d)\n", inb_p(WDT_RT)); 287 if (tachometer) {
281 if (!(status & WDC_SR_PSUOVER)) 288 if (!(status & WDC_SR_FANGOOD))
282 printk(KERN_CRIT "PSU over voltage.\n"); 289 printk(KERN_CRIT "Possible fan fault.\n");
283 if (!(status & WDC_SR_PSUUNDR)) 290 }
284 printk(KERN_CRIT "PSU under voltage.\n");
285 if (tachometer) {
286 if (!(status & WDC_SR_FANGOOD))
287 printk(KERN_CRIT "Possible fan fault.\n");
288 } 291 }
289#endif /* CONFIG_WDT_501 */
290 if (!(status & WDC_SR_WCCR)) { 292 if (!(status & WDC_SR_WCCR)) {
291#ifdef SOFTWARE_REBOOT 293#ifdef SOFTWARE_REBOOT
292#ifdef ONLY_TESTING 294#ifdef ONLY_TESTING
@@ -366,17 +368,18 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
366 368
367 /* Add options according to the card we have */ 369 /* Add options according to the card we have */
368 ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2); 370 ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
369#ifdef CONFIG_WDT_501 371 if (type == 501) {
370 ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER); 372 ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|
371 if (tachometer) 373 WDIOF_POWEROVER);
372 ident.options |= WDIOF_FANFAULT; 374 if (tachometer)
373#endif /* CONFIG_WDT_501 */ 375 ident.options |= WDIOF_FANFAULT;
376 }
374 377
375 switch (cmd) { 378 switch (cmd) {
376 case WDIOC_GETSUPPORT: 379 case WDIOC_GETSUPPORT:
377 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; 380 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
378 case WDIOC_GETSTATUS: 381 case WDIOC_GETSTATUS:
379 wdt_get_status(&status); 382 status = wdt_get_status();
380 return put_user(status, p); 383 return put_user(status, p);
381 case WDIOC_GETBOOTSTATUS: 384 case WDIOC_GETBOOTSTATUS:
382 return put_user(0, p); 385 return put_user(0, p);
@@ -446,7 +449,6 @@ static int wdt_release(struct inode *inode, struct file *file)
446 return 0; 449 return 0;
447} 450}
448 451
449#ifdef CONFIG_WDT_501
450/** 452/**
451 * wdt_temp_read: 453 * wdt_temp_read:
452 * @file: file handle to the watchdog board 454 * @file: file handle to the watchdog board
@@ -461,10 +463,7 @@ static int wdt_release(struct inode *inode, struct file *file)
461static ssize_t wdt_temp_read(struct file *file, char __user *buf, 463static ssize_t wdt_temp_read(struct file *file, char __user *buf,
462 size_t count, loff_t *ptr) 464 size_t count, loff_t *ptr)
463{ 465{
464 int temperature; 466 int temperature = wdt_get_temperature();
465
466 if (wdt_get_temperature(&temperature))
467 return -EFAULT;
468 467
469 if (copy_to_user(buf, &temperature, 1)) 468 if (copy_to_user(buf, &temperature, 1))
470 return -EFAULT; 469 return -EFAULT;
@@ -497,7 +496,6 @@ static int wdt_temp_release(struct inode *inode, struct file *file)
497{ 496{
498 return 0; 497 return 0;
499} 498}
500#endif /* CONFIG_WDT_501 */
501 499
502/** 500/**
503 * notify_sys: 501 * notify_sys:
@@ -539,7 +537,6 @@ static struct miscdevice wdt_miscdev = {
539 .fops = &wdt_fops, 537 .fops = &wdt_fops,
540}; 538};
541 539
542#ifdef CONFIG_WDT_501
543static const struct file_operations wdt_temp_fops = { 540static const struct file_operations wdt_temp_fops = {
544 .owner = THIS_MODULE, 541 .owner = THIS_MODULE,
545 .llseek = no_llseek, 542 .llseek = no_llseek,
@@ -553,7 +550,6 @@ static struct miscdevice temp_miscdev = {
553 .name = "temperature", 550 .name = "temperature",
554 .fops = &wdt_temp_fops, 551 .fops = &wdt_temp_fops,
555}; 552};
556#endif /* CONFIG_WDT_501 */
557 553
558/* 554/*
559 * The WDT card needs to learn about soft shutdowns in order to 555 * The WDT card needs to learn about soft shutdowns in order to
@@ -577,9 +573,8 @@ static struct notifier_block wdt_notifier = {
577static void __exit wdt_exit(void) 573static void __exit wdt_exit(void)
578{ 574{
579 misc_deregister(&wdt_miscdev); 575 misc_deregister(&wdt_miscdev);
580#ifdef CONFIG_WDT_501 576 if (type == 501)
581 misc_deregister(&temp_miscdev); 577 misc_deregister(&temp_miscdev);
582#endif /* CONFIG_WDT_501 */
583 unregister_reboot_notifier(&wdt_notifier); 578 unregister_reboot_notifier(&wdt_notifier);
584 free_irq(irq, NULL); 579 free_irq(irq, NULL);
585 release_region(io, 8); 580 release_region(io, 8);
@@ -597,12 +592,17 @@ static int __init wdt_init(void)
597{ 592{
598 int ret; 593 int ret;
599 594
595 if (type != 500 && type != 501) {
596 printk(KERN_ERR "wdt: unknown card type '%d'.\n", type);
597 return -ENODEV;
598 }
599
600 /* Check that the heartbeat value is within it's range; 600 /* Check that the heartbeat value is within it's range;
601 if not reset to the default */ 601 if not reset to the default */
602 if (wdt_set_heartbeat(heartbeat)) { 602 if (wdt_set_heartbeat(heartbeat)) {
603 wdt_set_heartbeat(WD_TIMO); 603 wdt_set_heartbeat(WD_TIMO);
604 printk(KERN_INFO "wdt: heartbeat value must be 0 < heartbeat < 65536, using %d\n", 604 printk(KERN_INFO "wdt: heartbeat value must be "
605 WD_TIMO); 605 "0 < heartbeat < 65536, using %d\n", WD_TIMO);
606 } 606 }
607 607
608 if (!request_region(io, 8, "wdt501p")) { 608 if (!request_region(io, 8, "wdt501p")) {
@@ -625,15 +625,14 @@ static int __init wdt_init(void)
625 goto outirq; 625 goto outirq;
626 } 626 }
627 627
628#ifdef CONFIG_WDT_501 628 if (type == 501) {
629 ret = misc_register(&temp_miscdev); 629 ret = misc_register(&temp_miscdev);
630 if (ret) { 630 if (ret) {
631 printk(KERN_ERR 631 printk(KERN_ERR "wdt: cannot register miscdev "
632 "wdt: cannot register miscdev on minor=%d (err=%d)\n", 632 "on minor=%d (err=%d)\n", TEMP_MINOR, ret);
633 TEMP_MINOR, ret); 633 goto outrbt;
634 goto outrbt; 634 }
635 } 635 }
636#endif /* CONFIG_WDT_501 */
637 636
638 ret = misc_register(&wdt_miscdev); 637 ret = misc_register(&wdt_miscdev);
639 if (ret) { 638 if (ret) {
@@ -643,28 +642,25 @@ static int __init wdt_init(void)
643 goto outmisc; 642 goto outmisc;
644 } 643 }
645 644
646 ret = 0; 645 printk(KERN_INFO "WDT500/501-P driver 0.10 "
647 printk(KERN_INFO "WDT500/501-P driver 0.10 at 0x%04x (Interrupt %d). heartbeat=%d sec (nowayout=%d)\n", 646 "at 0x%04x (Interrupt %d). heartbeat=%d sec (nowayout=%d)\n",
648 io, irq, heartbeat, nowayout); 647 io, irq, heartbeat, nowayout);
649#ifdef CONFIG_WDT_501 648 if (type == 501)
650 printk(KERN_INFO "wdt: Fan Tachometer is %s\n", 649 printk(KERN_INFO "wdt: Fan Tachometer is %s\n",
651 (tachometer ? "Enabled" : "Disabled")); 650 (tachometer ? "Enabled" : "Disabled"));
652#endif /* CONFIG_WDT_501 */ 651 return 0;
653
654out:
655 return ret;
656 652
657outmisc: 653outmisc:
658#ifdef CONFIG_WDT_501 654 if (type == 501)
659 misc_deregister(&temp_miscdev); 655 misc_deregister(&temp_miscdev);
660outrbt: 656outrbt:
661#endif /* CONFIG_WDT_501 */
662 unregister_reboot_notifier(&wdt_notifier); 657 unregister_reboot_notifier(&wdt_notifier);
663outirq: 658outirq:
664 free_irq(irq, NULL); 659 free_irq(irq, NULL);
665outreg: 660outreg:
666 release_region(io, 8); 661 release_region(io, 8);
667 goto out; 662out:
663 return ret;
668} 664}
669 665
670module_init(wdt_init); 666module_init(wdt_init);
diff --git a/drivers/watchdog/wdt977.c b/drivers/watchdog/wdt977.c
index 60e28d49ff52..90ef70eb47d7 100644
--- a/drivers/watchdog/wdt977.c
+++ b/drivers/watchdog/wdt977.c
@@ -401,7 +401,7 @@ static long wdt977_ioctl(struct file *file, unsigned int cmd,
401 return -EFAULT; 401 return -EFAULT;
402 402
403 if (wdt977_set_timeout(new_timeout)) 403 if (wdt977_set_timeout(new_timeout))
404 return -EINVAL; 404 return -EINVAL;
405 405
406 wdt977_keepalive(); 406 wdt977_keepalive();
407 /* Fall */ 407 /* Fall */