]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
usb: tcpm: fix inverted poll condition in tcpm_pd_transmit()
authorPeng Fan <peng.fan@nxp.com>
Thu, 18 Jun 2026 06:48:48 +0000 (14:48 +0800)
committerMarek Vasut <marek.vasut+usb@mailbox.org>
Thu, 18 Jun 2026 14:48:16 +0000 (16:48 +0200)
The read_poll_timeout() macro breaks out of its loop when the condition
evaluates to true. The current code uses "!tx_complete" as the
condition, which means it exits immediately when tx_complete is false
(i.e., transmission has NOT completed yet), rather than waiting for
completion.

Fix the condition to "tx_complete" so that the poll loop waits until
the TCPC signals transmission success/failure/discard before
proceeding.

Without this fix, tcpm_pd_transmit() returns before the TCPC has
finished transmitting, causing the PD state machine to proceed with
stale tx_status values.

Fixes: 1db4c0ac77e3 ("usb: tcpm: add core framework")
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/usb/tcpm/tcpm.c

index 3061b466d7c7e3736469018f25e8b7906ebf3cf3..d6c0be8233306dbb66f858adf0a66be13016e639 100644 (file)
@@ -207,7 +207,7 @@ static int tcpm_pd_transmit(struct udevice *dev,
         */
        timeout_us *= 5;
        ret = read_poll_timeout(tcpm_transmit_helper, tx_complete,
-                               !tx_complete, false, timeout_us, dev);
+                               tx_complete, false, timeout_us, dev);
        if (ret < 0) {
                dev_err(dev, "TCPM: PD transmit data failed: %d\n", ret);
                return ret;