aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2005-09-29 10:22:30 -0400
committerWim Van Sebroeck <wim@iguana.be>2005-09-29 10:22:30 -0400
commit195331d7c9813fe7f1a93c09afa2c7dcdf2790a8 (patch)
tree758db912533901b7fa08f02b321665f28191c56e /drivers
parenta0800f6da7c4590d49ae513d9d5ee8b1ad203b82 (diff)
[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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/watchdog/pcwd_pci.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c
index 0cb62e39e58f..0b8e493be045 100644
--- a/drivers/char/watchdog/pcwd_pci.c
+++ b/drivers/char/watchdog/pcwd_pci.c
@@ -111,6 +111,13 @@ static struct { /* this is private data for each PCI-PC watchdog card */
111} pcipcwd_private; 111} pcipcwd_private;
112 112
113/* module parameters */ 113/* module parameters */
114#define QUIET 0 /* Default */
115#define VERBOSE 1 /* Verbose */
116#define DEBUG 2 /* print fancy stuff too */
117static int debug = QUIET;
118module_param(debug, int, 0);
119MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)");
120
114#define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ 121#define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */
115static int heartbeat = WATCHDOG_HEARTBEAT; 122static int heartbeat = WATCHDOG_HEARTBEAT;
116module_param(heartbeat, int, 0); 123module_param(heartbeat, int, 0);
@@ -128,6 +135,10 @@ static int send_command(int cmd, int *msb, int *lsb)
128{ 135{
129 int got_response, count; 136 int got_response, count;
130 137
138 if (debug >= DEBUG)
139 printk(KERN_DEBUG PFX "sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n",
140 cmd, *msb, *lsb);
141
131 spin_lock(&pcipcwd_private.io_lock); 142 spin_lock(&pcipcwd_private.io_lock);
132 /* If a command requires data it should be written first. 143 /* If a command requires data it should be written first.
133 * Data for commands with 8 bits of data should be written to port 4. 144 * Data for commands with 8 bits of data should be written to port 4.
@@ -148,6 +159,15 @@ static int send_command(int cmd, int *msb, int *lsb)
148 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; 159 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
149 } 160 }
150 161
162 if (debug >= DEBUG) {
163 if (got_response) {
164 printk(KERN_DEBUG PFX "time to process command was: %d ms\n",
165 count);
166 } else {
167 printk(KERN_DEBUG PFX "card did not respond on command!\n");
168 }
169 }
170
151 if (got_response) { 171 if (got_response) {
152 /* read back response */ 172 /* read back response */
153 *lsb = inb_p(pcipcwd_private.io_addr + 4); 173 *lsb = inb_p(pcipcwd_private.io_addr + 4);
@@ -155,7 +175,12 @@ static int send_command(int cmd, int *msb, int *lsb)
155 175
156 /* clear WRSP bit */ 176 /* clear WRSP bit */
157 inb_p(pcipcwd_private.io_addr + 6); 177 inb_p(pcipcwd_private.io_addr + 6);
178
179 if (debug >= DEBUG)
180 printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n",
181 cmd, *msb, *lsb);
158 } 182 }
183
159 spin_unlock(&pcipcwd_private.io_lock); 184 spin_unlock(&pcipcwd_private.io_lock);
160 185
161 return got_response; 186 return got_response;
@@ -226,6 +251,9 @@ static int pcipcwd_start(void)
226 return -1; 251 return -1;
227 } 252 }
228 253
254 if (debug >= VERBOSE)
255 printk(KERN_DEBUG PFX "Watchdog started\n");
256
229 return 0; 257 return 0;
230} 258}
231 259
@@ -248,6 +276,9 @@ static int pcipcwd_stop(void)
248 return -1; 276 return -1;
249 } 277 }
250 278
279 if (debug >= VERBOSE)
280 printk(KERN_DEBUG PFX "Watchdog stopped\n");
281
251 return 0; 282 return 0;
252} 283}
253 284
@@ -255,6 +286,10 @@ static int pcipcwd_keepalive(void)
255{ 286{
256 /* Re-trigger watchdog by writing to port 0 */ 287 /* Re-trigger watchdog by writing to port 0 */
257 outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */ 288 outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */
289
290 if (debug >= DEBUG)
291 printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n");
292
258 return 0; 293 return 0;
259} 294}
260 295
@@ -270,6 +305,10 @@ static int pcipcwd_set_heartbeat(int t)
270 send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb); 305 send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb);
271 306
272 heartbeat = t; 307 heartbeat = t;
308 if (debug >= VERBOSE)
309 printk(KERN_DEBUG PFX "New heartbeat: %d\n",
310 heartbeat);
311
273 return 0; 312 return 0;
274} 313}
275 314
@@ -287,6 +326,10 @@ static int pcipcwd_get_status(int *status)
287 panic(PFX "Temperature overheat trip!\n"); 326 panic(PFX "Temperature overheat trip!\n");
288 } 327 }
289 328
329 if (debug >= DEBUG)
330 printk(KERN_DEBUG PFX "Control Status #1: 0x%02x\n",
331 control_status);
332
290 return 0; 333 return 0;
291} 334}
292 335
@@ -296,8 +339,17 @@ static int pcipcwd_clear_status(void)
296 int msb; 339 int msb;
297 int reset_counter; 340 int reset_counter;
298 341
342 if (debug >= VERBOSE)
343 printk(KERN_INFO PFX "clearing watchdog trip status & LED\n");
344
299 control_status = inb_p(pcipcwd_private.io_addr + 1); 345 control_status = inb_p(pcipcwd_private.io_addr + 1);
300 346
347 if (debug >= DEBUG) {
348 printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status);
349 printk(KERN_DEBUG PFX "sending: 0x%02x\n",
350 (control_status & WD_PCI_R2DS) | WD_PCI_WTRP);
351 }
352
301 /* clear trip status & LED and keep mode of relay 2 */ 353 /* clear trip status & LED and keep mode of relay 2 */
302 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1); 354 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1);
303 355
@@ -306,6 +358,11 @@ static int pcipcwd_clear_status(void)
306 reset_counter=0xff; 358 reset_counter=0xff;
307 send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter); 359 send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter);
308 360
361 if (debug >= DEBUG) {
362 printk(KERN_DEBUG PFX "reset count was: 0x%02x\n",
363 reset_counter);
364 }
365
309 return 0; 366 return 0;
310} 367}
311 368
@@ -323,6 +380,11 @@ static int pcipcwd_get_temperature(int *temperature)
323 */ 380 */
324 *temperature = (*temperature * 9 / 5) + 32; 381 *temperature = (*temperature * 9 / 5) + 32;
325 382
383 if (debug >= DEBUG) {
384 printk(KERN_DEBUG PFX "temperature is: %d F\n",
385 *temperature);
386 }
387
326 return 0; 388 return 0;
327} 389}
328 390
@@ -457,6 +519,8 @@ static int pcipcwd_open(struct inode *inode, struct file *file)
457{ 519{
458 /* /dev/watchdog can only be opened once */ 520 /* /dev/watchdog can only be opened once */
459 if (test_and_set_bit(0, &is_active)) { 521 if (test_and_set_bit(0, &is_active)) {
522 if (debug >= VERBOSE)
523 printk(KERN_ERR PFX "Attempt to open already opened device.\n");
460 return -EBUSY; 524 return -EBUSY;
461 } 525 }
462 526