watchdog: Refactor timeRemaining

This function also depends only on the state of the timer.
This patch introduces no functional changes but will make
future changes shorter.

Change-Id: Id9b5825faf6c4795ca5b862f140afe06ca51e1cf
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/watchdog.cpp b/watchdog.cpp
index 4a87a0d..b5cae66 100644
--- a/watchdog.cpp
+++ b/watchdog.cpp
@@ -71,24 +71,18 @@
 // Reset the timer to a new expiration value
 uint64_t Watchdog::timeRemaining(uint64_t value)
 {
-    if (this->enabled())
+    if (timer.getEnabled() == SD_EVENT_OFF)
     {
-        // Disable the timer
-        timer.setEnabled<std::false_type>();
-
-        // Timer handles all in microseconds and hence converting
-        auto usec = duration_cast<microseconds>(
-                                  milliseconds(value));
-        // Update new expiration
-        timer.start(usec);
-
-        // Enable the timer.
-        timer.setEnabled<std::true_type>();
-
-        // Update Base class data.
-        return WatchdogInherits::timeRemaining(value);
+        // We don't need to update the timer because it is off
+        return 0;
     }
-    return 0;
+
+    // Update new expiration
+    auto usec = duration_cast<microseconds>(milliseconds(value));
+    timer.start(usec);
+
+    // Update Base class data.
+    return WatchdogInherits::timeRemaining(value);
 }
 
 // Optional callback function on timer expiration