psu-ng: Refactor CML fault detection
Split off CML fault checking of STATUS_WORD into its own function.
Change-Id: I845fe0dbcc86f085057bd5128303dde04cd9057f
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 b5eeb2f..13d11f7 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -189,6 +189,22 @@
}
}
+void PowerSupply::analyzeCMLFault()
+{
+ if (statusWord & phosphor::pmbus::status_word::CML_FAULT)
+ {
+ if (!cmlFault)
+ {
+ log<level::ERR>(fmt::format("CML fault: STATUS_WORD = {:#04x}, "
+ "STATUS_CML = {:#02x}",
+ statusWord, statusCML)
+ .c_str());
+ }
+
+ cmlFault = true;
+ }
+}
+
void PowerSupply::analyzeTemperatureFault()
{
if (statusWord & phosphor::pmbus::status_word::TEMPERATURE_FAULT_WARN)
@@ -298,19 +314,8 @@
statusFans12 = pmbusIntf->read(STATUS_FANS_1_2, Type::Debug);
statusTemperature =
pmbusIntf->read(STATUS_TEMPERATURE, Type::Debug);
- if (statusWord & status_word::CML_FAULT)
- {
- if (!cmlFault)
- {
- log<level::ERR>(
- fmt::format("CML fault: STATUS_WORD = {:#04x}, "
- "STATUS_CML = {:#02x}",
- statusWord, statusCML)
- .c_str());
- }
- cmlFault = true;
- }
+ analyzeCMLFault();
if (statusWord & status_word::INPUT_FAULT_WARN)
{
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 04d73f7..1d1e105 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 CML (communication, memory, logic fault).
+ */
+ void analyzeCMLFault();
+
+ /**
* @brief Examine STATUS_WORD for temperature fault.
*/
void analyzeTemperatureFault();