Set lastRebootTime once at startup only
The lastRebootTime doesn't change once the daemon starts, so we only
need to fetch the info once and save the time instead of calculating it
everytime.
Change-Id: I5e665d637f122727be9bb8f0e7b731d75a567f02
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/bmc_state_manager.cpp b/bmc_state_manager.cpp
index 5071d89..9f67a31 100644
--- a/bmc_state_manager.cpp
+++ b/bmc_state_manager.cpp
@@ -4,13 +4,11 @@
#include "xyz/openbmc_project/Common/error.hpp"
#include <gpiod.h>
-#include <sys/sysinfo.h>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/exception.hpp>
-#include <cassert>
#include <filesystem>
#include <fstream>
#include <iostream>
@@ -246,17 +244,7 @@
uint64_t BMC::lastRebootTime() const
{
- using namespace std::chrono;
- struct sysinfo info;
-
- auto rc = sysinfo(&info);
- assert(rc == 0);
-
- // Since uptime is in seconds, also get the current time in seconds.
- auto now = time_point_cast<seconds>(system_clock::now());
- auto rebootTime = now - seconds(info.uptime);
-
- return duration_cast<milliseconds>(rebootTime.time_since_epoch()).count();
+ return rebootTime;
}
void BMC::discoverLastRebootCause()