From patchwork Wed Nov 30 13:48:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059851 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 B15C1C433FE for ; Wed, 30 Nov 2022 13:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbiK3NtO (ORCPT ); Wed, 30 Nov 2022 08:49:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbiK3NtL (ORCPT ); Wed, 30 Nov 2022 08:49:11 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81DE3218BB; Wed, 30 Nov 2022 05: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=1669816150; x=1701352150; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=EyJFPG6PhV/AwdfzlcYIAHQ0QmtsikwhVNregiJywak=; b=W6k2S1Pgs1JtmKpFI2qJvzwzACxulY1RmXNqcm0O432WGIjGJiTwpTCm 3qoKfHEdNRtiMMRQGecDTwMUvH5V5W5iamVmmwMwr5G2QW2J5g/hTe+0N My3LmaUn2/a0sLhNO0/KiyjXGYcshaYI4HMjDXdpvvXkl8sSMo2Ko9nAX q5v8u4IOJti8jGo8qwRy+7l9HT/P721xThXq5cVJVoA/9pAIetyt80oz3 1GK+tcFM/n+QzSsKWh5he2UFdDVsnF2Veob2/hksuqbUpAX5yoHpozUrg lk806IluZOfM2L4iUMP/H9+h//MOf/EAr/B6YXLDCC0yfvFQ3WQUyl1sQ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="298769783" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="298769783" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 05:48:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="676825898" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="676825898" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 30 Nov 2022 05:48:12 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 89D29179; Wed, 30 Nov 2022 15:48:39 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , 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 , Lucas De Marchi , Jani Nikula Subject: [PATCH v5 1/4] i915: Move list_count() to list.h as list_count_nodes() for broader use Date: Wed, 30 Nov 2022 15:48:35 +0200 Message-Id: <20221130134838.23805-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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. Reviewed-by: Lucas De Marchi Acked-by: Jani Nikula Signed-off-by: Andy Shevchenko --- v5: added tag (Lucas), renamed API to list_count_nodes() (LKP) 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 | 15 ++------------- include/linux/list.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c index 1f7188129cd1..370164363b0d 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c @@ -2004,17 +2004,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); @@ -2189,8 +2178,8 @@ 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", - list_count(&engine->sched_engine->hold)); + drm_printf(m, "\tOn hold?: %zu\n", + list_count_nodes(&engine->sched_engine->hold)); spin_unlock_irqrestore(&engine->sched_engine->lock, flags); drm_printf(m, "\tMMIO base: 0x%08x\n", engine->mmio_base); diff --git a/include/linux/list.h b/include/linux/list.h index 61762054b4be..f10344dbad4d 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_nodes - count nodes in the list + * @head: the head for your list. + */ +static inline size_t list_count_nodes(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 30 13:48:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059850 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 2C6CEC4332F for ; Wed, 30 Nov 2022 13:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbiK3NtM (ORCPT ); Wed, 30 Nov 2022 08:49:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbiK3NtL (ORCPT ); Wed, 30 Nov 2022 08:49:11 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25AF328726; Wed, 30 Nov 2022 05: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=1669816150; x=1701352150; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IUyB0aYfzgdGPjnanaYtbllUXw0rFzNVl+2IWpnEV3s=; b=VCpuxzyZ6hKVk0u2cGz4ZSMZJA7OYzv56wMZD7BPbtqXat/AdnTBVFgG /en3STEemBbE5qQbI7vVFP8DzDtZ86WZVCK3kFnVXDOA40hDlMzWldHvQ b11vx5wIv7CiNwk4MhQ9dfe9HiRAQ6p+LGsJGJakbtM3YvJnUAQBTN3g2 1EQI3mNC5ZWsUE5TDwB+Hmf0FWm6YooDqEy7NPWPXcLhdZNCp3zL7GQLO ZjZlWqJlq2KWqaxYwNK7WoSr6ISi3YgOWVuSwK4lorndcyKnbHTH+6Wbm 4+hJu7QD61AmCHTST/4Czz2y6pat/MeffvSKN5orIhMWagmfDElB/akC+ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="298769766" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="298769766" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 05:48:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="676825894" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="676825894" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 30 Nov 2022 05:48:12 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 984BA10E; Wed, 30 Nov 2022 15:48:39 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , 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 Subject: [PATCH v5 2/4] usb: gadget: hid: Convert to use list_count_nodes() Date: Wed, 30 Nov 2022 15:48:36 +0200 Message-Id: <20221130134838.23805-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221130134838.23805-1-andriy.shevchenko@linux.intel.com> References: <20221130134838.23805-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 provides the list_count_nodes() to help with counting existing nodes in the list. Utilise it. Signed-off-by: Andy Shevchenko --- v5: used renamed API (LKP) 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..133daf88162e 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_nodes(&hidg_func_list); if (!funcs) return -ENODEV; From patchwork Wed Nov 30 13:48:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059849 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 ED1EBC433FE for ; Wed, 30 Nov 2022 13:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230077AbiK3NtM (ORCPT ); Wed, 30 Nov 2022 08:49:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiK3NtK (ORCPT ); Wed, 30 Nov 2022 08:49:10 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA2825C67; Wed, 30 Nov 2022 05:49:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669816149; x=1701352149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HI3mIdGxpwMNpBOCxwOqAfT9zwwhndChIxh60vJ//mU=; b=Ug/JaiJ7dPdDlQVJE+lIompSA1RpmrbkKyKqQnJHrua9qN6ytONMlwJ0 KVPNX0U0uRiapcP4zVqz48iQIUgRqEkR/Kn+8vU+yGpjpMWtCHajrNqnL g3yM2E59EIjqF9P3qPhZ40Xfz+hh+Va/Vgi3mJAUug4WIRU4gzoB/YJoB +6qpEXwLTZ6bl3cSvpOW4Z2KR8Wt9/sxCX1r2mTq4pBx8QJxA0pHtxjh/ BXovfc/A6CqCbOVT/9c9XlAaQFEYZFw70lb9yHd3/z7gnd+xCEwlZv1oI VQqJmc5N9DnjPn2G+HI7zo2rnTotqCwSpeCQwLpBZ/5GAHB+BbUc9oE8Y w==; X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="298769771" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="298769771" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 05:48:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="676825895" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="676825895" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 30 Nov 2022 05:48:12 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id ABBE73B3; Wed, 30 Nov 2022 15:48:39 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , 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 Subject: [PATCH v5 3/4] usb: gadget: udc: bcm63xx: Convert to use list_count_nodes() Date: Wed, 30 Nov 2022 15:48:37 +0200 Message-Id: <20221130134838.23805-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221130134838.23805-1-andriy.shevchenko@linux.intel.com> References: <20221130134838.23805-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 provides the list_count_nodes() to help with counting existing nodes in the list. Utilise it. Signed-off-by: Andy Shevchenko --- v5: used renamed API (LKP) 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..771ba1ffce95 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_nodes(&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 30 13:48:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059848 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 CC66CC4332F for ; Wed, 30 Nov 2022 13:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbiK3NsW (ORCPT ); Wed, 30 Nov 2022 08:48:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiK3NsV (ORCPT ); Wed, 30 Nov 2022 08:48:21 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E1C5F48; Wed, 30 Nov 2022 05:48:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669816101; x=1701352101; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I2235I6+qL/ul/8hqTNNkG+zjnVNh7zDAoRuFikuV88=; b=LgvrD5zQb0ocysQASAYDCx17e3g9SqkHqFkwDP7cEfTaRxbauVpDeweM BuUmaZnXMGwRMZ1wuZOg8d1JuEx7YZ7kQkNLziPm9J1DHq0Ee9f4IWhw1 ezNwsKMAaNu48Q5XtDMFO9AxZuJZDEagTrkS6azEcIetvZKcYZmBaxp9T IvEDPFns8Yg6ZSoJwE61E3ZwLJcxAep81bFW4UFk60n6bD5yIY5Bu6j8R THcliaLzmXdcv0NK9Y+pzZnyscCf4a/O3zThNQv5vKCLB7x9ByaMNFlEW LXnk9zIgcxVM4bFfNlu/aBGLlfKCA5M96AShL5frIIwREP9C6NIrASZsQ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="317244867" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="317244867" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 05:48:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="973108894" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="973108894" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 30 Nov 2022 05:48:12 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B1E6E184; Wed, 30 Nov 2022 15:48:39 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , 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 Subject: [PATCH v5 4/4] xhci: Convert to use list_count_nodes() Date: Wed, 30 Nov 2022 15:48:38 +0200 Message-Id: <20221130134838.23805-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221130134838.23805-1-andriy.shevchenko@linux.intel.com> References: <20221130134838.23805-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 provides the list_count_nodes() to help with counting existing nodes in the list. Utilise it. Acked-by: Mathias Nyman Signed-off-by: Andy Shevchenko --- v5: used renamed API (LKP) 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 ddc30037f9ce..aa4d34efecd2 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2528,7 +2528,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; @@ -2582,10 +2581,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_nodes(&ep_ring->td_list); /* Look for common error cases */ switch (trb_comp_code) {