Skip to content

Commit

Permalink
[WATCHDOG] pcwd_pci.c add debug module_param
Browse files Browse the repository at this point in the history
Add debugging code for the pcwd_pci driver.

Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Wim Van Sebroeck committed Sep 29, 2005
1 parent a0800f6 commit 195331d
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions drivers/char/watchdog/pcwd_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ static struct { /* this is private data for each PCI-PC watchdog card */
} pcipcwd_private;

/* module parameters */
#define QUIET 0 /* Default */
#define VERBOSE 1 /* Verbose */
#define DEBUG 2 /* print fancy stuff too */
static int debug = QUIET;
module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)");

#define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */
static int heartbeat = WATCHDOG_HEARTBEAT;
module_param(heartbeat, int, 0);
Expand All @@ -128,6 +135,10 @@ static int send_command(int cmd, int *msb, int *lsb)
{
int got_response, count;

if (debug >= DEBUG)
printk(KERN_DEBUG PFX "sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n",
cmd, *msb, *lsb);

spin_lock(&pcipcwd_private.io_lock);
/* If a command requires data it should be written first.
* Data for commands with 8 bits of data should be written to port 4.
Expand All @@ -148,14 +159,28 @@ static int send_command(int cmd, int *msb, int *lsb)
got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
}

if (debug >= DEBUG) {
if (got_response) {
printk(KERN_DEBUG PFX "time to process command was: %d ms\n",
count);
} else {
printk(KERN_DEBUG PFX "card did not respond on command!\n");
}
}

if (got_response) {
/* read back response */
*lsb = inb_p(pcipcwd_private.io_addr + 4);
*msb = inb_p(pcipcwd_private.io_addr + 5);

/* clear WRSP bit */
inb_p(pcipcwd_private.io_addr + 6);

if (debug >= DEBUG)
printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n",
cmd, *msb, *lsb);
}

spin_unlock(&pcipcwd_private.io_lock);

return got_response;
Expand Down Expand Up @@ -226,6 +251,9 @@ static int pcipcwd_start(void)
return -1;
}

if (debug >= VERBOSE)
printk(KERN_DEBUG PFX "Watchdog started\n");

return 0;
}

Expand All @@ -248,13 +276,20 @@ static int pcipcwd_stop(void)
return -1;
}

if (debug >= VERBOSE)
printk(KERN_DEBUG PFX "Watchdog stopped\n");

return 0;
}

static int pcipcwd_keepalive(void)
{
/* Re-trigger watchdog by writing to port 0 */
outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */

if (debug >= DEBUG)
printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n");

return 0;
}

Expand All @@ -270,6 +305,10 @@ static int pcipcwd_set_heartbeat(int t)
send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb);

heartbeat = t;
if (debug >= VERBOSE)
printk(KERN_DEBUG PFX "New heartbeat: %d\n",
heartbeat);

return 0;
}

Expand All @@ -287,6 +326,10 @@ static int pcipcwd_get_status(int *status)
panic(PFX "Temperature overheat trip!\n");
}

if (debug >= DEBUG)
printk(KERN_DEBUG PFX "Control Status #1: 0x%02x\n",
control_status);

return 0;
}

Expand All @@ -296,8 +339,17 @@ static int pcipcwd_clear_status(void)
int msb;
int reset_counter;

if (debug >= VERBOSE)
printk(KERN_INFO PFX "clearing watchdog trip status & LED\n");

control_status = inb_p(pcipcwd_private.io_addr + 1);

if (debug >= DEBUG) {
printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status);
printk(KERN_DEBUG PFX "sending: 0x%02x\n",
(control_status & WD_PCI_R2DS) | WD_PCI_WTRP);
}

/* clear trip status & LED and keep mode of relay 2 */
outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1);

Expand All @@ -306,6 +358,11 @@ static int pcipcwd_clear_status(void)
reset_counter=0xff;
send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter);

if (debug >= DEBUG) {
printk(KERN_DEBUG PFX "reset count was: 0x%02x\n",
reset_counter);
}

return 0;
}

Expand All @@ -323,6 +380,11 @@ static int pcipcwd_get_temperature(int *temperature)
*/
*temperature = (*temperature * 9 / 5) + 32;

if (debug >= DEBUG) {
printk(KERN_DEBUG PFX "temperature is: %d F\n",
*temperature);
}

return 0;
}

Expand Down Expand Up @@ -457,6 +519,8 @@ static int pcipcwd_open(struct inode *inode, struct file *file)
{
/* /dev/watchdog can only be opened once */
if (test_and_set_bit(0, &is_active)) {
if (debug >= VERBOSE)
printk(KERN_ERR PFX "Attempt to open already opened device.\n");
return -EBUSY;
}

Expand Down

0 comments on commit 195331d

Please sign in to comment.