Fix SIO gpio related crash
When a machine does not have SIO, the sioEnabled is set to false and it
should work.
But recent commit 61b4a5b introduces an issue that it uses the
sioPowerGoodLine directly without checking the sioEnabled flag, and it
gets exception as below:
terminate called after throwing an instance of 'std::logic_error'
what(): object not holding a GPIO line handle
Fix the code by checking sioEnabled flag first.
Tested: Verify the above exception is fixed on g220a.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I27996e0af87a68f3b205cb4e167a46dcd6af869f
diff --git a/power-control-x86/src/power_control.cpp b/power-control-x86/src/power_control.cpp
index c24fe92..bdb4ea7 100644
--- a/power-control-x86/src/power_control.cpp
+++ b/power-control-x86/src/power_control.cpp
@@ -2831,7 +2831,8 @@
if (powerOkConfig.type == ConfigType::GPIO)
{
if (psPowerOKLine.get_value() > 0 ||
- sioPowerGoodLine.get_value() == sioPwrGoodConfig.polarity)
+ (sioEnabled &&
+ (sioPowerGoodLine.get_value() == sioPwrGoodConfig.polarity)))
{
powerState = PowerState::on;
}