usb: xhci: Fix TRB transfer length macro used for Event TRB.
[pandora-kernel.git] / drivers / usb / host / xhci-mem.c
index a40ab98..ee5ec11 100644 (file)
@@ -178,8 +178,15 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
                struct xhci_segment     *next;
 
                next = xhci_segment_alloc(xhci, flags);
-               if (!next)
+               if (!next) {
+                       prev = ring->first_seg;
+                       while (prev) {
+                               next = prev->next;
+                               xhci_segment_free(xhci, prev);
+                               prev = next;
+                       }
                        goto fail;
+               }
                xhci_link_segments(xhci, prev, next, link_trbs, isoc);
 
                prev = next;
@@ -199,7 +206,7 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
        return ring;
 
 fail:
-       xhci_ring_free(xhci, ring);
+       kfree(ring);
        return NULL;
 }
 
@@ -1145,6 +1152,8 @@ static unsigned int xhci_microframes_to_exponent(struct usb_device *udev,
 static unsigned int xhci_parse_microframe_interval(struct usb_device *udev,
                struct usb_host_endpoint *ep)
 {
+       if (ep->desc.bInterval == 0)
+               return 0;
        return xhci_microframes_to_exponent(udev, ep,
                        ep->desc.bInterval, 0, 15);
 }
@@ -1680,6 +1689,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
 {
        struct pci_dev  *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
        struct dev_info *dev_info, *next;
+       struct xhci_cd  *cur_cd, *next_cd;
        unsigned long   flags;
        int size;
        int i, j, num_ports;
@@ -1701,6 +1711,11 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
                xhci_ring_free(xhci, xhci->cmd_ring);
        xhci->cmd_ring = NULL;
        xhci_dbg(xhci, "Freed command ring\n");
+       list_for_each_entry_safe(cur_cd, next_cd,
+                       &xhci->cancel_cmd_list, cancel_cmd_list) {
+               list_del(&cur_cd->cancel_cmd_list);
+               kfree(cur_cd);
+       }
 
        for (i = 1; i < MAX_HC_SLOTS; ++i)
                xhci_free_virt_device(xhci, i);
@@ -2246,6 +2261,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
        xhci->cmd_ring = xhci_ring_alloc(xhci, 1, true, false, flags);
        if (!xhci->cmd_ring)
                goto fail;
+       INIT_LIST_HEAD(&xhci->cancel_cmd_list);
        xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring);
        xhci_dbg(xhci, "First segment DMA is 0x%llx\n",
                        (unsigned long long)xhci->cmd_ring->first_seg->dma);