From patchwork Wed Nov 23 14:48:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 25033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2835674wrr; Wed, 23 Nov 2022 06:52:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf6OEUUGcro3K5cdqTzrpW9F90qpUuAQHxcT2WVs7/s7P9xlPivt8c1tJBFvomoQ3yrmjBgg X-Received: by 2002:a17:90a:708a:b0:20a:eaab:137 with SMTP id g10-20020a17090a708a00b0020aeaab0137mr31302853pjk.206.1669215139761; Wed, 23 Nov 2022 06:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669215139; cv=none; d=google.com; s=arc-20160816; b=g+kYeYYwa1H1+KOfuM9CEw3e5AEYM0Z5kRFlaJDIrEuixoBaofRUZLB394L06I1RTl vtsoF8LG2KMjNTSz+7smNg63OAvCDoWZogdVme8gZXA4WD/SCzCwzs1UHAKuiAmZN174 YQva7nn5BVKhw3kieR8FWBoSM2/UbqTtmFVR2AbTiBBVNCSZEMZ3gSFhQmvqdZUVCpF9 14Qvonb5y/NYJOyuBki3BzJQbWVrDAFa/NP/xSyLA2wlcyInlcVyIE+OAAdxjyOMEwhx jSJCtCLmqQIRfiu0WwFCZfTuz6lPiPThz15Bq+NVKl/L4cG2qlbzp5YOVE/TrlmOM6vA EPBQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ZeSB9qdn73Myt2i0jHzn3NwGLhoTS9nYQuS1263f0g4=; b=zvVSWhc7R3B1IQjz+5pljDl49iJdhPM3mZShmlGqOhOjvr+xpDUhoKssPMNaCk3Ke2 lVkH42pLkp2llHEvmG9q46Q9lbmI+fCybsTUVPCDsJMiJHWPCMNMqxNw6ih57NxDKLHJ m5+2H7vmQr6hEG0dxfSmDsD6QZ4YNLdWlPXNRwWQCR7R8oRJYZ6+4sTKSREzQ99pCwhg d1mdUpYhdk59nRPPWttwk9Ok1xMNdkeP6gWhKLCMN55P6QHAV6UEJO/qj1IWQRAlO+VC 1T36/YyiArD1mB4Hv7nlB1ZAQRuuiGp1dYIR8SzFm3+6H40oxbXudaoRSn1SmJQkcwID RDfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P5vnlvey; 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 x69-20020a638648000000b00477c2326410si1027656pgd.298.2022.11.23.06.52.06; Wed, 23 Nov 2022 06:52:19 -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=P5vnlvey; 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 S237621AbiKWOt2 (ORCPT + 99 others); Wed, 23 Nov 2022 09:49:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237580AbiKWOtQ (ORCPT ); Wed, 23 Nov 2022 09:49:16 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 264306CA12; Wed, 23 Nov 2022 06:49:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669214954; x=1700750954; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6CaDzmwprgLasCtAjji0nqGgQ6qOSWdVD2cInwSVDOE=; b=P5vnlveyz4nNZzzJ/MQgHJOvUpWYDjlnFsFExWsTsy6GUdHXkeKoAozL HHjGuw8LcB+1tJhgjjIyuA/Ga9cYu0WrUnYFKVe8nqL4sRrsqIoa/rK0H 5OvoW2/4SPLObauGFQ6GP7yk6CsgQQ7bhzNFDrvL2SiD40R8n9R5Njoqt z2/kONs+QEIJFJSWXI0C59K+/yh50Dd+isUyAjKk3dMqkSamd2ZE/hkUC HcuxWmZBxZ4US64jL6y9RH0m+LOjsjwRqUQJWAiXPKGU3cgk3QHRmFbNb IfDFRcWi3I2jh14eMRKClfpxMuBfTdSJbvGwatRrnH51rq/4qLP74AMlL g==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="376225212" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="376225212" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 06:48:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="635936973" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="635936973" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 23 Nov 2022 06:48:37 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 80918128; Wed, 23 Nov 2022 16:49:03 +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 , Jani Nikula Subject: [PATCH v4 1/4] i915: Move list_count() to list.h for broader use Date: Wed, 23 Nov 2022 16:48:58 +0200 Message-Id: <20221123144901.40493-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 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?1750298934076057813?= X-GMAIL-MSGID: =?utf-8?q?1750298934076057813?= Some of the existing users, and definitely will be new ones, want to count existing nodes in the list. Provide a generic API for that by moving code from i915 to list.h. Signed-off-by: Andy Shevchenko Acked-by: Jani Nikula Reviewed-by: Lucas De Marchi --- v4: fixed prototype when converting to static inline v3: added tag (Jani), changed to be static inline (Mike) v2: dropped the duplicate code in i915 (LKP) drivers/gpu/drm/i915/gt/intel_engine_cs.c | 13 +------------ include/linux/list.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c index c33e0d72d670..b96c8217743c 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c @@ -2094,17 +2094,6 @@ static void print_request_ring(struct drm_printer *m, struct i915_request *rq) } } -static unsigned long list_count(struct list_head *list) -{ - struct list_head *pos; - unsigned long count = 0; - - list_for_each(pos, list) - count++; - - return count; -} - static unsigned long read_ul(void *p, size_t x) { return *(unsigned long *)(p + x); @@ -2279,7 +2268,7 @@ void intel_engine_dump(struct intel_engine_cs *engine, spin_lock_irqsave(&engine->sched_engine->lock, flags); engine_dump_active_requests(engine, m); - drm_printf(m, "\tOn hold?: %lu\n", + drm_printf(m, "\tOn hold?: %zu\n", list_count(&engine->sched_engine->hold)); spin_unlock_irqrestore(&engine->sched_engine->lock, flags); diff --git a/include/linux/list.h b/include/linux/list.h index 61762054b4be..632a298c7018 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -655,6 +655,21 @@ static inline void list_splice_tail_init(struct list_head *list, !list_is_head(pos, (head)); \ pos = n, n = pos->prev) +/** + * list_count - count nodes in the list + * @head: the head for your list. + */ +static inline size_t list_count(struct list_head *head) +{ + struct list_head *pos; + size_t count = 0; + + list_for_each(pos, head) + count++; + + return count; +} + /** * list_entry_is_head - test if the entry points to the head of the list * @pos: the type * to cursor From patchwork Wed Nov 23 14:48:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 25031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2835601wrr; Wed, 23 Nov 2022 06:52:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ZFANBZA1ouRwWeevi9rfDHd/CCSA4fI1AFvjSgC3pui6UoXngBVouTR2DPpBAHa4BIpJD X-Received: by 2002:a05:6a00:4287:b0:56c:1251:8718 with SMTP id bx7-20020a056a00428700b0056c12518718mr9775759pfb.62.1669215126009; Wed, 23 Nov 2022 06:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669215126; cv=none; d=google.com; s=arc-20160816; b=n3o7O12DDre5sK9R+rkJA5sIm0w58afUojos37xIGjmt6JSypKrJdGWxNYj4OAYYoB 01HEivFAVcz7y66bU35EBwDNeLtHYUTEabhG6PHJZYEpavGGxYOpio9lVqqaG9lfwgAC 7fpnn8WnF1FfRFnJtXU8goAXy0ztO0aenPqqXfrGm94pKYdHI4ujnpZ/jVDK8LpcpJy0 K3JHrdrTh5QyScUYmG0Sf7yfEVlIkOMtJ1j5Z4gCvbghI9NTOaHFvHCofZ3ahIcaBs32 AEBLkhF9xz9Net0GJ+hwgEVCSowCsmHBvse7exQ5C3E2j7yX7yUb1ddb1T3DhRFLTxmu 0wdg== 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=wuk5z95m1tY0YQdeA9+MlMCmiiAyLgEeZIaKkiM25zI=; b=JCXujo2I1IOyACrDHNGLv7j2a0/F2CIS0pVcOpOoSXVMETvL6pfQTsQInRBM0xVFX5 53MGmxK5sS+Z96+loJfoOUYohI+pMWIBN8MLt4OZs5AARQryUeNfUkCRymkQZA5mM2KM EXNIllFCHo/YUz9Hns/VfbcceGAQ5cdI10Plvexg4wWWrgj/xAzhPa/V83NAh9Vrmg5H N2O/TguZBuXkIL5mR4DdZfGswCj4iGBnJx7Tee0NcmCqKPsi18Iul60fmccOvLLtRuCx W3AKjQIo1Oht3Wum+bdABbTKbhNYzrk41ebmCoLle6HNX7JGMBYjvXxuZx1a+M0QYAjK 3jmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b94MSyV6; 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 c20-20020a6566d4000000b00476ea7b91ddsi16178487pgw.51.2022.11.23.06.51.51; Wed, 23 Nov 2022 06:52:05 -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=b94MSyV6; 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 S237497AbiKWOtU (ORCPT + 99 others); Wed, 23 Nov 2022 09:49:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237484AbiKWOtO (ORCPT ); Wed, 23 Nov 2022 09:49:14 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 093AF74A83; Wed, 23 Nov 2022 06:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669214951; x=1700750951; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PZw/qx/VCBuHt8kLTtD2kAjtrp/ndgtSgsymsuc6HUA=; b=b94MSyV6Z3VbT8k4JYhSSkUqY7+WLa3Fth1u8DJFhCIB0Yl1ZDtJgzl7 vkoosvAr/k4/0X7DTa0S7fnBy9s/PHtIwmyNu2u3mJfmh/ceN+GrFBN53 84iq5BOEk4Cr/a/Do5s+wcVe6NwjddSUZ3YiREmiUR6oaaUB5LXi9WHfL hussW35TGAucXEty9DXmJvGJXux6q30N5BaOYpRooWycO5bI0XhKzUceP pXJhimV92n7JQbRbBBTW/gpyVImGvVMJfxLq4wm2V7s5tZt/ffaEVms5p C6JQ55osYLQZ1LAKnEmA09FIlYe3SsYcJVnIeTq9a7G5ZenIqFGYxPCaj g==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="376225198" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="376225198" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 06:48:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="635936969" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="635936969" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 23 Nov 2022 06:48:37 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9096CB7; Wed, 23 Nov 2022 16:49:03 +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 v4 2/4] usb: gadget: hid: Convert to use list_count() Date: Wed, 23 Nov 2022 16:48:59 +0200 Message-Id: <20221123144901.40493-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221123144901.40493-1-andriy.shevchenko@linux.intel.com> References: <20221123144901.40493-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?1750298919473120682?= X-GMAIL-MSGID: =?utf-8?q?1750298919473120682?= The list API now provides the list_count() to help with counting existing nodes in the list. Utilise it. Signed-off-by: Andy Shevchenko --- v4: no change 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; From patchwork Wed Nov 23 14:49:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 25032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2835614wrr; Wed, 23 Nov 2022 06:52:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf68pmds+s4JRnhx+FPAMVlseQ31b/QK1pJhyQJQtTRS6iv2pA0jZW/Cmrbbp0YAwwYUU8Op X-Received: by 2002:a17:902:a5cc:b0:186:de87:7ffd with SMTP id t12-20020a170902a5cc00b00186de877ffdmr21472363plq.94.1669215127693; Wed, 23 Nov 2022 06:52:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669215127; cv=none; d=google.com; s=arc-20160816; b=dN0vi4LxhbJewpfGzfN+t8e41/i8dgUpwFwn0azF02eEHnavOdX9suhOVXWyTZIs+Z XE8PfGBorsK9j+GAFyJF9Xzobp76hnI5cOMfBwQhmC4Fy9AjKorAFogmXGx916nDiy/X 1XGYjuSAeC5JIZodBs8wR7McOl2ytQcPe/nzIQYlSLyi4wWsxrsFllIYeeCAMJBcd9ZY vFKYXIb4QWuq4tugF5Nj9xU/l3Y96O+5TM1aRokwm31/nf/tanp4w+JXz+ljeQG6n5nu I9xrSKN3Lce8JshG4LNUlz0s/ag/I/dtVclRtc4RmsEL1SD/zCB6cC5ED9fkSJ0BuP8A F9xg== 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=bcvnQL3fjsLSAjxWAHOQp/RM4LK2n9tyx2Y958WJ0ys=; b=VB24TKdigrPnPjKgysqnaXM3PZRPDQMVJtfxwoBj4KvinD0KR987aFH2ZRq3AgyU2J wtvvhl3PHa1TDUzrY+4yjfWoHN3DhWqetuU/wzfRNGB2IGPxaaYH/vaLSCrqXI5+E2cG toHngW3jk9ZyOSZLfT5G3hdOEeA6c09DtxUj+2mT4iBxnpvyuiDpT1VtegojclKvqSxe 4HbCIpGGAcwmi2yD6Rk0WJJLyrfNHgaL4DVUfSgjgClLqWMHPD0SEAfahv0Q20kGXyHQ XKRcacfDjMaGWg6j4DodBQuOX1U802ww7/r/ul/Fb2HKporf7fknYNhA2Xh7ZudODGyB d0Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Kvg0AP4U; 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 cp5-20020a170902e78500b0017deb323079si787063plb.142.2022.11.23.06.51.54; Wed, 23 Nov 2022 06:52:07 -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=Kvg0AP4U; 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 S237340AbiKWOtZ (ORCPT + 99 others); Wed, 23 Nov 2022 09:49:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237549AbiKWOtP (ORCPT ); Wed, 23 Nov 2022 09:49:15 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36A0B70188; Wed, 23 Nov 2022 06:49:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669214952; x=1700750952; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yNdh/hk4prTZOSg8R5rGTM68n79WKoKNAojMOq62B0c=; b=Kvg0AP4UY358dpDgJDZEWma9ql/q39sFfEyD+KkhQS7PbE0b1+trDHs/ Yr8a/t9Xibxrzs36qRToPA0W8FLgKv0wmXR3k99r+6fsBQtwlLjw7JFpb UR/XUXyZrKH+C/w+/DFbE0viosSOpHinhXQ2vcxVNDjTHRa5rGKUf1htR xaNqeJpz+mSBwioyAgqgQ4qO5P3qP4RPfmpsHe5JJeA+jEg5rqNZvJaTV 1m2ZLThQwdWDDtQP8unRU6OZJlpjK0oLvGmSrzzzM4cGwlDPplJp/3Kaa J96sIeJ51qg0laE05HUXpUTJIhV70DZB5HGcSAWAg/C0KH0LTsdye2mY6 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="376225206" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="376225206" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 06:48:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="635936971" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="635936971" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 23 Nov 2022 06:48:37 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A0A95184; Wed, 23 Nov 2022 16:49:03 +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 v4 3/4] usb: gadget: udc: bcm63xx: Convert to use list_count() Date: Wed, 23 Nov 2022 16:49:00 +0200 Message-Id: <20221123144901.40493-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221123144901.40493-1-andriy.shevchenko@linux.intel.com> References: <20221123144901.40493-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?1750298921683292089?= X-GMAIL-MSGID: =?utf-8?q?1750298921683292089?= The list API now provides the list_count() to help with counting existing nodes in the list. Utilise it. Signed-off-by: Andy Shevchenko --- v4: no change v3: no change v2: no change drivers/usb/gadget/udc/bcm63xx_udc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c index 2cdb07905bde..0762e49e85f8 100644 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c @@ -2172,7 +2172,6 @@ static int bcm63xx_iudma_dbg_show(struct seq_file *s, void *p) for (ch_idx = 0; ch_idx < BCM63XX_NUM_IUDMA; ch_idx++) { struct iudma_ch *iudma = &udc->iudma[ch_idx]; - struct list_head *pos; seq_printf(s, "IUDMA channel %d -- ", ch_idx); switch (iudma_defaults[ch_idx].ep_type) { @@ -2205,14 +2204,10 @@ static int bcm63xx_iudma_dbg_show(struct seq_file *s, void *p) seq_printf(s, " desc: %d/%d used", iudma->n_bds_used, iudma->n_bds); - if (iudma->bep) { - i = 0; - list_for_each(pos, &iudma->bep->queue) - i++; - seq_printf(s, "; %d queued\n", i); - } else { + if (iudma->bep) + seq_printf(s, "; %zu queued\n", list_count(&iudma->bep->queue)); + else seq_printf(s, "\n"); - } for (i = 0; i < iudma->n_bds; i++) { struct bcm_enet_desc *d = &iudma->bd_ring[i]; From patchwork Wed Nov 23 14:49:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 25030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2835529wrr; Wed, 23 Nov 2022 06:51:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf5mkmAgGfUPq0xKONhNgn5IVMjGl//C/HPmuUk7leIsTz0RFRD0bMIBXwdBTCLnoLyRM8/p X-Received: by 2002:a05:6402:3808:b0:468:c911:d843 with SMTP id es8-20020a056402380800b00468c911d843mr25811714edb.422.1669215116663; Wed, 23 Nov 2022 06:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669215116; cv=none; d=google.com; s=arc-20160816; b=gmNWK5vlWtBuUeVOfQynShZCMH7ZZxxKNGo9WR3LwhFoHsu4oN7q9xRxR68zR/rN9B susc1o3c10RCXxRmu9WKbF0pglp/U3KWaWAMQRxop+L/w0BdxelVaQ813FPY/xB4Pq81 Toob4MPpp9NARFy6nQ5CcHbDvij7Zonl3hmVMmcSWvKV6dBs/Fn/v/HUUbn9z8o3fbOv 3917UBtaLWPReQ4LJPCqX5/x7iFSF/Tihs3x71dVVoXIwnOFGjiZ1b4vlFbB5bO2y22C yGGgc9i0HA8vUU1myjQJD6nMfSFgtMIP0Hj8XyjuIJbX2/hEcc1McdrJm62MOtZNkfng Z3ag== 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=adpYtAW7sCnKq/12s/rJUKK7mXCu21bBwa2aEnJ0hqY=; b=fn1ERmu/4e18UTVW8YReABYi+NHuE7dbf7tsd34Swaw2Wb9Z0BspNeFL35oStzyeUC ul1+Aiwt55pBzg5tWVSioRJRFKJYjTfPMaTFhiiuz3N6COP8wmKQW3ufvAr74waUakFr PVVzElemLlAdgLBYWKbT78n3yVJdtliZq7BWGlHzirViqjoKOUp0H53xvyx06To8fy9z pP1JxvJ3fHdUwC62EIzttWRJLz1VOHrN/g3KztRpT3gP6wQ7dQ3Tq+1uiwlLUi2XdE+7 uMX103KY3UpA1B0AN4gM3Ofz5+1kvn3+vnQFWY6AruqXyeYTIonkIkd/O3IWW+pQCPc0 iuPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="XFhha/N/"; 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 xg12-20020a170907320c00b007ae100a7255si15331892ejb.709.2022.11.23.06.51.32; Wed, 23 Nov 2022 06:51: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="XFhha/N/"; 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 S236142AbiKWOs5 (ORCPT + 99 others); Wed, 23 Nov 2022 09:48:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236447AbiKWOsz (ORCPT ); Wed, 23 Nov 2022 09:48:55 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 146626DCD3; Wed, 23 Nov 2022 06:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669214934; x=1700750934; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pgt4N39lUyQv8Pv+snAd9Kisc2GhpoYqnvOX9T/Og/g=; b=XFhha/N/4Phk105vFiRUe2SNqGNuMxCLetT2tDEKEMTkyE1a7ER5UqDl 3gmp6E+tmY9yN8SYnXuYVgZZ+GyJgbh2aO4KfJSmiPo2w+xe1FEuaduvQ CtNyDaXg4PWIxR882WxOL4tr1Rb+fma6gI0S2t/kFrkAn2sN/VqVBbcLL BB5qzvKM0A4GebLSAIZSXsBxWI7WOsiUzkEwYWvd25XMxvg6m8b6fNsle aMp1miY13ktIr739llA+Tx+F0l7WWk7obCTM9c2dOad8ng6Gk0yCqQvJp gUOxfjdqN7+aRjvLYj7/xP41ztYwPedAZeHlo2P0KW+OkWvu8ANtVMr78 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="315231755" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="315231755" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 06:48:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="970883660" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="970883660" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 23 Nov 2022 06:48:37 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B03FC24A; Wed, 23 Nov 2022 16:49:03 +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 v4 4/4] xhci: Convert to use list_count() Date: Wed, 23 Nov 2022 16:49:01 +0200 Message-Id: <20221123144901.40493-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221123144901.40493-1-andriy.shevchenko@linux.intel.com> References: <20221123144901.40493-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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?1750298909904179872?= X-GMAIL-MSGID: =?utf-8?q?1750298909904179872?= The list API now provides the list_count() to help with counting existing nodes in the list. Utilise it. Signed-off-by: Andy Shevchenko Acked-by: Mathias Nyman --- v4: added tag (Mathias) v3: no change v2: no change drivers/usb/host/xhci-ring.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index ad81e9a508b1..817c31e3b0c8 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2532,7 +2532,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, union xhci_trb *ep_trb; int status = -EINPROGRESS; struct xhci_ep_ctx *ep_ctx; - struct list_head *tmp; u32 trb_comp_code; int td_num = 0; bool handling_skipped_tds = false; @@ -2580,10 +2579,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, } /* Count current td numbers if ep->skip is set */ - if (ep->skip) { - list_for_each(tmp, &ep_ring->td_list) - td_num++; - } + if (ep->skip) + td_num += list_count(&ep_ring->td_list); /* Look for common error cases */ switch (trb_comp_code) {