psu-ng: Refactor PGOOD and UNIT_IS_OFF fault
Split the code for detecting PGOOD and/or UNIT_IS_OFF fault into its own
private member function.
The analyze() function is getting a bit long and hard to read.
Change-Id: I48771a5d4e8991ce37b54bd6ad4c3e938924418e
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 04762b3..6fd412a 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -189,6 +189,28 @@
}
}
+void PowerSupply::analyzePgoodFault()
+{
+ if ((statusWord & phosphor::pmbus::status_word::POWER_GOOD_NEGATED) ||
+ (statusWord & phosphor::pmbus::status_word::UNIT_IS_OFF))
+ {
+ if (pgoodFault < DEGLITCH_LIMIT)
+ {
+ log<level::ERR>(fmt::format("PGOOD fault: "
+ "STATUS_WORD = {:#04x}, "
+ "STATUS_MFR_SPECIFIC = {:#02x}",
+ statusWord, statusMFR)
+ .c_str());
+
+ pgoodFault++;
+ }
+ }
+ else
+ {
+ pgoodFault = 0;
+ }
+}
+
void PowerSupply::determineMFRFault()
{
if (bindPath.string().find("ibm-cffps") != std::string::npos)
@@ -367,25 +389,7 @@
tempFault = true;
}
- if ((statusWord & status_word::POWER_GOOD_NEGATED) ||
- (statusWord & status_word::UNIT_IS_OFF))
- {
- if (pgoodFault < DEGLITCH_LIMIT)
- {
- log<level::ERR>(
- fmt::format("PGOOD fault: "
- "STATUS_WORD = {:#04x}, "
- "STATUS_MFR_SPECIFIC = {:#02x}",
- statusWord, statusMFR)
- .c_str());
-
- pgoodFault++;
- }
- }
- else
- {
- pgoodFault = 0;
- }
+ analyzePgoodFault();
analyzeMFRFault();
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 83ebc74..3cb5a6d 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -491,6 +491,11 @@
size_t readFail = 0;
/**
+ * @brief Examine STATUS_WORD for pgood or unit off faults.
+ */
+ void analyzePgoodFault();
+
+ /**
* @brief Determine possible manufacturer-specific faults from bits in
* STATUS_MFR.
*