psu-ng: Refactor clearing fault member variables
Consolidated the copy/paste of clearing the fault member variables into
a helper function that both analyze() and clearFaults() can use.
Change-Id: Ib56718b0d4cc36edd000b9ba1f52fb42047e2a8c
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 a48441d..6b82796 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -402,25 +402,32 @@
}
else
{
- cmlFault = false;
- inputFault = false;
- mfrFault = false;
- vinUVFault = false;
- voutOVFault = false;
- ioutOCFault = false;
- voutUVFault = false;
- fanFault = false;
- tempFault = false;
+ // if INPUT/VIN_UV fault was on, it cleared, trace it.
+ if (inputFault)
+ {
+ log<level::INFO>(
+ fmt::format(
+ "INPUT fault cleared: STATUS_WORD = {:#04x}",
+ statusWord)
+ .c_str());
+ }
+
+ if (vinUVFault)
+ {
+ log<level::INFO>(
+ fmt::format("VIN_UV cleared: STATUS_WORD = {:#04x}",
+ statusWord)
+ .c_str());
+ }
+
if (pgoodFault > 0)
{
log<level::INFO>(fmt::format("pgoodFault cleared path: {}",
inventoryPath)
.c_str());
- pgoodFault = 0;
}
- psKillFault = false;
- ps12VcsFault = false;
- psCS12VFault = false;
+
+ clearFaultFlags();
}
}
catch (const ReadFailure& e)
@@ -466,20 +473,7 @@
// I do not care what the return value is.
if (present)
{
- inputFault = false;
- mfrFault = false;
- statusMFR = 0;
- vinUVFault = false;
- cmlFault = false;
- voutOVFault = false;
- ioutOCFault = false;
- voutUVFault = false;
- fanFault = false;
- tempFault = false;
- pgoodFault = 0;
- psKillFault = false;
- ps12VcsFault = false;
- psCS12VFault = false;
+ clearFaultFlags();
readFail = 0;
try