regulators: Clear cached hardware data during boot

Clear cached data about hardware devices when the system is powering on
(booting).

While the system was powered off, hardware devices containing voltage
regulators could have been added, removed, or replaced.  Cached hardware
data might now be invalid.

Tested:
* Ran automated test cases
* Verified that cached data is cleared without errors during boot
  * When config file was found and loaded
  * When no config file was found

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ief45fe32ddcb122847d201e89ca1267526a87e3c
diff --git a/phosphor-regulators/src/manager.cpp b/phosphor-regulators/src/manager.cpp
index 51c8944..73e49bf 100644
--- a/phosphor-regulators/src/manager.cpp
+++ b/phosphor-regulators/src/manager.cpp
@@ -90,6 +90,9 @@
 
 void Manager::configure()
 {
+    // Clear any cached data or error history related to hardware devices
+    clearHardwareData();
+
     // Verify System object exists; this means config file has been loaded
     if (system)
     {
@@ -181,7 +184,7 @@
             // Close the regulator devices in the system.  Monitoring is
             // normally disabled because the system is being powered off.  The
             // devices should be closed in case hardware is removed or replaced
-            // while the system is at standby.
+            // while the system is powered off.
             system->closeDevices(services);
         }
     }
@@ -200,6 +203,21 @@
     // collect/update telemetry for each regulator
 }
 
+void Manager::clearHardwareData()
+{
+    // Clear any cached hardware presence data
+    services.getPresenceService().clearCache();
+
+    // Verify System object exists; this means config file has been loaded
+    if (system)
+    {
+        // Clear any cached hardware data in the System object
+        system->clearCache();
+    }
+
+    // TODO: Clear error history related to hardware devices
+}
+
 void Manager::findCompatibleSystemTypes()
 {
     using namespace phosphor::power::util;