psu-ng: Refactor fan fault detection
Split off code checking for fan fault/warning in STATUS_WORD to its own
function.
Change-Id: I49b6dc2d62b6ca39a564262a4745aa5ed25c14eb
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 5be801a..fbbcb14 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -276,6 +276,24 @@
}
}
+void PowerSupply::analyzeFanFault()
+{
+ if (statusWord & phosphor::pmbus::status_word::FAN_FAULT)
+ {
+ if (!fanFault)
+ {
+ log<level::ERR>(fmt::format("FANS fault/warning: "
+ "STATUS_WORD = {:#04x}, "
+ "STATUS_MFR_SPECIFIC = {:#02x}, "
+ "STATUS_FANS_1_2 = {:#02x}",
+ statusWord, statusMFR, statusFans12)
+ .c_str());
+ }
+
+ fanFault = true;
+ }
+}
+
void PowerSupply::analyzeTemperatureFault()
{
if (statusWord & phosphor::pmbus::status_word::TEMPERATURE_FAULT_WARN)
@@ -396,21 +414,7 @@
analyzeVoutUVFault();
- if (statusWord & status_word::FAN_FAULT)
- {
- if (!fanFault)
- {
- log<level::ERR>(
- fmt::format("FANS fault/warning: "
- "STATUS_WORD = {:#04x}, "
- "STATUS_MFR_SPECIFIC = {:#02x}, "
- "STATUS_FANS_1_2 = {:#02x}",
- statusWord, statusMFR, statusFans12)
- .c_str());
- }
-
- fanFault = true;
- }
+ analyzeFanFault();
analyzeTemperatureFault();
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 1e1e0fe..45c4959 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -529,6 +529,15 @@
void analyzeVoutUVFault();
/**
+ * @brief Examine STATUS_WORD for the fan fault/warning bit.
+ *
+ * If fanFault is not on, trace that the bit now came on, include
+ * STATUS_WORD, STATUS_MFR_SPECIFIC, and STATUS_FANS_1_2 values as well, to
+ * help with understanding what may have caused it to be set.
+ */
+ void analyzeFanFault();
+
+ /**
* @brief Examine STATUS_WORD for temperature fault.
*/
void analyzeTemperatureFault();