[PATCH RESEND v4 2/9] usb: xhci: create one unified function to calculate TRB TD remainder
Marek Vasut
marex at denx.de
Wed Sep 9 15:26:38 CEST 2020
On 9/8/20 6:59 PM, Frank Wunderlich wrote:
[...]
> +static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
> + int trb_buff_len, unsigned int td_total_len,
> + int maxp, bool more_trbs_coming)
> {
> - int packets_transferred;
> + u32 total_packet_count;
> +
> + if (ctrl->hci_version < 0x100)
> + return ((td_total_len - transferred) >> 10);
Here and ...
> /* One TRB with a zero-length data packet. */
> - if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
> + if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) ||
> + trb_buff_len == td_total_len)
> return 0;
>
> - /*
> - * All the TRB queueing functions don't count the current TRB in
> - * running_total.
> - */
> - packets_transferred = (running_total + trb_buff_len) / maxpacketsize;
> + total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
>
> - if ((total_packet_count - packets_transferred) > 31)
> - return 31 << 17;
> - return (total_packet_count - packets_transferred) << 17;
> + /* Queueing functions don't count the current TRB into transferred */
> + return (total_packet_count - ((transferred + trb_buff_len) / maxp));
... here. The outer parenthesis are not needed, can you check them in
other functions too and send a subsequent cleanup patch ?
I applied the patcheset to u-boot-usb/next , thanks.
More information about the U-Boot
mailing list