psu-ng: Refactor MFR fault detection
Move handling of MFR fault to its own analyzeMFRFault() function.
This will handle checking if the MFR fault bit is on in STATUS_WORD, and
determinine what power supply specific meaning any STATUS_MFR_SPECIFIC
bits mean by calling determineMFRFault().
The analyze() function is getting a bit long and hard to read.
Change-Id: I401ebcf11943099385044081518a27511075fa94
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 6b82796..04762b3 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -211,6 +211,24 @@
}
}
+void PowerSupply::analyzeMFRFault()
+{
+ if (statusWord & phosphor::pmbus::status_word::MFR_SPECIFIC_FAULT)
+ {
+ if (!mfrFault)
+ {
+ log<level::ERR>(fmt::format("MFR fault: "
+ "STATUS_WORD = {:#04x} "
+ "STATUS_MFR_SPECIFIC = {:#02x}",
+ statusWord, statusMFR)
+ .c_str());
+ }
+
+ mfrFault = true;
+ determineMFRFault();
+ }
+}
+
void PowerSupply::analyze()
{
using namespace phosphor::pmbus;
@@ -369,21 +387,7 @@
pgoodFault = 0;
}
- if (statusWord & status_word::MFR_SPECIFIC_FAULT)
- {
- if (!mfrFault)
- {
- log<level::ERR>(
- fmt::format("MFR fault: "
- "STATUS_WORD = {:#04x} "
- "STATUS_MFR_SPECIFIC = {:#02x}",
- statusWord, statusMFR)
- .c_str());
- }
-
- mfrFault = true;
- determineMFRFault();
- }
+ analyzeMFRFault();
if (statusWord & status_word::VIN_UV_FAULT)
{