[WATCHDOG] pcwd_pci.c add debug module_param

Add debugging code for the pcwd_pci driver.

Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

+64
+64
drivers/char/watchdog/pcwd_pci.c
··· 111 } pcipcwd_private; 112 113 /* module parameters */ 114 #define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ 115 static int heartbeat = WATCHDOG_HEARTBEAT; 116 module_param(heartbeat, int, 0); ··· 134 static int send_command(int cmd, int *msb, int *lsb) 135 { 136 int got_response, count; 137 138 spin_lock(&pcipcwd_private.io_lock); 139 /* If a command requires data it should be written first. ··· 159 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; 160 } 161 162 if (got_response) { 163 /* read back response */ 164 *lsb = inb_p(pcipcwd_private.io_addr + 4); ··· 175 176 /* clear WRSP bit */ 177 inb_p(pcipcwd_private.io_addr + 6); 178 } 179 spin_unlock(&pcipcwd_private.io_lock); 180 181 return got_response; ··· 251 return -1; 252 } 253 254 return 0; 255 } 256 ··· 276 return -1; 277 } 278 279 return 0; 280 } 281 ··· 286 { 287 /* Re-trigger watchdog by writing to port 0 */ 288 outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */ 289 return 0; 290 } 291 ··· 305 send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb); 306 307 heartbeat = t; 308 return 0; 309 } 310 ··· 326 panic(PFX "Temperature overheat trip!\n"); 327 } 328 329 return 0; 330 } 331 ··· 339 int msb; 340 int reset_counter; 341 342 control_status = inb_p(pcipcwd_private.io_addr + 1); 343 344 /* clear trip status & LED and keep mode of relay 2 */ 345 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1); ··· 357 msb=0; 358 reset_counter=0xff; 359 send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter); 360 361 return 0; 362 } ··· 379 * the decided 'standard' for this return value. 380 */ 381 *temperature = (*temperature * 9 / 5) + 32; 382 383 return 0; 384 } ··· 519 { 520 /* /dev/watchdog can only be opened once */ 521 if (test_and_set_bit(0, &is_active)) { 522 return -EBUSY; 523 } 524
··· 111 } pcipcwd_private; 112 113 /* module parameters */ 114 + #define QUIET 0 /* Default */ 115 + #define VERBOSE 1 /* Verbose */ 116 + #define DEBUG 2 /* print fancy stuff too */ 117 + static int debug = QUIET; 118 + module_param(debug, int, 0); 119 + MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); 120 + 121 #define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ 122 static int heartbeat = WATCHDOG_HEARTBEAT; 123 module_param(heartbeat, int, 0); ··· 127 static int send_command(int cmd, int *msb, int *lsb) 128 { 129 int got_response, count; 130 + 131 + if (debug >= DEBUG) 132 + printk(KERN_DEBUG PFX "sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n", 133 + cmd, *msb, *lsb); 134 135 spin_lock(&pcipcwd_private.io_lock); 136 /* If a command requires data it should be written first. ··· 148 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; 149 } 150 151 + if (debug >= DEBUG) { 152 + if (got_response) { 153 + printk(KERN_DEBUG PFX "time to process command was: %d ms\n", 154 + count); 155 + } else { 156 + printk(KERN_DEBUG PFX "card did not respond on command!\n"); 157 + } 158 + } 159 + 160 if (got_response) { 161 /* read back response */ 162 *lsb = inb_p(pcipcwd_private.io_addr + 4); ··· 155 156 /* clear WRSP bit */ 157 inb_p(pcipcwd_private.io_addr + 6); 158 + 159 + if (debug >= DEBUG) 160 + printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n", 161 + cmd, *msb, *lsb); 162 } 163 + 164 spin_unlock(&pcipcwd_private.io_lock); 165 166 return got_response; ··· 226 return -1; 227 } 228 229 + if (debug >= VERBOSE) 230 + printk(KERN_DEBUG PFX "Watchdog started\n"); 231 + 232 return 0; 233 } 234 ··· 248 return -1; 249 } 250 251 + if (debug >= VERBOSE) 252 + printk(KERN_DEBUG PFX "Watchdog stopped\n"); 253 + 254 return 0; 255 } 256 ··· 255 { 256 /* Re-trigger watchdog by writing to port 0 */ 257 outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */ 258 + 259 + if (debug >= DEBUG) 260 + printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); 261 + 262 return 0; 263 } 264 ··· 270 send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb); 271 272 heartbeat = t; 273 + if (debug >= VERBOSE) 274 + printk(KERN_DEBUG PFX "New heartbeat: %d\n", 275 + heartbeat); 276 + 277 return 0; 278 } 279 ··· 287 panic(PFX "Temperature overheat trip!\n"); 288 } 289 290 + if (debug >= DEBUG) 291 + printk(KERN_DEBUG PFX "Control Status #1: 0x%02x\n", 292 + control_status); 293 + 294 return 0; 295 } 296 ··· 296 int msb; 297 int reset_counter; 298 299 + if (debug >= VERBOSE) 300 + printk(KERN_INFO PFX "clearing watchdog trip status & LED\n"); 301 + 302 control_status = inb_p(pcipcwd_private.io_addr + 1); 303 + 304 + if (debug >= DEBUG) { 305 + printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status); 306 + printk(KERN_DEBUG PFX "sending: 0x%02x\n", 307 + (control_status & WD_PCI_R2DS) | WD_PCI_WTRP); 308 + } 309 310 /* clear trip status & LED and keep mode of relay 2 */ 311 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1); ··· 305 msb=0; 306 reset_counter=0xff; 307 send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter); 308 + 309 + if (debug >= DEBUG) { 310 + printk(KERN_DEBUG PFX "reset count was: 0x%02x\n", 311 + reset_counter); 312 + } 313 314 return 0; 315 } ··· 322 * the decided 'standard' for this return value. 323 */ 324 *temperature = (*temperature * 9 / 5) + 32; 325 + 326 + if (debug >= DEBUG) { 327 + printk(KERN_DEBUG PFX "temperature is: %d F\n", 328 + *temperature); 329 + } 330 331 return 0; 332 } ··· 457 { 458 /* /dev/watchdog can only be opened once */ 459 if (test_and_set_bit(0, &is_active)) { 460 + if (debug >= VERBOSE) 461 + printk(KERN_ERR PFX "Attempt to open already opened device.\n"); 462 return -EBUSY; 463 } 464