watchdog: hpwdt (8/12): implement WDIOC_GETTIMELEFT
authordann frazier <dannf@hp.com>
Wed, 2 Jun 2010 22:23:41 +0000 (16:23 -0600)
committerWim Van Sebroeck <wim@iguana.be>
Fri, 13 Aug 2010 20:54:46 +0000 (20:54 +0000)
Let applications check the amount of time left before the watchdog will fire.

Signed-off-by: dann frazier <dannf@hp.com>
Acked-by: Thomas Mingarelli <Thomas.Mingarelli@hp.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/hpwdt.c

index 00299919df398173bcd3f5031ca6219b18e6a6ad..554526cf32336f035a95fd22111a539a7df00652 100644 (file)
@@ -450,6 +450,11 @@ static int hpwdt_change_timer(int new_margin)
        return 0;
 }
 
+static int hpwdt_time_left(void)
+{
+       return TICKS_TO_SECS(ioread16(hpwdt_timer_reg));
+}
+
 /*
  *     NMI Handler
  */
@@ -591,6 +596,10 @@ static long hpwdt_ioctl(struct file *file, unsigned int cmd,
        case WDIOC_GETTIMEOUT:
                ret = put_user(soft_margin, p);
                break;
+
+       case WDIOC_GETTIMELEFT:
+               ret = put_user(hpwdt_time_left(), p);
+               break;
        }
        return ret;
 }