USB: EHCI: add pointer to end of async-unlink list
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 11 Jul 2012 15:21:43 +0000 (11:21 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Jul 2012 23:50:13 +0000 (16:50 -0700)
This patch (as1570) adds a pointer for the end of ehci-hcd's
async-unlink list.  The list (which is actually a queue) is singly
linked, so having a pointer to its end makes adding new entries easier
-- there's no longer any need to scan through the whole list.

In principle it could be changed to a standard doubly-linked list.  It
turns out that doing so actually makes the code less clear, so I'm
leaving it as is.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-q.c
drivers/usb/host/ehci.h

index efee426a246571b2f10ae873298a6a6952eeeee0..8b75e4279a47ae44dd5dc3e1138214f375a88d49 100644 (file)
@@ -1041,14 +1041,9 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
 
        /* defer till later if busy */
        if (ehci->async_unlink) {
-               struct ehci_qh          *last;
-
-               for (last = ehci->async_unlink;
-                               last->unlink_next;
-                               last = last->unlink_next)
-                       continue;
                qh->qh_state = QH_STATE_UNLINK_WAIT;
-               last->unlink_next = qh;
+               ehci->async_unlink_last->unlink_next = qh;
+               ehci->async_unlink_last = qh;
 
        /* start IAA cycle */
        } else
index 8e80cde8c35e703c926ce82b362f5a71a89558fe..5193612c96ea6564cac1f95de4b97e6b6d4d5259 100644 (file)
@@ -1227,6 +1227,8 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
 
        qh->qh_state = QH_STATE_UNLINK;
        ehci->async_unlink = qh;
+       if (!qh->unlink_next)
+               ehci->async_unlink_last = qh;
 
        prev = ehci->async;
        while (prev->qh_next.qh != qh)
index 3c6c07c0956a826e61255b12e0fc3bcd4dcc2f46..475f23e10bbf7b0bfb29351a07ee49d736804304 100644 (file)
@@ -82,6 +82,7 @@ struct ehci_hcd {                     /* one per controller */
        struct ehci_qh          *async;
        struct ehci_qh          *dummy;         /* For AMD quirk use */
        struct ehci_qh          *async_unlink;
+       struct ehci_qh          *async_unlink_last;
        struct ehci_qh          *qh_scan_next;
        unsigned                scanning : 1;