psu-ng: clearFaults read only if present
Only attempt the in1_input read for clearFaults if the power supply is
marked as being present.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I15a1af419a101efbde95612614775fc976ab2a29
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 271009b..0d63ca2 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -141,17 +141,20 @@
// reading in1_input should result in clearing the fault bits in
// STATUS_BYTE/STATUS_WORD.
// I do not care what the return value is.
- try
+ if (present)
{
- static_cast<void>(
- pmbusIntf->read("in1_input", phosphor::pmbus::Type::Hwmon));
- }
- catch (ReadFailure& e)
- {
- // Since I do not care what the return value is, I really do not
- // care much if it gets a ReadFailure either. However, this should not
- // prevent the application from continuing to run, so catching the read
- // failure.
+ try
+ {
+ static_cast<void>(
+ pmbusIntf->read("in1_input", phosphor::pmbus::Type::Hwmon));
+ }
+ catch (ReadFailure& e)
+ {
+ // Since I do not care what the return value is, I really do not
+ // care much if it gets a ReadFailure either. However, this should
+ // not prevent the application from continuing to run, so catching
+ // the read failure.
+ }
}
}