@@ -2613,8 +2613,9 @@ static int handle_tx_event(struct xhci_hcd *xhci,
union xhci_trb *ep_trb;
int status = -EINPROGRESS;
struct xhci_ep_ctx *ep_ctx;
u32 trb_comp_code;
+ bool short_packet = false;
slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1;
trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len));
@@ -2645,14 +2646,15 @@ static int handle_tx_event(struct xhci_hcd *xhci,
* transfer type
*/
case COMP_SUCCESS:
if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) {
- trb_comp_code = COMP_SHORT_PACKET;
+ short_packet = true;
xhci_dbg(xhci, "Successful completion on short TX for slot %u ep %u with last td short %d\n",
slot_id, ep_index, ep_ring->last_td_was_short);
}
break;
case COMP_SHORT_PACKET:
+ short_packet = true;
break;
/* Completion codes for endpoint stopped state */
case COMP_STOPPED:
xhci_dbg(xhci, "Stopped on Transfer TRB for slot %u ep %u\n",
@@ -2896,12 +2898,9 @@ static int handle_tx_event(struct xhci_hcd *xhci,
trb_in_td(xhci, td, ep_trb_dma, true);
return -ESHUTDOWN;
}
- if (trb_comp_code == COMP_SHORT_PACKET)
- ep_ring->last_td_was_short = true;
- else
- ep_ring->last_td_was_short = false;
+ ep_ring->last_td_was_short = short_packet;
ep_trb = &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) / sizeof(*ep_trb)];
trace_xhci_handle_transfer(ep_ring, (struct xhci_generic_trb *) ep_trb);
This variable normally is an endian-corrected copy of the completion code received from hardware, except for one case where it is changed in order to trick some later code into setting some flag. This can be confusing when analyzing or debugging the function and the false completion code is sometimes written to dmesg too. For even more confusion, functions called by handle_tx_event() also have same-named variables but they initialize them from scratch from the hardware event, undoing this change within their scope. Use a dedicated local variable instead of such machinations. Signed-off-by: Michal Pecio <michal.pecio@gmail.com> --- drivers/usb/host/xhci-ring.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)