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 <st...@rowland.harvard.edu>

---

 drivers/usb/host/ehci-hcd.c |    9 ++-------
 drivers/usb/host/ehci-q.c   |    2 ++
 drivers/usb/host/ehci.h     |    1 +
 3 files changed, 5 insertions(+), 7 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===================================================================
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -82,6 +82,7 @@ struct ehci_hcd {                     /* one per controlle
        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;
 
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===================================================================
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -1041,14 +1041,9 @@ static void unlink_async (struct ehci_hc
 
        /* 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: usb-3.4/drivers/usb/host/ehci-q.c
===================================================================
--- usb-3.4.orig/drivers/usb/host/ehci-q.c
+++ usb-3.4/drivers/usb/host/ehci-q.c
@@ -1227,6 +1227,8 @@ static void start_unlink_async (struct e
 
        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)


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to