psu-ng: Clear fault bits in STATUS_WORD

Allow for clearing the fault bits in STATUS_WORD (and STATUS_BYTE) by
having the clearFaults() function read from the in1_crit file in the
hwmon directory.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I1a3ad5c2402a61ff1172428085c4d707dc6166e4
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 30fbf74..fdbb94f 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -78,6 +78,15 @@
         inputFault = false;
         mfrFault = false;
         vinUVFault = false;
+
+        // The PMBus device driver does not allow for writing CLEAR_FAULTS
+        // directly. However, the pmbus hwmon device driver code will send a
+        // CLEAR_FAULTS after reading from any of the hwmon "files" in sysfs, so
+        // reading in1_crit should result in clearing the fault bits in
+        // STATUS_BYTE/STATUS_WORD.
+        // I do not care what the return value is.
+        static_cast<void>(
+            pmbusIntf->read("in1_crit", phosphor::pmbus::Type::Hwmon));
     }
 
     /**
diff --git a/phosphor-power-supply/test/power_supply_tests.cpp b/phosphor-power-supply/test/power_supply_tests.cpp
index 9674153..dda38f5 100644
--- a/phosphor-power-supply/test/power_supply_tests.cpp
+++ b/phosphor-power-supply/test/power_supply_tests.cpp
@@ -168,6 +168,7 @@
     EXPECT_EQ(psu.hasInputFault(), true);
     EXPECT_EQ(psu.hasMFRFault(), true);
     EXPECT_EQ(psu.hasVINUVFault(), true);
+    EXPECT_CALL(mockPMBus, read("in1_crit", _)).Times(1).WillOnce(Return(0x01));
     psu.clearFaults();
     EXPECT_EQ(psu.isPresent(), true);
     EXPECT_EQ(psu.isFaulted(), false);