From patchwork Tue Nov 22 15:35:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 24436 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2283127wrr; Tue, 22 Nov 2022 07:38:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf7BkQ4g0gQ3Ulc5volrX7QbXyUvr87JsW9Wo2CJMDXtrbBcmIGPpOc4GrAue7F/WGgdIw5G X-Received: by 2002:a17:906:19d7:b0:7b2:b782:e1df with SMTP id h23-20020a17090619d700b007b2b782e1dfmr16126814ejd.308.1669131520410; Tue, 22 Nov 2022 07:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669131520; cv=none; d=google.com; s=arc-20160816; b=H/7/r8GU1QpQ5GRpAFy2WkXsXik0OEroMOXb91vUGPExe6X4+K6NNZScM4fvXhTzXu qbCQ1nBwGUibgHWmCWZhyzLQiTcbDfBbtuQCeYEYnL72zOdD2DIiKm0yiVa7rEu4vJWd 6vaIptyNw7VyWIX4uwot9/sit7vsQCa0YD3Gw8xEFBsImcq+A6KU9y3ZxyQZ2/YXQHRt Ij+u2AvTCbe2NOtX3XG3zeAV0bGqtaiSfh/Gb4LnqFIeyiL0RS22qEL/4jd6VaMBAGaE n9O7/2aS8WGQNW3BDhGmIodVXXFvzsvTNN+YsbJ0ctf4VDR4BSe8i3Afrxwx6Xzdw+fY RtPw== 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=1Qtx7ZlRqQzibs+Sjim2+WzP1E23CpTGh86NOik24JI=; b=N2AeY5bmdVgl+f8hAvcbvOH1dqlAeVmRM0kjUBO9OgG5z9PuYCKJ115Ad9PBX9AQ8t vdn0878DCrVsDdly42eEzP5xSxCwkghUEcL9a/MkR7/+x74935dVCmZ/ABF1AMVy8qWZ BjxiFKKaDwMXiTBubTKtuvmiSk8kGOA7+1FoyA1bIaPPV6Aw9CirkSs7pM7Wa7tGPphH BWdm6f+M1mZGVuttIzbe61dNEw7u4+NvaYNf5wEDRBytv4GBBBQQ3TMXkSs1NV+sgpjY VzQbktF56/pg/r8rCXguR9g7RSTAmmCiAQpDh5ubjbUS2Z0f125LJ0XdvOGKUhMNllg8 9yMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mC07Z9IL; 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 ds6-20020a0564021cc600b0045c26f0050esi11974208edb.238.2022.11.22.07.38.16; Tue, 22 Nov 2022 07:38:40 -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=mC07Z9IL; 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 S232763AbiKVPfZ (ORCPT + 99 others); Tue, 22 Nov 2022 10:35:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbiKVPfP (ORCPT ); Tue, 22 Nov 2022 10:35:15 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27620682B7; 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:mime-version: content-transfer-encoding; bh=Lk7Aa8ZXFKY55rSbLTJ7BLbpsyJEXtHLhmH5NxdPyRU=; b=mC07Z9ILSsILE0OlTdG+lBfblmmeYu5gBo/4SHNITVYWO/TrUvIxOQAc h9x95sEG+FIb7k/EThUmyQ+KAlLPcmHUeQoOgGDbGfMZF8l4npn8ecCpV 4I/hVw8Yp63v6XN2niZ3Zp56OsjuaqnL1KoUm/pQimqdxbKGrQT2me0yS /GeQA152JcCrSG0/f0hwVPTFIaabgMacbTQKTK2I9bXCtJzzVp4SsOjTd wlvK8O8mBuo87PI0ZWX1hsAo+2UvUT5NaebahCvTmSusGZrKfhFOJPu/k +YrMv1mLQ/Z8pacPBCkxoPjXOLrjgmIoqtjaerf6wvYTYWcKLkYAdfzLT A==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="315662399" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="315662399" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) 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="730435563" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="730435563" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 22 Nov 2022 07:35:00 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4560E128; 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 , Jani Nikula Subject: [PATCH v3 1/4] i915: Move list_count() to list.h for broader use Date: Tue, 22 Nov 2022 17:35:13 +0200 Message-Id: <20221122153516.52577-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?1750211253140519629?= X-GMAIL-MSGID: =?utf-8?q?1750211253140519629?= 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 --- 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 6ae8b07cfaa1..b5d474be564d 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c @@ -2085,17 +2085,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); @@ -2270,7 +2259,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..65aab596ae33 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. + */ +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 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; From patchwork Tue Nov 22 15:35:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 24435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2283105wrr; Tue, 22 Nov 2022 07:38:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf4H+nqaEurTb7MqkhIx6yVCa8fo+oLRkUjL0UdCuaaLa1iicJgUYbXqbWX5Q17fZ+QraTy3 X-Received: by 2002:a05:6402:2409:b0:45c:935b:ae15 with SMTP id t9-20020a056402240900b0045c935bae15mr21289984eda.357.1669131517079; Tue, 22 Nov 2022 07:38:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669131517; cv=none; d=google.com; s=arc-20160816; b=K/tta2ZzGKqT82vG06ZgmRWxketnqklwR4Hlj2Iw311DNgfkmFD9oplbsNAtprjnZW oRV4o91OLVAOElvi9yNZ8yo7rQ1vh+nog4MyuUAyULkMUVWPfFnmbXbxA7JxC8IjfisP rz7VGzl4s95DrjgTXNYYbJSFQdMCnZTqbzwuml4qxvnna7cdfopX0BiCwTe7ZEC7CReZ IK+swffhem7j0kqyLS499ri+r7WEca08BV8a8e6TeE6phPbFtKHxAH6y9pVKGBH6ZXEL gjOhqgz4ykP55JxVL2r1LlmyjKcQ3VbaPC2943Qm4re2b5S7rbDNerWXrjb0ImUsD3lR fbKQ== 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=YQIS0gcgfBFPI2C8qqtw5XvCokGnWTUTgHpuj0usshE=; b=MLMQANmNrV02MrQxvtlXRkKrqBJpG35WfoaEunlItq193CVlitd7An6vBmeEBEXBXB fZbe1EyFTDv0oaZKyMY3EV3h9I5Kj0mfalj7+EpeWos1tc/eWNdAL4d9cn/3tFc9xlRY G7VEEG10t6mPYUfQhano7H2HiOVhvLkcHdYCoWCIqrVU8F+DuGpFwpKijLmJ4qLgvSNA AG3Y/IkMmS1tA5k+iHut4P7MAvuMj6Cj6x+6wRq3KzJtfYzDz/Km63BUKWHtSECLrm4Z eDq3fUYhIxQ3Pxkyuj61MLnQQyC2yjcyOY9fBfU6eunbyXyxvB8kZD+4tgY6OLwx1wBg KaHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=md3N+GrG; 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 gs40-20020a1709072d2800b0077b21283d09si409231ejc.349.2022.11.22.07.38.12; Tue, 22 Nov 2022 07:38:37 -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=md3N+GrG; 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 S233269AbiKVPfU (ORCPT + 99 others); Tue, 22 Nov 2022 10:35:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbiKVPfP (ORCPT ); Tue, 22 Nov 2022 10:35:15 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC39069DC3; Tue, 22 Nov 2022 07:35: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=1669131314; x=1700667314; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zu4U5AcdMvxjBbkfIRJ4d3Ua9ejTwnth+3FLNezefWw=; b=md3N+GrGvwUf6QOWLknExsDuy5ZH8A0ClL+DOWmPyuIORQhgSwNgmrDr +7ClffdZ2he0tn/dqWNPpHmtoy/FFMNNzoU2Xc6e8glQkNZfrg/D9/Pv5 13yCZkIWN2ZgcFxxF6TtDwjBkfEv2vk+hfFFVS6+aDrlQOYupJN8RTDAn r6FrM4iDo77PI792VkmP/tHELLe3o/hsh5oZ6COTIZcAUm/azEAXocdz7 fOKKYhzLQL6hDCyrAOOmUoN3/r+7RWurukdwl6909/nWev+R0adD1OekO /KU3kAhQUJJI2f4ZQobJFMWOVcXZDbW+eMSKF5NL0DEEyZwpWUi8X+L+9 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="315662394" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="315662394" 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:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="747395671" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="747395671" 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 5B37D184; 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 3/4] usb: gadget: udc: bcm63xx: Convert to use list_count() Date: Tue, 22 Nov 2022 17:35:15 +0200 Message-Id: <20221122153516.52577-3-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?1750211249886329857?= X-GMAIL-MSGID: =?utf-8?q?1750211249886329857?= 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: 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 Tue Nov 22 15:35:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 24434 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2282952wrr; Tue, 22 Nov 2022 07:38:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf7G+PcjV9618mLV1bOph+1WNhkoYf8/A8580/4MDQcDSkEH/gJLO4YrLPGH00oO6kvVxGFk X-Received: by 2002:a05:6402:14ce:b0:469:9395:beef with SMTP id f14-20020a05640214ce00b004699395beefmr9665924edx.316.1669131499756; Tue, 22 Nov 2022 07:38:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669131499; cv=none; d=google.com; s=arc-20160816; b=NcJ+akjZeU/kFPB63BUvg4U5Wcd0k84IBK1hgdnPIQrJaWyemfQoHND9uM1C365pdg epvZsapUCkNQGGJmp7h6s6UdRj7ZfyXrfZ4IgbEqtM/pUcYc08oh2Y1dSK9peVs8kWDi DwJbEqMXi9tzmtp5Kv7Us6hfy+90uGNSbwmSWF18Os2wKetMGtCAoYIvglvdpQ/Ogi4D pDwEfFLvOUFI6fYh3g+DgQfHzclbTS6F0j/FStXfbtmxco11WwsBQPckgIYQKQJZzUT7 7V1orvIHw8fwvZXcrK+geZc1Sv+/EsY6EFg+S5zMglDL5/xRnUxJZUw/Sy9eAwscSW+N PXXw== 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=F5A701C6n+FPIHNaC9Wwb0EcSRrUB1P+PDAk8BYJBzc=; b=jJTMQFQ3+nCwMiK1x0cV58i40pUmTBFgXXyZtajoezOvul0fIbdOIQmXTpg6WKPjMg s+ZtzeY+UGB3x5oVFlODo3UVofMBDxibQaqtH5cRgWCA9yZVlGQjCXAFVZ6dKf5gDl2L sLMyslHezC8qLJmiqArLWO0E1I9pdlYLdpiKExllHZgCc7e0Twd64zAAXcjRhvwWICn3 1pMRvShPvA68u6aSCysFQhM/0ODw8Ce8DlhpSy9TH4jgSEA0NATCzwOAhJsVm9fHXOJB KnlN8Jl733Uopz+Y3Df9F5fYVIKahQQONBUei35eIW+NSe/QBxFoXrYDnYItcdxSVGfB 1Ebw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=j7UA7UP+; 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 sh41-20020a1709076ea900b00781c1645926si549984ejc.524.2022.11.22.07.37.55; Tue, 22 Nov 2022 07:38: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=j7UA7UP+; 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 S233004AbiKVPfQ (ORCPT + 99 others); Tue, 22 Nov 2022 10:35:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiKVPfP (ORCPT ); Tue, 22 Nov 2022 10:35:15 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D40E2697ED; Tue, 22 Nov 2022 07:35:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669131313; x=1700667313; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QhFQ1vvgWJPcpF58xWVY2cCZqGcl+FTrvlc1UL7N3w0=; b=j7UA7UP+Q5zsxG1RqVs9XwX37ODWcb5/c1L13pUfo9vHx7XRasBmIfGM OkmuDeXJAj7QKd6wDpNDI77UGtSBbdtmcUUgqAY3F72Yl52YD26cT4T7z ta0ndf4KmJDiiE/+87r8+uzNQ7VxVqEqoZo3Ou3qdYSJf87WiXVin90md dWVBNY6CU3HExyGJEZniAAHjWqPF5mlsz/ZRcyk8JKK9YuewkU19BsI06 hZANuiFxW7t7emLcMD70ou6SjKvsG4tkdE4Lwe7iyTeq+KNT8OuZAElYn 5BZtNphUDJQslq5w9dZXEGmKag82EM/9qqYYUdVaAG/6ZvDKvQRJb01B/ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="315662392" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="315662392" 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:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="747395669" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="747395669" 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 6623724A; 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 4/4] xhci: Convert to use list_count() Date: Tue, 22 Nov 2022 17:35:16 +0200 Message-Id: <20221122153516.52577-4-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?1750211231636395877?= X-GMAIL-MSGID: =?utf-8?q?1750211231636395877?= 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 --- 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) {