psu-ng: Refactor IOUT_OC_FAULT detection
Split off code checking for IOUT_OC fault in STATUS_WORD to its own
function.
Change-Id: I4925149b0b1f9bce2400c83eb2808aeba0f7d1cc
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 e31734b..9e58ff2 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -240,6 +240,23 @@
}
}
+void PowerSupply::analyzeIoutOCFault()
+{
+ if (statusWord & phosphor::pmbus::status_word::IOUT_OC_FAULT)
+ {
+ if (!ioutOCFault)
+ {
+ log<level::ERR>(fmt::format("IOUT fault: STATUS_WORD = {:#04x}, "
+ "STATUS_MFR_SPECIFIC = {:#02x}, "
+ "STATUS_IOUT = {:#02x}",
+ statusWord, statusMFR, statusIout)
+ .c_str());
+ }
+
+ ioutOCFault = true;
+ }
+}
+
void PowerSupply::analyzeTemperatureFault()
{
if (statusWord & phosphor::pmbus::status_word::TEMPERATURE_FAULT_WARN)
@@ -356,20 +373,7 @@
analyzeVoutOVFault();
- if (statusWord & status_word::IOUT_OC_FAULT)
- {
- if (!ioutOCFault)
- {
- log<level::ERR>(
- fmt::format("IOUT fault: STATUS_WORD = {:#04x}, "
- "STATUS_MFR_SPECIFIC = {:#02x}, "
- "STATUS_IOUT = {:#02x}",
- statusWord, statusMFR, statusIout)
- .c_str());
- }
-
- ioutOCFault = true;
- }
+ analyzeIoutOCFault();
if ((statusWord & status_word::VOUT_FAULT) &&
!(statusWord & status_word::VOUT_OV_FAULT))
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index aa31de3..ae4a02c 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -511,6 +511,14 @@
*/
void analyzeVoutOVFault();
+ /*
+ * @brief Examine STATUS_WORD value read for IOUT_OC_FAULT.
+ *
+ * "An output overcurrent fault has occurred." If it is on, and fault not
+ * set, trace STATUS_WORD, STATUS_MFR_SPECIFIC, and STATUS_IOUT values.
+ */
+ void analyzeIoutOCFault();
+
/**
* @brief Examine STATUS_WORD for temperature fault.
*/