From 588a45687d3bbe2b184ca4f85e61b69677ef680e Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Thu, 20 Oct 2016 10:23:54 +0800 Subject: host_command_pd: pd_exchange_status: Fix first_exchange logic The code clearly indends to sleep on the second time the loop is taken, but the variable first_exchange is reset to 1 inside the loop. If, for whatever reason, PD alert status cannot be cleared, the code will then loop forever, and lead to a watchdog reset. BRANCH=none BUG=chrome-os-partner:58750 TEST=Flash EC RO using ec_util Run fwupdatetest with charger unplugged for 10 iterations. Change-Id: I9e13f2523111853fdc5c45e75886c11f1c8006eb Reviewed-on: https://chromium-review.googlesource.com/401238 Commit-Ready: Nicolas Boichat Tested-by: Nicolas Boichat Reviewed-by: Shawn N --- common/host_command_pd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/host_command_pd.c b/common/host_command_pd.c index 1042b2f232..fbfad43918 100644 --- a/common/host_command_pd.c +++ b/common/host_command_pd.c @@ -157,6 +157,10 @@ static int pd_get_alert(void) static void pd_exchange_status(uint32_t ec_state) { +#ifdef USB_TCPM_WITH_OFF_CHIP_TCPC + int first_exchange = 1; +#endif + #ifdef CONFIG_HOSTCMD_PD struct ec_params_pd_status ec_status; struct ec_response_pd_status pd_status; @@ -168,7 +172,6 @@ static void pd_exchange_status(uint32_t ec_state) #ifdef USB_TCPM_WITH_OFF_CHIP_TCPC /* Loop until the alert gpio is not active */ do { - int first_exchange = 1; #endif #ifdef CONFIG_HOSTCMD_PD -- cgit v1.2.1