psu-ng: Refactor MFR fault detection

Move handling of MFR fault to its own analyzeMFRFault() function.

This will handle checking if the MFR fault bit is on in STATUS_WORD, and
determinine what power supply specific meaning any STATUS_MFR_SPECIFIC
bits mean by calling determineMFRFault().

The analyze() function is getting a bit long and hard to read.

Change-Id: I401ebcf11943099385044081518a27511075fa94
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 6b82796..04762b3 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -211,6 +211,24 @@
     }
 }
 
+void PowerSupply::analyzeMFRFault()
+{
+    if (statusWord & phosphor::pmbus::status_word::MFR_SPECIFIC_FAULT)
+    {
+        if (!mfrFault)
+        {
+            log<level::ERR>(fmt::format("MFR fault: "
+                                        "STATUS_WORD = {:#04x} "
+                                        "STATUS_MFR_SPECIFIC = {:#02x}",
+                                        statusWord, statusMFR)
+                                .c_str());
+        }
+
+        mfrFault = true;
+        determineMFRFault();
+    }
+}
+
 void PowerSupply::analyze()
 {
     using namespace phosphor::pmbus;
@@ -369,21 +387,7 @@
                     pgoodFault = 0;
                 }
 
-                if (statusWord & status_word::MFR_SPECIFIC_FAULT)
-                {
-                    if (!mfrFault)
-                    {
-                        log<level::ERR>(
-                            fmt::format("MFR fault: "
-                                        "STATUS_WORD = {:#04x} "
-                                        "STATUS_MFR_SPECIFIC = {:#02x}",
-                                        statusWord, statusMFR)
-                                .c_str());
-                    }
-
-                    mfrFault = true;
-                    determineMFRFault();
-                }
+                analyzeMFRFault();
 
                 if (statusWord & status_word::VIN_UV_FAULT)
                 {
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 2e7c63b..83ebc74 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -501,6 +501,16 @@
     void determineMFRFault();
 
     /**
+     * @brief Examine STATUS_WORD value read for MFRSPECIFIC bit on.
+     *
+     * "A manufacturer specific fault or warning has occurred."
+     *
+     * If it is on, call the determineMFRFault() helper function to examine the
+     * value read from STATUS_MFR_SPECIFIC.
+     */
+    void analyzeMFRFault();
+
+    /**
      * @brief D-Bus path to use for this power supply's inventory status.
      **/
     std::string inventoryPath;