diff options
| author | Mark Brown <broonie@kernel.org> | 2025-10-13 15:32:13 +0300 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2025-10-13 15:32:13 +0300 |
| commit | 4f38da1f027ea2c9f01bb71daa7a299c191b6940 (patch) | |
| tree | 701d1096f1a3df53ecf2a0231d2ed9a868c9b4b3 /include/linux/list.h | |
| parent | 18a5f1af596e6ba22cd40ada449063041f3ce6d4 (diff) | |
| parent | 3a8660878839faadb4f1a6dd72c3179c1df56787 (diff) | |
| download | linux-4f38da1f027ea2c9f01bb71daa7a299c191b6940.tar.xz | |
spi: Merge up v6.18-rc1
Ensure my CI has a sensible baseline.
Diffstat (limited to 'include/linux/list.h')
| -rw-r--r-- | include/linux/list.h | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/include/linux/list.h b/include/linux/list.h index e7e28afd28f8..00ea8e5fb88b 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -20,8 +20,16 @@ * using the generic single-entry routines. */ +/** + * LIST_HEAD_INIT - initialize a &struct list_head's links to point to itself + * @name: name of the list_head + */ #define LIST_HEAD_INIT(name) { &(name), &(name) } +/** + * LIST_HEAD - definition of a &struct list_head with initialization values + * @name: name of the list_head + */ #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) @@ -637,6 +645,20 @@ static inline void list_splice_tail_init(struct list_head *list, }) /** + * list_last_entry_or_null - get the last element from a list + * @ptr: the list head to take the element from. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_head within the struct. + * + * Note that if the list is empty, it returns NULL. + */ +#define list_last_entry_or_null(ptr, type, member) ({ \ + struct list_head *head__ = (ptr); \ + struct list_head *pos__ = READ_ONCE(head__->prev); \ + pos__ != head__ ? list_entry(pos__, type, member) : NULL; \ +}) + +/** * list_next_entry - get the next element in list * @pos: the type * to cursor * @member: the name of the list_head within the struct. @@ -687,16 +709,6 @@ static inline void list_splice_tail_init(struct list_head *list, for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) /** - * list_for_each_rcu - Iterate over a list in an RCU-safe fashion - * @pos: the &struct list_head to use as a loop cursor. - * @head: the head for your list. - */ -#define list_for_each_rcu(pos, head) \ - for (pos = rcu_dereference((head)->next); \ - !list_is_head(pos, (head)); \ - pos = rcu_dereference(pos->next)) - -/** * list_for_each_continue - continue iteration over a list * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list. |
