diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/watchdog/pcwd.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c index e952c9bc12bb..0e4b3dfa0084 100644 --- a/drivers/char/watchdog/pcwd.c +++ b/drivers/char/watchdog/pcwd.c | |||
@@ -158,6 +158,13 @@ static struct { /* this is private data for each ISA-PC watchdog card */ | |||
158 | } pcwd_private; | 158 | } pcwd_private; |
159 | 159 | ||
160 | /* module parameters */ | 160 | /* module parameters */ |
161 | #define QUIET 0 /* Default */ | ||
162 | #define VERBOSE 1 /* Verbose */ | ||
163 | #define DEBUG 2 /* print fancy stuff too */ | ||
164 | static int debug = QUIET; | ||
165 | module_param(debug, int, 0); | ||
166 | MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); | ||
167 | |||
161 | #define WATCHDOG_HEARTBEAT 60 /* 60 sec default heartbeat */ | 168 | #define WATCHDOG_HEARTBEAT 60 /* 60 sec default heartbeat */ |
162 | static int heartbeat = WATCHDOG_HEARTBEAT; | 169 | static int heartbeat = WATCHDOG_HEARTBEAT; |
163 | module_param(heartbeat, int, 0); | 170 | module_param(heartbeat, int, 0); |
@@ -177,6 +184,10 @@ static int send_isa_command(int cmd) | |||
177 | int control_status; | 184 | int control_status; |
178 | int port0, last_port0; /* Double read for stabilising */ | 185 | int port0, last_port0; /* Double read for stabilising */ |
179 | 186 | ||
187 | if (debug >= DEBUG) | ||
188 | printk(KERN_DEBUG PFX "sending following data cmd=0x%02x\n", | ||
189 | cmd); | ||
190 | |||
180 | /* The WCMD bit must be 1 and the command is only 4 bits in size */ | 191 | /* The WCMD bit must be 1 and the command is only 4 bits in size */ |
181 | control_status = (cmd & 0x0F) | WD_WCMD; | 192 | control_status = (cmd & 0x0F) | WD_WCMD; |
182 | outb_p(control_status, pcwd_private.io_addr + 2); | 193 | outb_p(control_status, pcwd_private.io_addr + 2); |
@@ -193,6 +204,10 @@ static int send_isa_command(int cmd) | |||
193 | udelay (250); | 204 | udelay (250); |
194 | } | 205 | } |
195 | 206 | ||
207 | if (debug >= DEBUG) | ||
208 | printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n", | ||
209 | cmd, port0, last_port0); | ||
210 | |||
196 | return port0; | 211 | return port0; |
197 | } | 212 | } |
198 | 213 | ||
@@ -219,6 +234,10 @@ static int set_command_mode(void) | |||
219 | spin_unlock(&pcwd_private.io_lock); | 234 | spin_unlock(&pcwd_private.io_lock); |
220 | pcwd_private.command_mode = found; | 235 | pcwd_private.command_mode = found; |
221 | 236 | ||
237 | if (debug >= DEBUG) | ||
238 | printk(KERN_DEBUG PFX "command_mode=%d\n", | ||
239 | pcwd_private.command_mode); | ||
240 | |||
222 | return(found); | 241 | return(found); |
223 | } | 242 | } |
224 | 243 | ||
@@ -231,6 +250,10 @@ static void unset_command_mode(void) | |||
231 | spin_unlock(&pcwd_private.io_lock); | 250 | spin_unlock(&pcwd_private.io_lock); |
232 | 251 | ||
233 | pcwd_private.command_mode = 0; | 252 | pcwd_private.command_mode = 0; |
253 | |||
254 | if (debug >= DEBUG) | ||
255 | printk(KERN_DEBUG PFX "command_mode=%d\n", | ||
256 | pcwd_private.command_mode); | ||
234 | } | 257 | } |
235 | 258 | ||
236 | static inline void pcwd_check_temperature_support(void) | 259 | static inline void pcwd_check_temperature_support(void) |
@@ -360,6 +383,10 @@ static int pcwd_start(void) | |||
360 | return -EIO; | 383 | return -EIO; |
361 | } | 384 | } |
362 | } | 385 | } |
386 | |||
387 | if (debug >= VERBOSE) | ||
388 | printk(KERN_DEBUG PFX "Watchdog started\n"); | ||
389 | |||
363 | return 0; | 390 | return 0; |
364 | } | 391 | } |
365 | 392 | ||
@@ -384,6 +411,10 @@ static int pcwd_stop(void) | |||
384 | return -EIO; | 411 | return -EIO; |
385 | } | 412 | } |
386 | } | 413 | } |
414 | |||
415 | if (debug >= VERBOSE) | ||
416 | printk(KERN_DEBUG PFX "Watchdog stopped\n"); | ||
417 | |||
387 | return 0; | 418 | return 0; |
388 | } | 419 | } |
389 | 420 | ||
@@ -391,6 +422,10 @@ static int pcwd_keepalive(void) | |||
391 | { | 422 | { |
392 | /* user land ping */ | 423 | /* user land ping */ |
393 | pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ); | 424 | pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ); |
425 | |||
426 | if (debug >= DEBUG) | ||
427 | printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); | ||
428 | |||
394 | return 0; | 429 | return 0; |
395 | } | 430 | } |
396 | 431 | ||
@@ -400,6 +435,11 @@ static int pcwd_set_heartbeat(int t) | |||
400 | return -EINVAL; | 435 | return -EINVAL; |
401 | 436 | ||
402 | heartbeat = t; | 437 | heartbeat = t; |
438 | |||
439 | if (debug >= VERBOSE) | ||
440 | printk(KERN_DEBUG PFX "New heartbeat: %d\n", | ||
441 | heartbeat); | ||
442 | |||
403 | return 0; | 443 | return 0; |
404 | } | 444 | } |
405 | 445 | ||
@@ -458,8 +498,17 @@ static int pcwd_clear_status(void) | |||
458 | if (pcwd_private.revision == PCWD_REVISION_C) { | 498 | if (pcwd_private.revision == PCWD_REVISION_C) { |
459 | spin_lock(&pcwd_private.io_lock); | 499 | spin_lock(&pcwd_private.io_lock); |
460 | 500 | ||
501 | if (debug >= VERBOSE) | ||
502 | printk(KERN_INFO PFX "clearing watchdog trip status\n"); | ||
503 | |||
461 | control_status = inb_p(pcwd_private.io_addr + 1); | 504 | control_status = inb_p(pcwd_private.io_addr + 1); |
462 | 505 | ||
506 | if (debug >= DEBUG) { | ||
507 | printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status); | ||
508 | printk(KERN_DEBUG PFX "sending: 0x%02x\n", | ||
509 | (control_status & WD_REVC_R2DS)); | ||
510 | } | ||
511 | |||
463 | /* clear reset status & Keep Relay 2 disable state as it is */ | 512 | /* clear reset status & Keep Relay 2 disable state as it is */ |
464 | outb_p((control_status & WD_REVC_R2DS), pcwd_private.io_addr + 1); | 513 | outb_p((control_status & WD_REVC_R2DS), pcwd_private.io_addr + 1); |
465 | 514 | ||
@@ -486,6 +535,11 @@ static int pcwd_get_temperature(int *temperature) | |||
486 | *temperature = ((inb(pcwd_private.io_addr)) * 9 / 5) + 32; | 535 | *temperature = ((inb(pcwd_private.io_addr)) * 9 / 5) + 32; |
487 | spin_unlock(&pcwd_private.io_lock); | 536 | spin_unlock(&pcwd_private.io_lock); |
488 | 537 | ||
538 | if (debug >= DEBUG) { | ||
539 | printk(KERN_DEBUG PFX "temperature is: %d F\n", | ||
540 | *temperature); | ||
541 | } | ||
542 | |||
489 | return 0; | 543 | return 0; |
490 | } | 544 | } |
491 | 545 | ||
@@ -604,6 +658,8 @@ static ssize_t pcwd_write(struct file *file, const char __user *buf, size_t len, | |||
604 | static int pcwd_open(struct inode *inode, struct file *file) | 658 | static int pcwd_open(struct inode *inode, struct file *file) |
605 | { | 659 | { |
606 | if (!atomic_dec_and_test(&open_allowed) ) { | 660 | if (!atomic_dec_and_test(&open_allowed) ) { |
661 | if (debug >= VERBOSE) | ||
662 | printk(KERN_ERR PFX "Attempt to open already opened device.\n"); | ||
607 | atomic_inc( &open_allowed ); | 663 | atomic_inc( &open_allowed ); |
608 | return -EBUSY; | 664 | return -EBUSY; |
609 | } | 665 | } |