Skip to content
Snippets Groups Projects
Commit c809b3b6 authored by Sughosh Ganu's avatar Sughosh Ganu Committed by Heinrich Schuchardt
Browse files

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: default avatarSughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt's avatarHeinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
parent 48940c64
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment