Skip to content

Commit 0ec9400

Browse files
sylvioalvescarlescufi
authored andcommitted
[nrf fromtree] udc_dwc2: fix off-by-one in TX FIFO unset check
Fix the check in dwc2_unset_dedicated_fifo() that wrongly included the current endpoint when testing for higher FIFOs. This caused false warnings and early returns. Use ~BIT_MASK(ep_idx + 1) to only test FIFOs above the current EP. Signed-off-by: Sylvio Alves <[email protected]> (cherry picked from commit 7c1193c)
1 parent df375fd commit 0ec9400

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/usb/udc/udc_dwc2.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,9 +1586,11 @@ static int dwc2_unset_dedicated_fifo(const struct device *dev,
15861586
*diepctl &= ~USB_DWC2_DEPCTL_TXFNUM_MASK;
15871587

15881588
if (priv->dynfifosizing) {
1589-
if (priv->txf_set & ~BIT_MASK(ep_idx)) {
1590-
LOG_WRN("Some of the FIFOs higher than %u are set, %lx",
1591-
ep_idx, priv->txf_set & ~BIT_MASK(ep_idx));
1589+
uint16_t higher_mask = ~BIT_MASK(ep_idx + 1);
1590+
1591+
if (priv->txf_set & higher_mask) {
1592+
LOG_WRN("Some of the FIFOs higher than %u are set, %x",
1593+
ep_idx, priv->txf_set & higher_mask);
15921594
return 0;
15931595
}
15941596

0 commit comments

Comments
 (0)