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
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 8e82927..2e7c63b 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -104,6 +104,28 @@
void onOffConfig(uint8_t data);
/**
+ * Clears all the member variables that indicate if a fault bit was seen as
+ * on in the STATUS_WORD or STATUS_MFR_SPECIFIC response.
+ */
+ void clearFaultFlags()
+ {
+ 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;
+ }
+
+ /**
* Write PMBus CLEAR_FAULTS
*
* This function will be called in various situations in order to clear