From patchwork Mon Nov 14 11:28:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 624742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 073DCC433FE for ; Mon, 14 Nov 2022 11:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236216AbiKNL3Q (ORCPT ); Mon, 14 Nov 2022 06:29:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235984AbiKNL2q (ORCPT ); Mon, 14 Nov 2022 06:28:46 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A43420B; Mon, 14 Nov 2022 03:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668425303; x=1699961303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2tt0pXqyf+X16xT+uW1YvPBZjN8jaC7fs9UiviM7Ozw=; b=YrAvqf21nYGAffNIN1j6ibDaOHHeR0tEztOGrAkQBJ/CmfVyy569pbav 44gSXkysv7z5gaULjsQFFZAB+0exrmGmHRkrP9UXpERcXYdFSYeWqUMgF 2CthT4Ac/OKwXwfuA8cU3PK7gfW20oEPV81VtZLv/muYAf5pniUZCugX+ CQUQ7Q3BX1p94Ba4XkB/8MnUWQUy969qQ8Q/nlzXUc86QL7vrTZe/VTyb oEn+TwpSghp8TfF9e1HZNt3+28W8QGti+tPeazCVWBmRbRMlqI4O35sZR ifPuhooedRjPklAfk1+bJPgrX57I5FdyWzy3OM7bCWsjJQjJzF7nlColM A==; X-IronPort-AV: E=McAfee;i="6500,9779,10530"; a="374074728" X-IronPort-AV: E=Sophos;i="5.96,161,1665471600"; d="scan'208";a="374074728" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2022 03:28:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10530"; a="616278550" X-IronPort-AV: E=Sophos;i="5.96,161,1665471600"; d="scan'208";a="616278550" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 14 Nov 2022 03:28:19 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3FAC8346; Mon, 14 Nov 2022 13:28:44 +0200 (EET) From: Andy Shevchenko To: Jakob Koschel , Andy Shevchenko , Greg Kroah-Hartman , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kevin Cernekee , Mathias Nyman , Andrew Morton Subject: [PATCH v1 2/4] usb: gadget: hid: Convert to use list_count() Date: Mon, 14 Nov 2022 13:28:40 +0200 Message-Id: <20221114112842.38565-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114112842.38565-1-andriy.shevchenko@linux.intel.com> References: <20221114112842.38565-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The list API now provides the list_count() to help with counting existing nodes in the list. Uilise it. Signed-off-by: Andy Shevchenko --- drivers/usb/gadget/legacy/hid.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c index 1187ee4f316a..6196c3456e0b 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(&hidg_func_list); if (!funcs) return -ENODEV;