diff options
Diffstat (limited to 'include/linux/list.h')
| -rw-r--r-- | include/linux/list.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/include/linux/list.h b/include/linux/list.h index 6a1f8df9144b..f4d8a2f12a33 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -362,22 +362,22 @@ static inline void list_splice_tail_init(struct list_head *list, list_entry((ptr)->next, type, member) /** - * list_for_each - iterate over a list - * @pos: the &struct list_head to use as a loop cursor. - * @head: the head for your list. + * list_first_entry_or_null - get the first 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_struct within the struct. + * + * Note that if the list is empty, it returns NULL. */ -#define list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) +#define list_first_entry_or_null(ptr, type, member) \ + (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) /** - * __list_for_each - iterate over a list + * list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list. - * - * This variant doesn't differ from list_for_each() any more. - * We don't do prefetching in either case. */ -#define __list_for_each(pos, head) \ +#define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) /** |
