提交 e7a79a1d 编写于 作者: X Xenia Ragiadakou 提交者: Sarah Sharp

xhci: add variable 'cmd_comp_code' in handle_cmd_completion()

This patch adds a new variable 'cmd_comp_code' to hold the command completion
status code aiming to reduce code duplication and to improve code readability.
Signed-off-by: NXenia Ragiadakou <burzalodowa@gmail.com>
Acked-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
上级 6ed46d33
...@@ -1519,6 +1519,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, ...@@ -1519,6 +1519,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
int slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); int slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
u64 cmd_dma; u64 cmd_dma;
dma_addr_t cmd_dequeue_dma; dma_addr_t cmd_dequeue_dma;
u32 cmd_comp_code;
cmd_dma = le64_to_cpu(event->cmd_trb); cmd_dma = le64_to_cpu(event->cmd_trb);
cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg, cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
...@@ -1537,16 +1538,15 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, ...@@ -1537,16 +1538,15 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
trace_xhci_cmd_completion(&xhci->cmd_ring->dequeue->generic, trace_xhci_cmd_completion(&xhci->cmd_ring->dequeue->generic,
(struct xhci_generic_trb *) event); (struct xhci_generic_trb *) event);
if ((GET_COMP_CODE(le32_to_cpu(event->status)) == COMP_CMD_ABORT) || cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
(GET_COMP_CODE(le32_to_cpu(event->status)) == COMP_CMD_STOP)) { if (cmd_comp_code == COMP_CMD_ABORT || cmd_comp_code == COMP_CMD_STOP) {
/* If the return value is 0, we think the trb pointed by /* If the return value is 0, we think the trb pointed by
* command ring dequeue pointer is a good trb. The good * command ring dequeue pointer is a good trb. The good
* trb means we don't want to cancel the trb, but it have * trb means we don't want to cancel the trb, but it have
* been stopped by host. So we should handle it normally. * been stopped by host. So we should handle it normally.
* Otherwise, driver should invoke inc_deq() and return. * Otherwise, driver should invoke inc_deq() and return.
*/ */
if (handle_stopped_cmd_ring(xhci, if (handle_stopped_cmd_ring(xhci, cmd_comp_code)) {
GET_COMP_CODE(le32_to_cpu(event->status)))) {
inc_deq(xhci, xhci->cmd_ring); inc_deq(xhci, xhci->cmd_ring);
return; return;
} }
...@@ -1561,23 +1561,19 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, ...@@ -1561,23 +1561,19 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
switch (le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3]) switch (le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3])
& TRB_TYPE_BITMASK) { & TRB_TYPE_BITMASK) {
case TRB_TYPE(TRB_ENABLE_SLOT): case TRB_TYPE(TRB_ENABLE_SLOT):
xhci_handle_cmd_enable_slot(xhci, slot_id, xhci_handle_cmd_enable_slot(xhci, slot_id, cmd_comp_code);
GET_COMP_CODE(le32_to_cpu(event->status)));
break; break;
case TRB_TYPE(TRB_DISABLE_SLOT): case TRB_TYPE(TRB_DISABLE_SLOT):
xhci_handle_cmd_disable_slot(xhci, slot_id); xhci_handle_cmd_disable_slot(xhci, slot_id);
break; break;
case TRB_TYPE(TRB_CONFIG_EP): case TRB_TYPE(TRB_CONFIG_EP):
xhci_handle_cmd_config_ep(xhci, slot_id, event, xhci_handle_cmd_config_ep(xhci, slot_id, event, cmd_comp_code);
GET_COMP_CODE(le32_to_cpu(event->status)));
break; break;
case TRB_TYPE(TRB_EVAL_CONTEXT): case TRB_TYPE(TRB_EVAL_CONTEXT):
xhci_handle_cmd_eval_ctx(xhci, slot_id, event, xhci_handle_cmd_eval_ctx(xhci, slot_id, event, cmd_comp_code);
GET_COMP_CODE(le32_to_cpu(event->status)));
break; break;
case TRB_TYPE(TRB_ADDR_DEV): case TRB_TYPE(TRB_ADDR_DEV):
xhci_handle_cmd_addr_dev(xhci, slot_id, xhci_handle_cmd_addr_dev(xhci, slot_id, cmd_comp_code);
GET_COMP_CODE(le32_to_cpu(event->status)));
break; break;
case TRB_TYPE(TRB_STOP_RING): case TRB_TYPE(TRB_STOP_RING):
xhci_handle_cmd_stop_ep(xhci, xhci->cmd_ring->dequeue, event); xhci_handle_cmd_stop_ep(xhci, xhci->cmd_ring->dequeue, event);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册