psu-ng: Refactor PowerSupply::isFaulted
Refactor the isFaulted() function to check the various possible faults,
return true if any of the faults are detected. This should avoid needing
an extra flag to set/clear in addition to the one for the specific
fault.
Tested:
Verified input fault command logs error.
Verified OV/OC fault logs error.
Change-Id: I111705a175a49b01352ac86178620d6f2cb1231f
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 3f3a595..73998f3 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -223,7 +223,7 @@
statusWord, statusCML)
.c_str());
}
- faultFound = true;
+
cmlFault = true;
}
@@ -239,7 +239,6 @@
.c_str());
}
- faultFound = true;
inputFault = true;
}
@@ -254,7 +253,7 @@
statusWord, statusMFR, statusVout)
.c_str());
}
- faultFound = true;
+
voutOVFault = true;
}
@@ -269,7 +268,7 @@
statusWord, statusMFR)
.c_str());
}
- faultFound = true;
+
mfrFault = true;
}
@@ -285,13 +284,11 @@
.c_str());
}
- faultFound = true;
vinUVFault = true;
}
}
else
{
- faultFound = false;
cmlFault = false;
inputFault = false;
mfrFault = false;
@@ -342,7 +339,6 @@
// I do not care what the return value is.
if (present)
{
- faultFound = false;
inputFault = false;
mfrFault = false;
statusMFR = 0;
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 0cc80d9..8d072c7 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -181,7 +181,8 @@
*/
bool isFaulted() const
{
- return (faultFound || hasCommFault());
+ return (hasCommFault() || vinUVFault || inputFault || voutOVFault ||
+ mfrFault);
}
/**
@@ -307,9 +308,6 @@
/** @brief Will be updated to the latest/last value read from STATUS_VOUT.*/
uint64_t statusVout = 0;
- /** @brief True if a fault has already been found and not cleared */
- bool faultFound = false;
-
/** @brief True if an error for a fault has already been logged. */
bool faultLogged = false;