Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7008319rdb; Wed, 3 Jan 2024 01:03:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtIlteHdlhYZz8709yGAANwYu1YNcirE3bG20FaquMLv5aWSV1n6lH/mFUdUzlmY1BctI8 X-Received: by 2002:a05:622a:590:b0:425:4043:8d55 with SMTP id c16-20020a05622a059000b0042540438d55mr17380168qtb.112.1704272587069; Wed, 03 Jan 2024 01:03:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704272587; cv=none; d=google.com; s=arc-20160816; b=Avcxn/ff6bqzPJYIs9enihatE5pZyB+Q18KKBQJdc/Xan71HKsmHI+bq1w1kJ8a6VU sEZV6s8Eo5qmXAX4R5jFngccdgzCoFDCouso+nRuhWnpx1wtvxpEHG97vOObngilKHQN grg4vaprllf3aeNaliuZsnU+++HskgQyFOcmas9aW2yw8LIOtSziIptLNYsxKPddL9fb P0CxikFULDTROC8p211PpzjaKzY4Yezu/GUlnavf/Qc+Ys5h6eQoehzevUYuMCAvjRll 6vmRf+4RhKql/eke3PKZTrDCWZGPscP7vYHP4RA4qx6pPcqR9N3Wa/X+L+2mxvJiiwja mvzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=+zJD+pmcDLNgDoMTbJTKA3R+P8xsbJwkatlPFtJv6qA=; fh=uMDrzdvnRk0iXu8ZlCRidVYVyOIokmil/CLnDgKVER0=; b=i6V/2ZjiO5ugvuP+z8VYtt5Sh7e94eTLMUnILLxeJ1KNDnAchk6nvF85vPuGa75Lcw reQg0Iml9qv4FbKQA+QwUmRI1RmSuX0W9hUrW2xqSbFyNkZIhbzeCl30/HhruJOUsFJo DMspYf2nBMS2a6PuxyiDoVBhBiCJKnISpk8jgxutPHrUeZd9HhBKAgR0wEcNtSFP/Ndn m0Spa+guqwZPte+jiJcYcqhDIhHrmCFPPE5asZFb9YGLcxREdO6XU5RxfdIxsM6JWjQg RCo/6LRJvqtwAf0MaSdb8HIQiWaOYMg0jc3NAI7tLIPHogRPOl2boaJD7B4ZuRxTUVsm iuqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l20-20020a05622a175400b004281486a775si8376820qtk.215.2024.01.03.01.03.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 01:03:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D1FDF1C22FF1 for ; Wed, 3 Jan 2024 09:03:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7FA1182BD; Wed, 3 Jan 2024 09:02:58 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6617D182A9 for ; Wed, 3 Jan 2024 09:02:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 91A63C15; Wed, 3 Jan 2024 01:03:41 -0800 (PST) Received: from e126645.nice.arm.com (e126645.nice.arm.com [10.34.100.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 58FC83F7A6; Wed, 3 Jan 2024 01:02:54 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Pierre Gondois , Marco Elver , Kees Cook , Lucas De Marchi , Jani Nikula , Andy Shevchenko , Ingo Molnar Subject: [PATCH] list: Add hlist_count_nodes() Date: Wed, 3 Jan 2024 10:02:38 +0100 Message-Id: <20240103090241.164817-1-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a function to count nodes in a hlist. hlist_count_nodes() is similar to list_count_nodes(). Signed-off-by: Pierre Gondois --- include/linux/list.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index 1837caedf723..0f1b1d4a2e2e 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -1175,4 +1175,19 @@ static inline void hlist_move_list(struct hlist_head *old, pos && ({ n = pos->member.next; 1; }); \ pos = hlist_entry_safe(n, typeof(*pos), member)) +/** + * hlist_count_nodes - count nodes in the hlist + * @head: the head for your hlist. + */ +static inline size_t hlist_count_nodes(struct hlist_head *head) +{ + struct hlist_node *pos; + size_t count = 0; + + hlist_for_each(pos, head) + count++; + + return count; +} + #endif -- 2.25.1