[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 111 } pcipcwd_private; 112 112 113 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 + 114 121 #define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ 115 122 static int heartbeat = WATCHDOG_HEARTBEAT; 116 123 module_param(heartbeat, int, 0); ··· 134 127 static int send_command(int cmd, int *msb, int *lsb) 135 128 { 136 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); 137 134 138 135 spin_lock(&pcipcwd_private.io_lock); 139 136 /* If a command requires data it should be written first. ··· 159 148 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; 160 149 } 161 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 + 162 160 if (got_response) { 163 161 /* read back response */ 164 162 *lsb = inb_p(pcipcwd_private.io_addr + 4); ··· 175 155 176 156 /* clear WRSP bit */ 177 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); 178 162 } 163 + 179 164 spin_unlock(&pcipcwd_private.io_lock); 180 165 181 166 return got_response; ··· 251 226 return -1; 252 227 } 253 228 229 + if (debug >= VERBOSE) 230 + printk(KERN_DEBUG PFX "Watchdog started\n"); 231 + 254 232 return 0; 255 233 } 256 234 ··· 276 248 return -1; 277 249 } 278 250 251 + if (debug >= VERBOSE) 252 + printk(KERN_DEBUG PFX "Watchdog stopped\n"); 253 + 279 254 return 0; 280 255 } 281 256 ··· 286 255 { 287 256 /* Re-trigger watchdog by writing to port 0 */ 288 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 + 289 262 return 0; 290 263 } 291 264 ··· 305 270 send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb); 306 271 307 272 heartbeat = t; 273 + if (debug >= VERBOSE) 274 + printk(KERN_DEBUG PFX "New heartbeat: %d\n", 275 + heartbeat); 276 + 308 277 return 0; 309 278 } 310 279 ··· 326 287 panic(PFX "Temperature overheat trip!\n"); 327 288 } 328 289 290 + if (debug >= DEBUG) 291 + printk(KERN_DEBUG PFX "Control Status #1: 0x%02x\n", 292 + control_status); 293 + 329 294 return 0; 330 295 } 331 296 ··· 339 296 int msb; 340 297 int reset_counter; 341 298 299 + if (debug >= VERBOSE) 300 + printk(KERN_INFO PFX "clearing watchdog trip status & LED\n"); 301 + 342 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 + } 343 309 344 310 /* clear trip status & LED and keep mode of relay 2 */ 345 311 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1); ··· 357 305 msb=0; 358 306 reset_counter=0xff; 359 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 + } 360 313 361 314 return 0; 362 315 } ··· 379 322 * the decided 'standard' for this return value. 380 323 */ 381 324 *temperature = (*temperature * 9 / 5) + 32; 325 + 326 + if (debug >= DEBUG) { 327 + printk(KERN_DEBUG PFX "temperature is: %d F\n", 328 + *temperature); 329 + } 382 330 383 331 return 0; 384 332 } ··· 519 457 { 520 458 /* /dev/watchdog can only be opened once */ 521 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"); 522 462 return -EBUSY; 523 463 } 524 464