From: Andy Shevchenko Date: Wed, 30 Nov 2022 13:48:36 +0000 (+0200) Subject: usb: gadget: hid: Convert to use list_count_nodes() X-Git-Tag: v6.6.7~3438^2~196 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94c6bcec9f6c4843a9a8d07dddc042ca7a93777c;p=platform%2Fkernel%2Flinux-starfive.git usb: gadget: hid: Convert to use list_count_nodes() The list API provides the list_count_nodes() to help with counting existing nodes in the list. Utilise it. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20221130134838.23805-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c index 1187ee4..133daf8 100644 --- a/drivers/usb/gadget/legacy/hid.c +++ b/drivers/usb/gadget/legacy/hid.c @@ -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_nodes(&hidg_func_list); if (!funcs) return -ENODEV;