]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/watchdog/i6300esb.c
[WATCHDOG] i6300esb.c: Fix the GETSTATUS and GETBOOTSTATUS ioctls.
[net-next-2.6.git] / drivers / watchdog / i6300esb.c
index 2dbe83570d6513ef1adb906e75f4fc6ab4583163..8a0ef65a0691c21bdda0ef482772755c5c7dc1b4 100644 (file)
 #define ESB_LOCK_REG    0x68            /* WDT lock register                 */
 
 /* Memory mapped registers */
-#define ESB_TIMER1_REG  BASEADDR + 0x00 /* Timer1 value after each reset     */
-#define ESB_TIMER2_REG  BASEADDR + 0x04 /* Timer2 value after each reset     */
-#define ESB_GINTSR_REG  BASEADDR + 0x08 /* General Interrupt Status Register */
-#define ESB_RELOAD_REG  BASEADDR + 0x0c /* Reload register                   */
+#define ESB_TIMER1_REG (BASEADDR + 0x00)/* Timer1 value after each reset     */
+#define ESB_TIMER2_REG (BASEADDR + 0x04)/* Timer2 value after each reset     */
+#define ESB_GINTSR_REG (BASEADDR + 0x08)/* General Interrupt Status Register */
+#define ESB_RELOAD_REG (BASEADDR + 0x0c)/* Reload register                   */
 
 /* Lock register bits */
 #define ESB_WDT_FUNC    (0x01 << 2)   /* Watchdog functionality            */
@@ -68,6 +68,7 @@
 #define ESB_WDT_INTTYPE (0x11 << 0)   /* Interrupt type on timer1 timeout  */
 
 /* Reload register bits */
+#define ESB_WDT_TIMEOUT (0x01 << 9)    /* Watchdog timed out                */
 #define ESB_WDT_RELOAD  (0x01 << 8)    /* prevent timeout                   */
 
 /* Magic constants */
@@ -87,7 +88,6 @@ static struct platform_device *esb_platform_device;
 /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */
 #define WATCHDOG_HEARTBEAT 30
 static int heartbeat = WATCHDOG_HEARTBEAT;  /* in seconds */
-
 module_param(heartbeat, int, 0);
 MODULE_PARM_DESC(heartbeat,
                "Watchdog heartbeat in seconds. (1<heartbeat<2046, default="
@@ -143,7 +143,7 @@ static int esb_timer_stop(void)
        spin_unlock(&esb_lock);
 
        /* Returns 0 if the timer was disabled, non-zero otherwise */
-       return (val & 0x01);
+       return val & 0x01;
 }
 
 static void esb_timer_keepalive(void)
@@ -190,18 +190,6 @@ static int esb_timer_set_heartbeat(int time)
        return 0;
 }
 
-static int esb_timer_read(void)
-{
-       u32 count;
-
-       /* This isn't documented, and doesn't take into
-        * acount which stage is running, but it looks
-        * like a 20 bit count down, so we might as well report it.
-        */
-       pci_read_config_dword(esb_pci, 0x64, &count);
-       return (int)count;
-}
-
 /*
  *     /dev/watchdog handling
  */
@@ -282,7 +270,7 @@ static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                                        sizeof(ident)) ? -EFAULT : 0;
 
        case WDIOC_GETSTATUS:
-               return put_user(esb_timer_read(), p);
+               return put_user(0, p);
 
        case WDIOC_GETBOOTSTATUS:
                return put_user(triggered, p);
@@ -412,11 +400,12 @@ static unsigned char __devinit esb_getdevice(void)
                /* Check if the watchdog was previously triggered */
                esb_unlock_registers();
                val2 = readw(ESB_RELOAD_REG);
-               triggered = (val2 & (0x01 << 9) >> 9);
+               if (val2 & ESB_WDT_TIMEOUT)
+                       triggered = WDIOF_CARDRESET;
 
                /* Reset trigger flag and timers */
                esb_unlock_registers();
-               writew((0x11 << 8), ESB_RELOAD_REG);
+               writew((ESB_WDT_TIMEOUT | ESB_WDT_RELOAD), ESB_RELOAD_REG);
 
                /* Done */
                return 1;