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 <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
Nicolas Boichat
2016-10-20 10:23:54 +08:00
committed by chrome-bot
parent fb0d464fbd
commit 588a45687d

View File

@@ -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