mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 21:57:43 +00:00
xhci: cleanup and refactor process_ctrl_td()
Refactor pricess_ctrl_tx() to make it more readable No functional changes Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
52ab86852f
commit
0b6c324c8b
1 changed files with 45 additions and 58 deletions
|
@ -1932,6 +1932,8 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
|
||||||
int ep_index;
|
int ep_index;
|
||||||
struct xhci_ep_ctx *ep_ctx;
|
struct xhci_ep_ctx *ep_ctx;
|
||||||
u32 trb_comp_code;
|
u32 trb_comp_code;
|
||||||
|
u32 remaining, requested;
|
||||||
|
bool on_data_stage;
|
||||||
|
|
||||||
slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
|
slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
|
||||||
xdev = xhci->devs[slot_id];
|
xdev = xhci->devs[slot_id];
|
||||||
|
@ -1939,89 +1941,74 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
|
||||||
ep_ring = xhci_dma_to_transfer_ring(ep, le64_to_cpu(event->buffer));
|
ep_ring = xhci_dma_to_transfer_ring(ep, le64_to_cpu(event->buffer));
|
||||||
ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index);
|
ep_ctx = xhci_get_ep_ctx(xhci, xdev->out_ctx, ep_index);
|
||||||
trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len));
|
trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len));
|
||||||
|
requested = td->urb->transfer_buffer_length;
|
||||||
|
remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
|
||||||
|
|
||||||
|
/* not setup (dequeue), or status stage means we are at data stage */
|
||||||
|
on_data_stage = (event_trb != ep_ring->dequeue &&
|
||||||
|
event_trb != td->last_trb);
|
||||||
|
|
||||||
switch (trb_comp_code) {
|
switch (trb_comp_code) {
|
||||||
case COMP_SUCCESS:
|
case COMP_SUCCESS:
|
||||||
if (event_trb == ep_ring->dequeue) {
|
if (event_trb != td->last_trb) {
|
||||||
xhci_warn(xhci, "WARN: Success on ctrl setup TRB "
|
xhci_warn(xhci, "WARN: Success on ctrl %s TRB without IOC set?\n",
|
||||||
"without IOC set??\n");
|
on_data_stage ? "data" : "setup");
|
||||||
*status = -ESHUTDOWN;
|
*status = -ESHUTDOWN;
|
||||||
} else if (event_trb != td->last_trb) {
|
break;
|
||||||
xhci_warn(xhci, "WARN: Success on ctrl data TRB "
|
|
||||||
"without IOC set??\n");
|
|
||||||
*status = -ESHUTDOWN;
|
|
||||||
} else {
|
|
||||||
*status = 0;
|
|
||||||
}
|
}
|
||||||
|
*status = 0;
|
||||||
break;
|
break;
|
||||||
case COMP_SHORT_TX:
|
case COMP_SHORT_TX:
|
||||||
*status = 0;
|
*status = 0;
|
||||||
break;
|
break;
|
||||||
case COMP_STOP_SHORT:
|
case COMP_STOP_SHORT:
|
||||||
if (event_trb == ep_ring->dequeue || event_trb == td->last_trb)
|
if (on_data_stage)
|
||||||
xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n");
|
td->urb->actual_length = remaining;
|
||||||
else
|
else
|
||||||
td->urb->actual_length =
|
xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n");
|
||||||
EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
|
goto finish_td;
|
||||||
|
|
||||||
return finish_td(xhci, td, event_trb, event, ep, status, false);
|
|
||||||
case COMP_STOP:
|
case COMP_STOP:
|
||||||
/* Did we stop at data stage? */
|
if (on_data_stage)
|
||||||
if (event_trb != ep_ring->dequeue && event_trb != td->last_trb)
|
td->urb->actual_length = requested - remaining;
|
||||||
td->urb->actual_length =
|
goto finish_td;
|
||||||
td->urb->transfer_buffer_length -
|
|
||||||
EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
|
|
||||||
/* fall through */
|
|
||||||
case COMP_STOP_INVAL:
|
case COMP_STOP_INVAL:
|
||||||
return finish_td(xhci, td, event_trb, event, ep, status, false);
|
goto finish_td;
|
||||||
default:
|
default:
|
||||||
if (!xhci_requires_manual_halt_cleanup(xhci,
|
if (!xhci_requires_manual_halt_cleanup(xhci,
|
||||||
ep_ctx, trb_comp_code))
|
ep_ctx, trb_comp_code))
|
||||||
break;
|
break;
|
||||||
xhci_dbg(xhci, "TRB error code %u, "
|
xhci_dbg(xhci, "TRB error %u, halted endpoint index = %u\n",
|
||||||
"halted endpoint index = %u\n",
|
trb_comp_code, ep_index);
|
||||||
trb_comp_code, ep_index);
|
|
||||||
/* else fall through */
|
/* else fall through */
|
||||||
case COMP_STALL:
|
case COMP_STALL:
|
||||||
/* Did we transfer part of the data (middle) phase? */
|
/* Did we transfer part of the data (middle) phase? */
|
||||||
if (event_trb != ep_ring->dequeue &&
|
if (on_data_stage)
|
||||||
event_trb != td->last_trb)
|
td->urb->actual_length = requested - remaining;
|
||||||
td->urb->actual_length =
|
|
||||||
td->urb->transfer_buffer_length -
|
|
||||||
EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
|
|
||||||
else if (!td->urb_length_set)
|
else if (!td->urb_length_set)
|
||||||
td->urb->actual_length = 0;
|
td->urb->actual_length = 0;
|
||||||
|
goto finish_td;
|
||||||
return finish_td(xhci, td, event_trb, event, ep, status, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* stopped at setup stage, no data transferred */
|
||||||
|
if (event_trb == ep_ring->dequeue)
|
||||||
|
goto finish_td;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Did we transfer any data, despite the errors that might have
|
* if on data stage then update the actual_length of the URB and flag it
|
||||||
* happened? I.e. did we get past the setup stage?
|
* as set, so it won't be overwritten in the event for the last TRB.
|
||||||
*/
|
*/
|
||||||
if (event_trb != ep_ring->dequeue) {
|
if (on_data_stage) {
|
||||||
/* The event was for the status stage */
|
td->urb_length_set = true;
|
||||||
if (event_trb == td->last_trb) {
|
td->urb->actual_length = requested - remaining;
|
||||||
if (!td->urb_length_set) {
|
xhci_dbg(xhci, "Waiting for status stage event\n");
|
||||||
td->urb->actual_length =
|
return 0;
|
||||||
td->urb->transfer_buffer_length;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Maybe the event was for the data stage? If so, update
|
|
||||||
* already the actual_length of the URB and flag it as
|
|
||||||
* set, so that it is not overwritten in the event for
|
|
||||||
* the last TRB.
|
|
||||||
*/
|
|
||||||
td->urb_length_set = true;
|
|
||||||
td->urb->actual_length =
|
|
||||||
td->urb->transfer_buffer_length -
|
|
||||||
EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
|
|
||||||
xhci_dbg(xhci, "Waiting for status "
|
|
||||||
"stage event\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* at status stage */
|
||||||
|
if (!td->urb_length_set)
|
||||||
|
td->urb->actual_length = requested;
|
||||||
|
|
||||||
|
finish_td:
|
||||||
return finish_td(xhci, td, event_trb, event, ep, status, false);
|
return finish_td(xhci, td, event_trb, event, ep, status, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue