Skip to content

Commit 7c1193c

Browse files
sylvioalveskartben
authored andcommitted
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]>
1 parent 30092cf commit 7c1193c

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
@@ -1589,9 +1589,11 @@ static int dwc2_unset_dedicated_fifo(const struct device *dev,
15891589
*diepctl &= ~USB_DWC2_DEPCTL_TXFNUM_MASK;
15901590

15911591
if (priv->dynfifosizing) {
1592-
if (priv->txf_set & ~BIT_MASK(ep_idx)) {
1593-
LOG_WRN("Some of the FIFOs higher than %u are set, %lx",
1594-
ep_idx, priv->txf_set & ~BIT_MASK(ep_idx));
1592+
uint16_t higher_mask = ~BIT_MASK(ep_idx + 1);
1593+
1594+
if (priv->txf_set & higher_mask) {
1595+
LOG_WRN("Some of the FIFOs higher than %u are set, %x",
1596+
ep_idx, priv->txf_set & higher_mask);
15951597
return 0;
15961598
}
15971599

0 commit comments

Comments
 (0)