Fix PSU status when BMC is in standby
Without this patch:
Plug in the power supplies in any order, the power supply that is
plugged in first will report a `PSU_KILL_Fault` in standby, but the
problem will be restored after the host is powered on.
With this patch:
Regardless of whether it is in standby or host powered on, this
problem disappears and it works fine.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I18e0e26a4922dd710e042048625da1cc8b08dd3c
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index c965892..9d884f3 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -34,9 +34,11 @@
PowerSupply::PowerSupply(sdbusplus::bus_t& bus, const std::string& invpath,
std::uint8_t i2cbus, std::uint16_t i2caddr,
const std::string& driver,
- const std::string& gpioLineName) :
+ const std::string& gpioLineName,
+ std::function<bool()>&& callback) :
bus(bus),
- inventoryPath(invpath), bindPath("/sys/bus/i2c/drivers/" + driver)
+ inventoryPath(invpath), bindPath("/sys/bus/i2c/drivers/" + driver),
+ isPowerOn(std::move(callback))
{
if (inventoryPath.empty())
{
@@ -1164,8 +1166,8 @@
void PowerSupply::checkAvailability()
{
bool origAvailability = available;
- available = present && !hasInputFault() && !hasVINUVFault() &&
- !hasPSKillFault() && !hasIoutOCFault();
+ bool faulted = isPowerOn() && (hasPSKillFault() || hasIoutOCFault());
+ available = present && !hasInputFault() && !hasVINUVFault() && !faulted;
if (origAvailability != available)
{