Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 32db3d94 authored by John Youn's avatar John Youn Committed by Felipe Balbi
Browse files

usb: dwc3: gadget: Account for max size in TRB space



The current calculation takes dep->trb_dequeue - dep->trb_enqueue to
find the TRB space left.

If you enqueue 1, that results in:
(u8) 0 - (u8) 1 = 0xff = 255 TRBs left.

This is correct if DWC3_TRB_NUM == 256.

If DWC3_TRB_NUM is less than 256 (but still a power of 2) you need to
mod the result by DWC3_TRB_NUM.

For example the same calculation with DWC3_TRB_NUM = 8, results in:
255 % 6 = 7 TRBs left.

Signed-off-by: default avatarJohn Youn <johnyoun@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 89bc856e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment