Add in a way to check for any fault found

Adding in a variable to indicate that any type of fault has been found.
A number of the faults that can occur during the power on time frame
will eventually result in the power supply turning off. We do not want
to log multiple faults for something like a fan fault resulting in an
overtemperature fault that then results into the power supply turning
off, generating three error logs that call out the same supply that has
failed due to a bad fan.

The input/undervoltage fault is treated a bit uniquely, if that fault
clears (supply plugged in, different power source, etc.) it will also
clear the indicator that any fault has been found. All other faults will
require a power supply replace or power cycle in order to be cleared.

Resolves: openbmc/openbmc#2516

Change-Id: I32c3f9c4031de5d603aa96e184679c3d7d87a3f1
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index dc4b21d..931a3e0 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -126,7 +126,7 @@
 
             checkInputFault(statusWord);
 
-            if (powerOn && !inputFault)
+            if (powerOn && !faultFound)
             {
                 checkFanFault(statusWord);
                 checkTemperatureFault(statusWord);
@@ -257,6 +257,7 @@
     if (!inputFault && ((statusWord & status_word::INPUT_FAULT_WARN) ||
         (statusWord & status_word::VIN_UV_FAULT)))
     {
+        faultFound = true;
         inputFault = true;
 
         util::NamesValues nv;
@@ -277,6 +278,7 @@
             !(statusWord & status_word::VIN_UV_FAULT))
         {
             inputFault = false;
+            faultFound = false;
 
             statusInput = pmbusIntf.read(STATUS_INPUT, Type::Debug);
 
@@ -323,6 +325,8 @@
 
         if (powerOnFault >= FAULT_COUNT)
         {
+            faultFound = true;
+
             util::NamesValues nv;
             nv.add("STATUS_WORD", statusWord);
             captureCmd(nv, STATUS_INPUT, Type::Debug);
@@ -368,6 +372,7 @@
                                              metadata::CALLOUT_INVENTORY_PATH(
                                                      inventoryPath.c_str()));
 
+        faultFound = true;
         outputOCFault = true;
     }
 }
@@ -396,6 +401,7 @@
                                              metadata::CALLOUT_INVENTORY_PATH(
                                                      inventoryPath.c_str()));
 
+        faultFound = true;
         outputOVFault = true;
     }
 }
@@ -421,6 +427,7 @@
                 metadata::RAW_STATUS(nv.get().c_str()),
                 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
 
+        faultFound = true;
         fanFault = true;
     }
 }
@@ -462,6 +469,7 @@
                 metadata::RAW_STATUS(nv.get().c_str()),
                 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
 
+        faultFound = true;
         temperatureFault = true;
     }
 }
@@ -475,6 +483,7 @@
     outputOVFault = false;
     fanFault = false;
     temperatureFault = false;
+    faultFound = false;
 
     return;
 }
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index 3da02b4..eefefff 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -121,6 +121,9 @@
          */
         Timer presentTimer;
 
+        /** @brief True if a fault has already been found and not cleared */
+        bool faultFound = false;
+
         /** @brief True if the power is on. */
         bool powerOn = false;