psu-ng: Refactor VIN_UV fault detection
Split off code checking for VIN_UV fault in STATUS_WORD to its own
function.
Change-Id: Ifd07b6958885ed19c7611e10e343d1a5f10ec684
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 fbbcb14..d416c94 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -375,6 +375,23 @@
}
}
+void PowerSupply::analyzeVinUVFault()
+{
+ if (statusWord & phosphor::pmbus::status_word::VIN_UV_FAULT)
+ {
+ if (!vinUVFault)
+ {
+ log<level::ERR>(fmt::format("VIN_UV fault: STATUS_WORD = {:#04x}, "
+ "STATUS_MFR_SPECIFIC = {:#02x}, "
+ "STATUS_INPUT = {:#02x}",
+ statusWord, statusMFR, statusInput)
+ .c_str());
+ }
+
+ vinUVFault = true;
+ }
+}
+
void PowerSupply::analyze()
{
using namespace phosphor::pmbus;
@@ -422,20 +439,7 @@
analyzeMFRFault();
- if (statusWord & status_word::VIN_UV_FAULT)
- {
- if (!vinUVFault)
- {
- log<level::ERR>(
- fmt::format("VIN_UV fault: STATUS_WORD = {:#04x}, "
- "STATUS_MFR_SPECIFIC = {:#02x}, "
- "STATUS_INPUT = {:#02x}",
- statusWord, statusMFR, statusInput)
- .c_str());
- }
-
- vinUVFault = true;
- }
+ analyzeVinUVFault();
}
else
{
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 45c4959..f36a1cc 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -568,6 +568,11 @@
void analyzeMFRFault();
/**
+ * @brief Analyzes the STATUS_WORD for a VIN_UV_FAULT indicator.
+ */
+ void analyzeVinUVFault();
+
+ /**
* @brief D-Bus path to use for this power supply's inventory status.
**/
std::string inventoryPath;