summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSughosh Ganu <sughosh.ganu@linaro.org>2024-07-30 16:41:28 +0530
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2024-07-31 09:53:01 +0200
commitc809b3b641b34125aa6345b0849c7a491bd18c96 (patch)
treec5009a6c0ea751c2ecdc4e415f8c9ee31fe51a67 /include
parent48940c6429c3f77c04b1844e0cfed2f884bf045b (diff)
downloadu-boot-c809b3b641b34125aa6345b0849c7a491bd18c96.tar.gz
u-boot-c809b3b641b34125aa6345b0849c7a491bd18c96.tar.bz2
u-boot-c809b3b641b34125aa6345b0849c7a491bd18c96.zip
linux: list: add a function to count list nodes
Add a function to count the nodes of a list. Taken from linux 6.11-rc1 tag commit 8400291e289e. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/list.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 6910721c00..0f9d939b05 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -547,6 +547,21 @@ static inline void list_splice_tail_init(struct list_head *list,
&pos->member != (head); \
pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+/**
+ * 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;
+}
+
/*
* Double linked lists with a single pointer list head.
* Mostly useful for hash tables where the two pointer list head is