]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/usb/host/xhci-ring.c
xhci: use completion event's slot id rather than dig it out of command
[mirror_ubuntu-artful-kernel.git] / drivers / usb / host / xhci-ring.c
index 4cad420d770834201b0b1e07b9ac64dbb04da290..88939b798ac6ff8a9a4c934af7deafb4f9c82603 100644 (file)
@@ -1394,6 +1394,26 @@ static void xhci_handle_cmd_enable_slot(struct xhci_hcd *xhci, int slot_id,
        complete(&xhci->addr_dev);
 }
 
+static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id)
+{
+       struct xhci_virt_device *virt_dev;
+
+       virt_dev = xhci->devs[slot_id];
+       if (!virt_dev)
+               return;
+       if (xhci->quirks & XHCI_EP_LIMIT_QUIRK)
+               /* Delete default control endpoint resources */
+               xhci_free_device_endpoint_resources(xhci, virt_dev, true);
+       xhci_free_virt_device(xhci, slot_id);
+}
+
+static void xhci_handle_cmd_addr_dev(struct xhci_hcd *xhci, int slot_id,
+               u32 cmd_comp_code)
+{
+       xhci->devs[slot_id]->cmd_status = cmd_comp_code;
+       complete(&xhci->addr_dev);
+}
+
 static void handle_cmd_completion(struct xhci_hcd *xhci,
                struct xhci_event_cmd *event)
 {
@@ -1451,13 +1471,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
                                GET_COMP_CODE(le32_to_cpu(event->status)));
                break;
        case TRB_TYPE(TRB_DISABLE_SLOT):
-               if (xhci->devs[slot_id]) {
-                       if (xhci->quirks & XHCI_EP_LIMIT_QUIRK)
-                               /* Delete default control endpoint resources */
-                               xhci_free_device_endpoint_resources(xhci,
-                                               xhci->devs[slot_id], true);
-                       xhci_free_virt_device(xhci, slot_id);
-               }
+               xhci_handle_cmd_disable_slot(xhci, slot_id);
                break;
        case TRB_TYPE(TRB_CONFIG_EP):
                virt_dev = xhci->devs[slot_id];
@@ -1518,8 +1532,8 @@ bandwidth_change:
                complete(&xhci->devs[slot_id]->cmd_completion);
                break;
        case TRB_TYPE(TRB_ADDR_DEV):
-               xhci->devs[slot_id]->cmd_status = GET_COMP_CODE(le32_to_cpu(event->status));
-               complete(&xhci->addr_dev);
+               xhci_handle_cmd_addr_dev(xhci, slot_id,
+                               GET_COMP_CODE(le32_to_cpu(event->status)));
                break;
        case TRB_TYPE(TRB_STOP_RING):
                xhci_handle_cmd_stop_ep(xhci, xhci->cmd_ring->dequeue, event);
@@ -1533,9 +1547,9 @@ bandwidth_change:
                xhci_handle_cmd_reset_ep(xhci, event, xhci->cmd_ring->dequeue);
                break;
        case TRB_TYPE(TRB_RESET_DEV):
+               WARN_ON(slot_id != TRB_TO_SLOT_ID(
+                               le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3])));
                xhci_dbg(xhci, "Completed reset device command.\n");
-               slot_id = TRB_TO_SLOT_ID(
-                       le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3]));
                virt_dev = xhci->devs[slot_id];
                if (virt_dev)
                        handle_cmd_in_cmd_wait_list(xhci, virt_dev, event);