aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/watchdog/pcwd.c
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2006-01-09 15:53:33 -0500
committerWim Van Sebroeck <wim@iguana.be>2006-02-12 08:46:25 -0500
commita2be8786006ec0d21dcb1d322fc480b85ea82c66 (patch)
tree810324396cf784d1b057d11a476795faa095026e /drivers/char/watchdog/pcwd.c
parentf1c3a0567aa5086e755e58385740f9ece911c06e (diff)
[WATCHDOG] pcwd.c private data struct patch
more private data of the card to one struct. Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/char/watchdog/pcwd.c')
-rw-r--r--drivers/char/watchdog/pcwd.c206
1 files changed, 104 insertions, 102 deletions
diff --git a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c
index 3329cbffdb34..1112ec8e61f3 100644
--- a/drivers/char/watchdog/pcwd.c
+++ b/drivers/char/watchdog/pcwd.c
@@ -73,7 +73,7 @@
73#include <asm/io.h> /* For inb/outb/... */ 73#include <asm/io.h> /* For inb/outb/... */
74 74
75/* Module and version information */ 75/* Module and version information */
76#define WD_VER "1.16 (06/12/2004)" 76#define WD_VER "1.16 (03/01/2006)"
77#define PFX "pcwd: " 77#define PFX "pcwd: "
78 78
79/* 79/*
@@ -133,15 +133,17 @@ static int cards_found;
133/* internal variables */ 133/* internal variables */
134static atomic_t open_allowed = ATOMIC_INIT(1); 134static atomic_t open_allowed = ATOMIC_INIT(1);
135static char expect_close; 135static char expect_close;
136static struct timer_list timer;
137static unsigned long next_heartbeat;
138static int temp_panic; 136static int temp_panic;
139static int revision; /* The card's revision */ 137static struct { /* this is private data for each ISA-PC watchdog card */
140static int supports_temp; /* Wether or not the card has a temperature device */ 138 int revision; /* The card's revision */
141static int command_mode; /* Wether or not the card is in command mode */ 139 int supports_temp; /* Wether or not the card has a temperature device */
142static int initial_status; /* The card's boot status */ 140 int command_mode; /* Wether or not the card is in command mode */
143static int current_readport; /* The cards I/O address */ 141 int boot_status; /* The card's boot status */
144static spinlock_t io_lock; 142 int io_addr; /* The cards I/O address */
143 spinlock_t io_lock; /* the lock for io operations */
144 struct timer_list timer; /* The timer that pings the watchdog */
145 unsigned long next_heartbeat; /* the next_heartbeat for the timer */
146} pcwd_private;
145 147
146/* module parameters */ 148/* module parameters */
147#define WATCHDOG_HEARTBEAT 60 /* 60 sec default heartbeat */ 149#define WATCHDOG_HEARTBEAT 60 /* 60 sec default heartbeat */
@@ -165,13 +167,13 @@ static int send_isa_command(int cmd)
165 167
166 /* The WCMD bit must be 1 and the command is only 4 bits in size */ 168 /* The WCMD bit must be 1 and the command is only 4 bits in size */
167 control_status = (cmd & 0x0F) | 0x80; 169 control_status = (cmd & 0x0F) | 0x80;
168 outb_p(control_status, current_readport + 2); 170 outb_p(control_status, pcwd_private.io_addr + 2);
169 udelay(ISA_COMMAND_TIMEOUT); 171 udelay(ISA_COMMAND_TIMEOUT);
170 172
171 port0 = inb_p(current_readport); 173 port0 = inb_p(pcwd_private.io_addr);
172 for (i = 0; i < 25; ++i) { 174 for (i = 0; i < 25; ++i) {
173 last_port0 = port0; 175 last_port0 = port0;
174 port0 = inb_p(current_readport); 176 port0 = inb_p(pcwd_private.io_addr);
175 177
176 if (port0 == last_port0) 178 if (port0 == last_port0)
177 break; /* Data is stable */ 179 break; /* Data is stable */
@@ -187,7 +189,7 @@ static int set_command_mode(void)
187 int i, found=0, count=0; 189 int i, found=0, count=0;
188 190
189 /* Set the card into command mode */ 191 /* Set the card into command mode */
190 spin_lock(&io_lock); 192 spin_lock(&pcwd_private.io_lock);
191 while ((!found) && (count < 3)) { 193 while ((!found) && (count < 3)) {
192 i = send_isa_command(CMD_ISA_IDLE); 194 i = send_isa_command(CMD_ISA_IDLE);
193 195
@@ -195,15 +197,15 @@ static int set_command_mode(void)
195 found = 1; 197 found = 1;
196 else if (i == 0xF3) { 198 else if (i == 0xF3) {
197 /* Card does not like what we've done to it */ 199 /* Card does not like what we've done to it */
198 outb_p(0x00, current_readport + 2); 200 outb_p(0x00, pcwd_private.io_addr + 2);
199 udelay(1200); /* Spec says wait 1ms */ 201 udelay(1200); /* Spec says wait 1ms */
200 outb_p(0x00, current_readport + 2); 202 outb_p(0x00, pcwd_private.io_addr + 2);
201 udelay(ISA_COMMAND_TIMEOUT); 203 udelay(ISA_COMMAND_TIMEOUT);
202 } 204 }
203 count++; 205 count++;
204 } 206 }
205 spin_unlock(&io_lock); 207 spin_unlock(&pcwd_private.io_lock);
206 command_mode = found; 208 pcwd_private.command_mode = found;
207 209
208 return(found); 210 return(found);
209} 211}
@@ -211,12 +213,12 @@ static int set_command_mode(void)
211static void unset_command_mode(void) 213static void unset_command_mode(void)
212{ 214{
213 /* Set the card into normal mode */ 215 /* Set the card into normal mode */
214 spin_lock(&io_lock); 216 spin_lock(&pcwd_private.io_lock);
215 outb_p(0x00, current_readport + 2); 217 outb_p(0x00, pcwd_private.io_addr + 2);
216 udelay(ISA_COMMAND_TIMEOUT); 218 udelay(ISA_COMMAND_TIMEOUT);
217 spin_unlock(&io_lock); 219 spin_unlock(&pcwd_private.io_lock);
218 220
219 command_mode = 0; 221 pcwd_private.command_mode = 0;
220} 222}
221 223
222static void pcwd_timer_ping(unsigned long data) 224static void pcwd_timer_ping(unsigned long data)
@@ -225,25 +227,25 @@ static void pcwd_timer_ping(unsigned long data)
225 227
226 /* If we got a heartbeat pulse within the WDT_INTERVAL 228 /* If we got a heartbeat pulse within the WDT_INTERVAL
227 * we agree to ping the WDT */ 229 * we agree to ping the WDT */
228 if(time_before(jiffies, next_heartbeat)) { 230 if(time_before(jiffies, pcwd_private.next_heartbeat)) {
229 /* Ping the watchdog */ 231 /* Ping the watchdog */
230 spin_lock(&io_lock); 232 spin_lock(&pcwd_private.io_lock);
231 if (revision == PCWD_REVISION_A) { 233 if (pcwd_private.revision == PCWD_REVISION_A) {
232 /* Rev A cards are reset by setting the WD_WDRST bit in register 1 */ 234 /* Rev A cards are reset by setting the WD_WDRST bit in register 1 */
233 wdrst_stat = inb_p(current_readport); 235 wdrst_stat = inb_p(pcwd_private.io_addr);
234 wdrst_stat &= 0x0F; 236 wdrst_stat &= 0x0F;
235 wdrst_stat |= WD_WDRST; 237 wdrst_stat |= WD_WDRST;
236 238
237 outb_p(wdrst_stat, current_readport + 1); 239 outb_p(wdrst_stat, pcwd_private.io_addr + 1);
238 } else { 240 } else {
239 /* Re-trigger watchdog by writing to port 0 */ 241 /* Re-trigger watchdog by writing to port 0 */
240 outb_p(0x00, current_readport); 242 outb_p(0x00, pcwd_private.io_addr);
241 } 243 }
242 244
243 /* Re-set the timer interval */ 245 /* Re-set the timer interval */
244 mod_timer(&timer, jiffies + WDT_INTERVAL); 246 mod_timer(&pcwd_private.timer, jiffies + WDT_INTERVAL);
245 247
246 spin_unlock(&io_lock); 248 spin_unlock(&pcwd_private.io_lock);
247 } else { 249 } else {
248 printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); 250 printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n");
249 } 251 }
@@ -253,18 +255,18 @@ static int pcwd_start(void)
253{ 255{
254 int stat_reg; 256 int stat_reg;
255 257
256 next_heartbeat = jiffies + (heartbeat * HZ); 258 pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ);
257 259
258 /* Start the timer */ 260 /* Start the timer */
259 mod_timer(&timer, jiffies + WDT_INTERVAL); 261 mod_timer(&pcwd_private.timer, jiffies + WDT_INTERVAL);
260 262
261 /* Enable the port */ 263 /* Enable the port */
262 if (revision == PCWD_REVISION_C) { 264 if (pcwd_private.revision == PCWD_REVISION_C) {
263 spin_lock(&io_lock); 265 spin_lock(&pcwd_private.io_lock);
264 outb_p(0x00, current_readport + 3); 266 outb_p(0x00, pcwd_private.io_addr + 3);
265 udelay(ISA_COMMAND_TIMEOUT); 267 udelay(ISA_COMMAND_TIMEOUT);
266 stat_reg = inb_p(current_readport + 2); 268 stat_reg = inb_p(pcwd_private.io_addr + 2);
267 spin_unlock(&io_lock); 269 spin_unlock(&pcwd_private.io_lock);
268 if (stat_reg & 0x10) { 270 if (stat_reg & 0x10) {
269 printk(KERN_INFO PFX "Could not start watchdog\n"); 271 printk(KERN_INFO PFX "Could not start watchdog\n");
270 return -EIO; 272 return -EIO;
@@ -278,17 +280,17 @@ static int pcwd_stop(void)
278 int stat_reg; 280 int stat_reg;
279 281
280 /* Stop the timer */ 282 /* Stop the timer */
281 del_timer(&timer); 283 del_timer(&pcwd_private.timer);
282 284
283 /* Disable the board */ 285 /* Disable the board */
284 if (revision == PCWD_REVISION_C) { 286 if (pcwd_private.revision == PCWD_REVISION_C) {
285 spin_lock(&io_lock); 287 spin_lock(&pcwd_private.io_lock);
286 outb_p(0xA5, current_readport + 3); 288 outb_p(0xA5, pcwd_private.io_addr + 3);
287 udelay(ISA_COMMAND_TIMEOUT); 289 udelay(ISA_COMMAND_TIMEOUT);
288 outb_p(0xA5, current_readport + 3); 290 outb_p(0xA5, pcwd_private.io_addr + 3);
289 udelay(ISA_COMMAND_TIMEOUT); 291 udelay(ISA_COMMAND_TIMEOUT);
290 stat_reg = inb_p(current_readport + 2); 292 stat_reg = inb_p(pcwd_private.io_addr + 2);
291 spin_unlock(&io_lock); 293 spin_unlock(&pcwd_private.io_lock);
292 if ((stat_reg & 0x10) == 0) { 294 if ((stat_reg & 0x10) == 0) {
293 printk(KERN_INFO PFX "Could not stop watchdog\n"); 295 printk(KERN_INFO PFX "Could not stop watchdog\n");
294 return -EIO; 296 return -EIO;
@@ -300,7 +302,7 @@ static int pcwd_stop(void)
300static int pcwd_keepalive(void) 302static int pcwd_keepalive(void)
301{ 303{
302 /* user land ping */ 304 /* user land ping */
303 next_heartbeat = jiffies + (heartbeat * HZ); 305 pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ);
304 return 0; 306 return 0;
305} 307}
306 308
@@ -318,23 +320,23 @@ static int pcwd_get_status(int *status)
318 int card_status; 320 int card_status;
319 321
320 *status=0; 322 *status=0;
321 spin_lock(&io_lock); 323 spin_lock(&pcwd_private.io_lock);
322 if (revision == PCWD_REVISION_A) 324 if (pcwd_private.revision == PCWD_REVISION_A)
323 /* Rev A cards return status information from 325 /* Rev A cards return status information from
324 * the base register, which is used for the 326 * the base register, which is used for the
325 * temperature in other cards. */ 327 * temperature in other cards. */
326 card_status = inb(current_readport); 328 card_status = inb(pcwd_private.io_addr);
327 else { 329 else {
328 /* Rev C cards return card status in the base 330 /* Rev C cards return card status in the base
329 * address + 1 register. And use different bits 331 * address + 1 register. And use different bits
330 * to indicate a card initiated reset, and an 332 * to indicate a card initiated reset, and an
331 * over-temperature condition. And the reboot 333 * over-temperature condition. And the reboot
332 * status can be reset. */ 334 * status can be reset. */
333 card_status = inb(current_readport + 1); 335 card_status = inb(pcwd_private.io_addr + 1);
334 } 336 }
335 spin_unlock(&io_lock); 337 spin_unlock(&pcwd_private.io_lock);
336 338
337 if (revision == PCWD_REVISION_A) { 339 if (pcwd_private.revision == PCWD_REVISION_A) {
338 if (card_status & WD_WDRST) 340 if (card_status & WD_WDRST)
339 *status |= WDIOF_CARDRESET; 341 *status |= WDIOF_CARDRESET;
340 342
@@ -363,10 +365,10 @@ static int pcwd_get_status(int *status)
363 365
364static int pcwd_clear_status(void) 366static int pcwd_clear_status(void)
365{ 367{
366 if (revision == PCWD_REVISION_C) { 368 if (pcwd_private.revision == PCWD_REVISION_C) {
367 spin_lock(&io_lock); 369 spin_lock(&pcwd_private.io_lock);
368 outb_p(0x00, current_readport + 1); /* clear reset status */ 370 outb_p(0x00, pcwd_private.io_addr + 1); /* clear reset status */
369 spin_unlock(&io_lock); 371 spin_unlock(&pcwd_private.io_lock);
370 } 372 }
371 return 0; 373 return 0;
372} 374}
@@ -374,20 +376,20 @@ static int pcwd_clear_status(void)
374static int pcwd_get_temperature(int *temperature) 376static int pcwd_get_temperature(int *temperature)
375{ 377{
376 /* check that port 0 gives temperature info and no command results */ 378 /* check that port 0 gives temperature info and no command results */
377 if (command_mode) 379 if (pcwd_private.command_mode)
378 return -1; 380 return -1;
379 381
380 *temperature = 0; 382 *temperature = 0;
381 if (!supports_temp) 383 if (!pcwd_private.supports_temp)
382 return -ENODEV; 384 return -ENODEV;
383 385
384 /* 386 /*
385 * Convert celsius to fahrenheit, since this was 387 * Convert celsius to fahrenheit, since this was
386 * the decided 'standard' for this return value. 388 * the decided 'standard' for this return value.
387 */ 389 */
388 spin_lock(&io_lock); 390 spin_lock(&pcwd_private.io_lock);
389 *temperature = ((inb(current_readport)) * 9 / 5) + 32; 391 *temperature = ((inb(pcwd_private.io_addr)) * 9 / 5) + 32;
390 spin_unlock(&io_lock); 392 spin_unlock(&pcwd_private.io_lock);
391 393
392 return 0; 394 return 0;
393} 395}
@@ -428,7 +430,7 @@ static int pcwd_ioctl(struct inode *inode, struct file *file,
428 return put_user(status, argp); 430 return put_user(status, argp);
429 431
430 case WDIOC_GETBOOTSTATUS: 432 case WDIOC_GETBOOTSTATUS:
431 return put_user(initial_status, argp); 433 return put_user(pcwd_private.boot_status, argp);
432 434
433 case WDIOC_GETTEMP: 435 case WDIOC_GETTEMP:
434 if (pcwd_get_temperature(&temperature)) 436 if (pcwd_get_temperature(&temperature))
@@ -437,7 +439,7 @@ static int pcwd_ioctl(struct inode *inode, struct file *file,
437 return put_user(temperature, argp); 439 return put_user(temperature, argp);
438 440
439 case WDIOC_SETOPTIONS: 441 case WDIOC_SETOPTIONS:
440 if (revision == PCWD_REVISION_C) 442 if (pcwd_private.revision == PCWD_REVISION_C)
441 { 443 {
442 if(copy_from_user(&rv, argp, sizeof(int))) 444 if(copy_from_user(&rv, argp, sizeof(int)))
443 return -EFAULT; 445 return -EFAULT;
@@ -553,7 +555,7 @@ static ssize_t pcwd_temp_read(struct file *file, char __user *buf, size_t count,
553 555
554static int pcwd_temp_open(struct inode *inode, struct file *file) 556static int pcwd_temp_open(struct inode *inode, struct file *file)
555{ 557{
556 if (!supports_temp) 558 if (!pcwd_private.supports_temp)
557 return -ENODEV; 559 return -ENODEV;
558 560
559 return nonseekable_open(inode, file); 561 return nonseekable_open(inode, file);
@@ -621,21 +623,21 @@ static struct notifier_block pcwd_notifier = {
621 623
622static inline void get_support(void) 624static inline void get_support(void)
623{ 625{
624 if (inb(current_readport) != 0xF0) 626 if (inb(pcwd_private.io_addr) != 0xF0)
625 supports_temp = 1; 627 pcwd_private.supports_temp = 1;
626} 628}
627 629
628static inline int get_revision(void) 630static inline int get_revision(void)
629{ 631{
630 int r = PCWD_REVISION_C; 632 int r = PCWD_REVISION_C;
631 633
632 spin_lock(&io_lock); 634 spin_lock(&pcwd_private.io_lock);
633 /* REV A cards use only 2 io ports; test 635 /* REV A cards use only 2 io ports; test
634 * presumes a floating bus reads as 0xff. */ 636 * presumes a floating bus reads as 0xff. */
635 if ((inb(current_readport + 2) == 0xFF) || 637 if ((inb(pcwd_private.io_addr + 2) == 0xFF) ||
636 (inb(current_readport + 3) == 0xFF)) 638 (inb(pcwd_private.io_addr + 3) == 0xFF))
637 r=PCWD_REVISION_A; 639 r=PCWD_REVISION_A;
638 spin_unlock(&io_lock); 640 spin_unlock(&pcwd_private.io_lock);
639 641
640 return r; 642 return r;
641} 643}
@@ -695,32 +697,32 @@ static int __devinit pcwatchdog_init(int base_addr)
695 printk(KERN_ERR PFX "No I/O-Address for card detected\n"); 697 printk(KERN_ERR PFX "No I/O-Address for card detected\n");
696 return -ENODEV; 698 return -ENODEV;
697 } 699 }
698 current_readport = base_addr; 700 pcwd_private.io_addr = base_addr;
699 701
700 /* Check card's revision */ 702 /* Check card's revision */
701 revision = get_revision(); 703 pcwd_private.revision = get_revision();
702 704
703 if (!request_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) { 705 if (!request_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) {
704 printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", 706 printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",
705 current_readport); 707 pcwd_private.io_addr);
706 current_readport = 0x0000; 708 pcwd_private.io_addr = 0x0000;
707 return -EIO; 709 return -EIO;
708 } 710 }
709 711
710 /* Initial variables */ 712 /* Initial variables */
711 supports_temp = 0; 713 pcwd_private.supports_temp = 0;
712 temp_panic = 0; 714 temp_panic = 0;
713 initial_status = 0x0000; 715 pcwd_private.boot_status = 0x0000;
714 716
715 /* get the boot_status */ 717 /* get the boot_status */
716 pcwd_get_status(&initial_status); 718 pcwd_get_status(&pcwd_private.boot_status);
717 719
718 /* clear the "card caused reboot" flag */ 720 /* clear the "card caused reboot" flag */
719 pcwd_clear_status(); 721 pcwd_clear_status();
720 722
721 init_timer(&timer); 723 init_timer(&pcwd_private.timer);
722 timer.function = pcwd_timer_ping; 724 pcwd_private.timer.function = pcwd_timer_ping;
723 timer.data = 0; 725 pcwd_private.timer.data = 0;
724 726
725 /* Disable the board */ 727 /* Disable the board */
726 pcwd_stop(); 728 pcwd_stop();
@@ -729,12 +731,12 @@ static int __devinit pcwatchdog_init(int base_addr)
729 get_support(); 731 get_support();
730 732
731 /* Get some extra info from the hardware (in command/debug/diag mode) */ 733 /* Get some extra info from the hardware (in command/debug/diag mode) */
732 if (revision == PCWD_REVISION_A) 734 if (pcwd_private.revision == PCWD_REVISION_A)
733 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", current_readport); 735 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr);
734 else if (revision == PCWD_REVISION_C) { 736 else if (pcwd_private.revision == PCWD_REVISION_C) {
735 firmware = get_firmware(); 737 firmware = get_firmware();
736 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n", 738 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n",
737 current_readport, firmware); 739 pcwd_private.io_addr, firmware);
738 kfree(firmware); 740 kfree(firmware);
739 option_switches = get_option_switches(); 741 option_switches = get_option_switches();
740 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", 742 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
@@ -750,23 +752,23 @@ static int __devinit pcwatchdog_init(int base_addr)
750 } else { 752 } else {
751 /* Should NEVER happen, unless get_revision() fails. */ 753 /* Should NEVER happen, unless get_revision() fails. */
752 printk(KERN_INFO PFX "Unable to get revision\n"); 754 printk(KERN_INFO PFX "Unable to get revision\n");
753 release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4); 755 release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);
754 current_readport = 0x0000; 756 pcwd_private.io_addr = 0x0000;
755 return -1; 757 return -1;
756 } 758 }
757 759
758 if (supports_temp) 760 if (pcwd_private.supports_temp)
759 printk(KERN_INFO PFX "Temperature Option Detected\n"); 761 printk(KERN_INFO PFX "Temperature Option Detected\n");
760 762
761 if (initial_status & WDIOF_CARDRESET) 763 if (pcwd_private.boot_status & WDIOF_CARDRESET)
762 printk(KERN_INFO PFX "Previous reboot was caused by the card\n"); 764 printk(KERN_INFO PFX "Previous reboot was caused by the card\n");
763 765
764 if (initial_status & WDIOF_OVERHEAT) { 766 if (pcwd_private.boot_status & WDIOF_OVERHEAT) {
765 printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n"); 767 printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n");
766 printk(KERN_EMERG PFX "CPU Overheat\n"); 768 printk(KERN_EMERG PFX "CPU Overheat\n");
767 } 769 }
768 770
769 if (initial_status == 0) 771 if (pcwd_private.boot_status == 0)
770 printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n"); 772 printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");
771 773
772 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 774 /* Check that the heartbeat value is within it's range ; if not reset to the default */
@@ -780,19 +782,19 @@ static int __devinit pcwatchdog_init(int base_addr)
780 if (ret) { 782 if (ret) {
781 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", 783 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
782 ret); 784 ret);
783 release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4); 785 release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);
784 current_readport = 0x0000; 786 pcwd_private.io_addr = 0x0000;
785 return ret; 787 return ret;
786 } 788 }
787 789
788 if (supports_temp) { 790 if (pcwd_private.supports_temp) {
789 ret = misc_register(&temp_miscdev); 791 ret = misc_register(&temp_miscdev);
790 if (ret) { 792 if (ret) {
791 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 793 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
792 TEMP_MINOR, ret); 794 TEMP_MINOR, ret);
793 unregister_reboot_notifier(&pcwd_notifier); 795 unregister_reboot_notifier(&pcwd_notifier);
794 release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4); 796 release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);
795 current_readport = 0x0000; 797 pcwd_private.io_addr = 0x0000;
796 return ret; 798 return ret;
797 } 799 }
798 } 800 }
@@ -801,11 +803,11 @@ static int __devinit pcwatchdog_init(int base_addr)
801 if (ret) { 803 if (ret) {
802 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", 804 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
803 WATCHDOG_MINOR, ret); 805 WATCHDOG_MINOR, ret);
804 if (supports_temp) 806 if (pcwd_private.supports_temp)
805 misc_deregister(&temp_miscdev); 807 misc_deregister(&temp_miscdev);
806 unregister_reboot_notifier(&pcwd_notifier); 808 unregister_reboot_notifier(&pcwd_notifier);
807 release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4); 809 release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);
808 current_readport = 0x0000; 810 pcwd_private.io_addr = 0x0000;
809 return ret; 811 return ret;
810 } 812 }
811 813
@@ -823,11 +825,11 @@ static void __devexit pcwatchdog_exit(void)
823 825
824 /* Deregister */ 826 /* Deregister */
825 misc_deregister(&pcwd_miscdev); 827 misc_deregister(&pcwd_miscdev);
826 if (supports_temp) 828 if (pcwd_private.supports_temp)
827 misc_deregister(&temp_miscdev); 829 misc_deregister(&temp_miscdev);
828 unregister_reboot_notifier(&pcwd_notifier); 830 unregister_reboot_notifier(&pcwd_notifier);
829 release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4); 831 release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);
830 current_readport = 0x0000; 832 pcwd_private.io_addr = 0x0000;
831 cards_found--; 833 cards_found--;
832} 834}
833 835
@@ -891,7 +893,7 @@ static int __init pcwd_init_module(void)
891{ 893{
892 int i, found = 0; 894 int i, found = 0;
893 895
894 spin_lock_init(&io_lock); 896 spin_lock_init(&pcwd_private.io_lock);
895 897
896 for (i = 0; pcwd_ioports[i] != 0; i++) { 898 for (i = 0; pcwd_ioports[i] != 0; i++) {
897 if (pcwd_checkcard(pcwd_ioports[i])) { 899 if (pcwd_checkcard(pcwd_ioports[i])) {
@@ -910,7 +912,7 @@ static int __init pcwd_init_module(void)
910 912
911static void __exit pcwd_cleanup_module(void) 913static void __exit pcwd_cleanup_module(void)
912{ 914{
913 if (current_readport) 915 if (pcwd_private.io_addr)
914 pcwatchdog_exit(); 916 pcwatchdog_exit();
915 return; 917 return;
916} 918}