OSDN Git Service

usb: pd: Increment MessageID only on successful TX
authorJack Pham <jackp@codeaurora.org>
Wed, 7 Jun 2017 22:35:57 +0000 (15:35 -0700)
committerJack Pham <jackp@codeaurora.org>
Wed, 7 Jun 2017 22:39:31 +0000 (15:39 -0700)
According to the PD 2.0 Spec, Section 6.2.1.3, the MessageID
field shall only be incremented upon successful transmission
(meaning GoodCRC was received). Thus, increment the counter
only when pd_phy_write() succeeds.

Change-Id: I73dce5736c473a1f79db9be868442c7941d13c44
Signed-off-by: Jack Pham <jackp@codeaurora.org>
drivers/usb/pd/policy_engine.c

index 0df527a..f93ab91 100644 (file)
@@ -481,13 +481,12 @@ static int pd_send_msg(struct usbpd *pd, u8 hdr_type, const u32 *data,
        ret = pd_phy_write(hdr, (u8 *)data, num_data * sizeof(u32), type, 15);
        /* TODO figure out timeout. based on tReceive=1.1ms x nRetryCount? */
 
-       /* MessageID incremented regardless of Tx error */
-       pd->tx_msgid = (pd->tx_msgid + 1) & PD_MAX_MSG_ID;
-
        if (ret < 0)
                return ret;
        else if (ret != num_data * sizeof(u32))
                return -EIO;
+
+       pd->tx_msgid = (pd->tx_msgid + 1) & PD_MAX_MSG_ID;
        return 0;
 }