From patchwork Tue Nov 22 15:35:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 24437 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2283218wrr; Tue, 22 Nov 2022 07:38:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf5bNvyl8BrRR+gHslfEfVrxRaD38CXnj0BRTJDu4YjTYNbYR/01cG03ekhXPSfy2TLn+uHW X-Received: by 2002:aa7:d999:0:b0:461:7f5a:e04e with SMTP id u25-20020aa7d999000000b004617f5ae04emr5535110eds.389.1669131530003; Tue, 22 Nov 2022 07:38:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669131529; cv=none; d=google.com; s=arc-20160816; b=I36eBsofqGKQ7pcQmUp1sUb1oKgqKPAShz7Monjw7EUO+Px/9L1jAutH4fXeN1W9tX zLxvTargwARfzOCeQfsRiSgtTu/tT8rhj6ck1uaNs5kKsEAsrNsNr1t+w1WRPmB1Llhu bVrg7v/qGSjbHv/QWO1Usjs2PtxZbh6XWRGqshVz37KNkwmUmY+FOdxPSPM11myBwack dn5O36nZImFpsN4x0U84tegljbk+WNbw4F4uVlL48+TEpZlHkqeH7uI9/vWvt/M80Z/B qTF0foT2LSSxcKVajbs/ZlLrGxTZsbRBqBDZAUebwrCQDTTzIOgRd6uVoXWX50dGZmMM bUiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lEpsLkgaNeX2khWpwGIeq2wNnY8dphOaLDMexLLmslc=; b=ueqCBdqA8j8m1rScFACR3JW0r52au+uTGOMTysiahzGKwQVZ0arBI5VIummSe/yEyJ WDsMjrQhYbroz0T8Qcal31ENidzEonaKJrc4huMQm2zADZBgS4KDtEVDkoa9f0MESL68 JMQxqkaU4IWWNFBKzBk1+Sv/krqp9bDjp/X/bSi2AbJpvcb9cqOzL1zUmzIdKxDcXJRa L23VqNnxsmpGefYJb2uLceR4JTF5/k5nh/WAntpMdLUXRYYqoUBi8BeSqBAWGSLKoOE7 Www2D2y+XqyuNJby43664UDboyj+pvXvKkpXb4DKHzTkcmLwb9TgOHIZZbGRLEapYJV2 fbtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CDs97KAw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i23-20020a17090685d700b0073dcb2ec4d2si9400560ejy.889.2022.11.22.07.38.25; Tue, 22 Nov 2022 07:38:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CDs97KAw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233693AbiKVPff (ORCPT + 99 others); Tue, 22 Nov 2022 10:35:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbiKVPfQ (ORCPT ); Tue, 22 Nov 2022 10:35:16 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88A8A697ED; Tue, 22 Nov 2022 07:35:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669131315; x=1700667315; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S4XpqXdqGWk1whCKjTw1Tbea2OWWldUyTEhirb3Ex2I=; b=CDs97KAwtHnZL1ESISARre7fQaI0xQdm9nkVAzIlECDgFYEBaSgUeN2p izbUOnjRcSZyDuVysWVYeWP2L9mANgcFGY3PadxkiC36mv36MnaVNb8LT mD+XEMv/+PvE8Xuj1xydkYehBs9yiuKFzz8a2nd4Q6bBV868+x9om/y8P b7HGxqBRgkDt0Ua94X1dGzhvxo8Qc0thtf89hnXna9EW4oZ0pM5oP3lIL pTVLDpFMWTusJsCwzhPCB8DoxfytQR5L/92kxUtQ5vypY9gBfYaHKAVbZ cYLfehyYLnqPmOWvFvaF96ONPb3ea8KVhpCfzMCJuGs8mc/GyKVH4JTSH A==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="315662396" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="315662396" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2022 07:35:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="747395673" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="747395673" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 22 Nov 2022 07:35:00 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4E543F7; Tue, 22 Nov 2022 17:35:26 +0200 (EET) From: Andy Shevchenko To: Jakob Koschel , Andy Shevchenko , Greg Kroah-Hartman , Mathias Nyman , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Kevin Cernekee , Mathias Nyman , Hans de Goede Subject: [PATCH v3 2/4] usb: gadget: hid: Convert to use list_count() Date: Tue, 22 Nov 2022 17:35:14 +0200 Message-Id: <20221122153516.52577-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221122153516.52577-1-andriy.shevchenko@linux.intel.com> References: <20221122153516.52577-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750211263254175832?= X-GMAIL-MSGID: =?utf-8?q?1750211263254175832?= The list API now provides the list_count() to help with counting existing nodes in the list. Utilise it. Signed-off-by: Andy Shevchenko --- v3: fixed typo in the commit message (Fabio) v2: no change 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;