Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5744692rwb; Mon, 14 Nov 2022 08:53:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rRpLWpKmePOWsHVOVOru01lhleZ8o0IFy1x4xxwsLGp5fVkGDMPsI9D8qDw4mlbiRdRVU X-Received: by 2002:a17:903:50e:b0:188:63db:f23a with SMTP id jn14-20020a170903050e00b0018863dbf23amr220666plb.21.1668444836197; Mon, 14 Nov 2022 08:53:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668444836; cv=none; d=google.com; s=arc-20160816; b=F5jFBTYsWlLOy7Fn6fzf+VLexm3OwL3HQKGr0/lPd04wF6QZk785TA8GpSsDsEMw3c 0V0eYabqQrhruIxl5E1/qG2Ssjo0+3sJJGuS03aZD8BdafnnT4R9ft8brGZo/6tCtssD ZmEposyhZ3oNEBLiO4v0El9LxDFwCIQ9yaPkn3CEqs96HCbr92kp9Lky9zBSKUa+dW+v 36mPi7+8fvk8L/5a2bhKx1eskwxNnqMEVLxmwTeGn+PNhpECWNoG4mWybx1XI74/hiC6 sGKLXNY9MhpkG9aTXb8X80nV+ib9O0AkkOh2IUF155F/INkLcZw5VthYhPRp14kMv5I1 tTgQ== 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=Ngf3+Cgn7R+diEXpJHazkL4CJ3ubwdFv2PSm1HY3J0k=; b=VBgIS9wthYLT2qCIDeh6qXTFeaD8mMef+X674gX/OV6BFK24zzoCyrUfIESUw+G/ld Pz0gVajN56Ul+Q1p1mFpeaer8XQGfvksMJL0MDcjAuAhTbzsy88IX8+oouYCSZiiT+Wf tBcoQn/1LqMLSn2HfZezh7hzIb+fKOkK33yn7pyATDx49ieD2NKK/Zx67XGoh1F8A/Z9 qyyVN3E7+UXZgHDntOGIGYMS4y57o2oWaA01F6HOjuedZRFvLngvoASmX55XcbN/4rSW uyvRDFkmgH5rQBJqx7t6J6NiVApdJVQ4JzvRitPaq48NJ7csA1kQ2RjfvFkiVnpgX46Q PToA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XZ7nwpTx; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a1709029a4400b001768452d4d0si9245656plv.30.2022.11.14.08.53.44; Mon, 14 Nov 2022 08:53:56 -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=XZ7nwpTx; 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 S236989AbiKNQWA (ORCPT + 87 others); Mon, 14 Nov 2022 11:22:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236747AbiKNQVw (ORCPT ); Mon, 14 Nov 2022 11:21:52 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69F2D193C8; Mon, 14 Nov 2022 08:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668442911; x=1699978911; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zFMpj8pIeak4KWo5LltVRHbs15ezgzFEsmtc9On8Ais=; b=XZ7nwpTxZUmXJdQtTc4tQEqBZabumuvCiLmx4lAnY7VbKmMt8xsmC1Xd b8MQDvadWk/WWtyzuT8cmBvvBITqXW9gxZZOUBpYsbapak27vxVA9OlcT nDZKMnnzrybyp52ZRqyh8If/1fX0YkS7RHGLit4RshiEdNoPt8wOXgXE6 K7Zc7+CRKWTBh1y43gaK0IseX6924svEHFDgbXhMRJHjCRrouEHnaPlTI lBKFnQPPA/drfs+NSWYnRCgIaBf4rPO7XSYfuogQQxckqZ6KoP3pcLhbF O2crqbe6EWv1UgcDwj97yBF4qTLSsyT7DobBdltyCEKt0QOGcL8TaotY2 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10531"; a="295375006" X-IronPort-AV: E=Sophos;i="5.96,164,1665471600"; d="scan'208";a="295375006" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2022 08:21:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10531"; a="632861255" X-IronPort-AV: E=Sophos;i="5.96,164,1665471600"; d="scan'208";a="632861255" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 14 Nov 2022 08:21:46 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B76F6B7; Mon, 14 Nov 2022 18:22:10 +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 , Andrew Morton Subject: [PATCH v2 2/4] usb: gadget: hid: Convert to use list_count() Date: Mon, 14 Nov 2022 18:22:05 +0200 Message-Id: <20221114162207.62559-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114162207.62559-1-andriy.shevchenko@linux.intel.com> References: <20221114162207.62559-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 The list API now provides the list_count() to help with counting existing nodes in the list. Uilise it. Signed-off-by: Andy Shevchenko --- 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; -- 2.35.1