summaryrefslogtreecommitdiffstats
path: root/watchdog.cpp
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-02-27 18:54:36 -0800
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-07 11:16:00 +0000
commit1c9515f8ab0d387911544bb5f7049942291f6cc4 (patch)
tree605a65525d8214840e24e6190c052300518cf8b4 /watchdog.cpp
parentab17520b8558d2e83aea5162124a6379418ec32a (diff)
downloadphosphor-watchdog-1c9515f8ab0d387911544bb5f7049942291f6cc4.tar.gz
phosphor-watchdog-1c9515f8ab0d387911544bb5f7049942291f6cc4.zip
watchdog: timeRemaining doesn't need to check enabled
The Timer is fully owned by the Watchdog and is only enabled when the watchdog is enabled. Therefore, we only need to check the state of the timer instead of the interface and timer before populating the timeRemaining value. This simplifies later patches and does not make any functional change. Change-Id: Ib11edd75eb1953360bf4eae7fc4b29b5251cf0c5 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'watchdog.cpp')
-rw-r--r--watchdog.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/watchdog.cpp b/watchdog.cpp
index c948d27..4a87a0d 100644
--- a/watchdog.cpp
+++ b/watchdog.cpp
@@ -49,24 +49,21 @@ uint64_t Watchdog::timeRemaining() const
{
uint64_t timeRemain = 0;
- if (this->enabled())
+ // timer may have already expired and disabled
+ if (timer.getEnabled() != SD_EVENT_OFF)
{
- // timer may have already expired and disabled
- if (timer.getEnabled() != SD_EVENT_OFF)
- {
- // the one-shot timer does not expire yet
- auto expiry = duration_cast<milliseconds>(
- timer.getRemaining());
-
- // convert to msec per interface expectation.
- auto timeNow = duration_cast<milliseconds>(
- Timer::getCurrentTime());
-
- // Its possible that timer may have expired by now.
- // So need to cross verify.
- timeRemain = (expiry > timeNow) ?
- (expiry - timeNow).count() : 0;
- }
+ // the one-shot timer does not expire yet
+ auto expiry = duration_cast<milliseconds>(
+ timer.getRemaining());
+
+ // convert to msec per interface expectation.
+ auto timeNow = duration_cast<milliseconds>(
+ Timer::getCurrentTime());
+
+ // Its possible that timer may have expired by now.
+ // So need to cross verify.
+ timeRemain = (expiry > timeNow) ?
+ (expiry - timeNow).count() : 0;
}
return timeRemain;
}
OpenPOWER on IntegriCloud