Add error handing to recovery from gpio config failure
Sometimes these chassis related services will fail with below error:
Power GPIO: call to getGpioConfiguration failed:
GDBus.Error:org.freedesktop.DBus.Error.Service
Unknown: The name org.openbmc.managers.System was not provided by any
.service files
These gpio pins cannot be configured properly, and cannot power on/off
host.
Add error handing to terminate the service in such error, systemd will
restart them to try again
Change-Id: I3ce7383825f2b9715fdd82e1dec0725cef83073c
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
diff --git a/op-pwrctl/power_control_obj.c b/op-pwrctl/power_control_obj.c
index 19ce118..e9c9673 100644
--- a/op-pwrctl/power_control_obj.c
+++ b/op-pwrctl/power_control_obj.c
@@ -462,11 +462,13 @@
if(read_gpios(connection, &g_gpio_configs) != TRUE) {
g_print("ERROR PowerControl: could not read power GPIO configuration\n");
+ exit(-1);
}
int rc = set_up_gpio(connection, &g_gpio_configs.power_gpio, control_power);
if(rc != GPIO_OK) {
g_print("ERROR PowerControl: GPIO setup (rc=%d)\n",rc);
+ exit(-1);
}
//start poll
pgood_timeout_start = 0;
@@ -474,6 +476,7 @@
int pgood_timeout = atoi(cmd->argv[2]);
if(poll_interval < 500 || pgood_timeout <5) {
g_print("ERROR PowerControl: poll_interval < 500 or pgood_timeout < 5\n");
+ exit(-1);
} else {
control_set_poll_interval(control,poll_interval);
control_power_set_pgood_timeout(control_power,pgood_timeout);
diff --git a/pwrbutton/button_power_obj.c b/pwrbutton/button_power_obj.c
index b8bca38..7b27986 100644
--- a/pwrbutton/button_power_obj.c
+++ b/pwrbutton/button_power_obj.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <openbmc_intf.h>
#include <gpio.h>
#include <openbmc.h>
@@ -120,6 +121,7 @@
if(rc != GPIO_OK)
{
printf("ERROR PowerButton: GPIO setup (rc=%d)\n",rc);
+ exit(-1);
}
}
diff --git a/rstbutton/button_reset_obj.c b/rstbutton/button_reset_obj.c
index 731ecce..8e1c1ac 100644
--- a/rstbutton/button_reset_obj.c
+++ b/rstbutton/button_reset_obj.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <openbmc_intf.h>
#include <gpio.h>
#include <openbmc.h>
@@ -120,6 +121,7 @@
if(rc != GPIO_OK)
{
printf("ERROR PowerButton: GPIO setup (rc=%d)\n",rc);
+ exit(-1);
}
}