usb: gadget: hid: Convert to use list_count()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 23 Nov 2022 14:48:59 +0000 (16:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Nov 2022 07:56:09 +0000 (08:56 +0100)
The list API now provides the list_count() to help with counting
existing nodes in the list. Utilise it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221123144901.40493-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/legacy/hid.c

index 1187ee4f316abf5d27dea5fd251ba076ddaa2821..6196c3456e0be2126676dd1fccb99854a2944765 100644 (file)
@@ -133,14 +133,11 @@ static struct usb_configuration config_driver = {
 static int hid_bind(struct usb_composite_dev *cdev)
 {
        struct usb_gadget *gadget = cdev->gadget;
-       struct list_head *tmp;
        struct hidg_func_node *n = NULL, *m, *iter_n;
        struct f_hid_opts *hid_opts;
-       int status, funcs = 0;
-
-       list_for_each(tmp, &hidg_func_list)
-               funcs++;
+       int status, funcs;
 
+       funcs = list_count(&hidg_func_list);
        if (!funcs)
                return -ENODEV;