xhci: Convert to use list_count_nodes()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 30 Nov 2022 13:48:38 +0000 (15:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Jan 2023 15:37:46 +0000 (16:37 +0100)
The list API provides the list_count_nodes() to help with counting
existing nodes in the list. Utilise it.

Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221130134838.23805-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c

index ddc3003..aa4d34e 100644 (file)
@@ -2528,7 +2528,6 @@ static int handle_tx_event(struct xhci_hcd *xhci,
        union xhci_trb *ep_trb;
        int status = -EINPROGRESS;
        struct xhci_ep_ctx *ep_ctx;
-       struct list_head *tmp;
        u32 trb_comp_code;
        int td_num = 0;
        bool handling_skipped_tds = false;
@@ -2582,10 +2581,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
        }
 
        /* Count current td numbers if ep->skip is set */
-       if (ep->skip) {
-               list_for_each(tmp, &ep_ring->td_list)
-                       td_num++;
-       }
+       if (ep->skip)
+               td_num += list_count_nodes(&ep_ring->td_list);
 
        /* Look for common error cases */
        switch (trb_comp_code) {