Lines Matching +full:entry +full:- +full:name
1 /* SPDX-License-Identifier: GPL-2.0 */
17 * using the generic single-entry routines.
20 #define LIST_HEAD_INIT(name) { &(name), &(name) } argument
22 #define LIST_HEAD(name) \ argument
23 struct list_head name = LIST_HEAD_INIT(name)
27 list->next = list; in INIT_LIST_HEAD()
28 list->prev = list; in INIT_LIST_HEAD()
32 * Insert a new entry between two known consecutive entries.
42 next->prev = new; in __list_add()
43 new->next = next; in __list_add()
44 new->prev = prev; in __list_add()
45 prev->next = new; in __list_add()
54 * list_add - add a new entry
55 * @new: new entry to be added
58 * Insert a new entry after the specified head.
63 __list_add(new, head, head->next); in list_add()
68 * list_add_tail - add a new entry
69 * @new: new entry to be added
72 * Insert a new entry before the specified head.
77 __list_add(new, head->prev, head); in list_add_tail()
81 * Delete a list entry by making the prev/next entries
89 next->prev = prev; in __list_del()
90 WRITE_ONCE(prev->next, next); in __list_del()
94 * list_del - deletes entry from list.
95 * @entry: the element to delete from the list.
96 * Note: list_empty() on entry does not return true after this, the entry is
100 static inline void __list_del_entry(struct list_head *entry) in __list_del_entry() argument
102 __list_del(entry->prev, entry->next); in __list_del_entry()
105 static inline void list_del(struct list_head *entry) in list_del() argument
107 __list_del(entry->prev, entry->next); in list_del()
108 entry->next = LIST_POISON1; in list_del()
109 entry->prev = LIST_POISON2; in list_del()
112 extern void __list_del_entry(struct list_head *entry);
113 extern void list_del(struct list_head *entry);
117 * list_replace - replace old entry by new one
126 new->next = old->next; in list_replace()
127 new->next->prev = new; in list_replace()
128 new->prev = old->prev; in list_replace()
129 new->prev->next = new; in list_replace()
140 * list_del_init - deletes entry from list and reinitialize it.
141 * @entry: the element to delete from the list.
143 static inline void list_del_init(struct list_head *entry) in list_del_init() argument
145 __list_del_entry(entry); in list_del_init()
146 INIT_LIST_HEAD(entry); in list_del_init()
150 * list_move - delete from one list and add as another's head
151 * @list: the entry to move
152 * @head: the head that will precede our entry
161 * list_move_tail - delete from one list and add as another's tail
162 * @list: the entry to move
163 * @head: the head that will follow our entry
173 * list_is_last - tests whether @list is the last entry in list @head
174 * @list: the entry to test
180 return list->next == head; in list_is_last()
184 * list_empty - tests whether a list is empty
189 return head->next == head; in list_empty()
193 * list_empty_careful - tests whether a list is empty and not being modified
202 * to the list entry is list_del_init(). Eg. it cannot be used
203 * if another CPU could re-list_add() it.
207 struct list_head *next = head->next; in list_empty_careful()
208 return (next == head) && (next == head->prev); in list_empty_careful()
212 * list_rotate_left - rotate the list to the left
220 first = head->next; in list_rotate_left()
226 * list_is_singular - tests whether a list has just one entry.
231 return !list_empty(head) && (head->next == head->prev); in list_is_singular()
235 struct list_head *head, struct list_head *entry) in __list_cut_position() argument
237 struct list_head *new_first = entry->next; in __list_cut_position()
238 list->next = head->next; in __list_cut_position()
239 list->next->prev = list; in __list_cut_position()
240 list->prev = entry; in __list_cut_position()
241 entry->next = list; in __list_cut_position()
242 head->next = new_first; in __list_cut_position()
243 new_first->prev = head; in __list_cut_position()
247 * list_cut_position - cut a list into two
250 * @entry: an entry within head, could be the head itself
254 * including @entry, from @head to @list. You should
255 * pass on @entry an element you know is on @head. @list
261 struct list_head *head, struct list_head *entry) in list_cut_position() argument
266 (head->next != entry && head != entry)) in list_cut_position()
268 if (entry == head) in list_cut_position()
271 __list_cut_position(list, head, entry); in list_cut_position()
278 struct list_head *first = list->next; in __list_splice()
279 struct list_head *last = list->prev; in __list_splice()
281 first->prev = prev; in __list_splice()
282 prev->next = first; in __list_splice()
284 last->next = next; in __list_splice()
285 next->prev = last; in __list_splice()
289 * list_splice - join two lists, this is designed for stacks
297 __list_splice(list, head, head->next); in list_splice()
301 * list_splice_tail - join two lists, each list being a queue
309 __list_splice(list, head->prev, head); in list_splice_tail()
313 * list_splice_init - join two lists and reinitialise the emptied list.
323 __list_splice(list, head, head->next); in list_splice_init()
329 * list_splice_tail_init - join two lists and reinitialise the emptied list
340 __list_splice(list, head->prev, head); in list_splice_tail_init()
346 * list_entry - get the struct for this entry
349 * @member: the name of the list_head within the struct.
355 * list_first_entry - get the first element from a list
358 * @member: the name of the list_head within the struct.
363 list_entry((ptr)->next, type, member)
366 * list_last_entry - get the last element from a list
369 * @member: the name of the list_head within the struct.
374 list_entry((ptr)->prev, type, member)
377 * list_first_entry_or_null - get the first element from a list
380 * @member: the name of the list_head within the struct.
388 * list_next_entry - get the next element in list
390 * @member: the name of the list_head within the struct.
393 list_entry((pos)->member.next, typeof(*(pos)), member)
396 * list_prev_entry - get the prev element in list
398 * @member: the name of the list_head within the struct.
401 list_entry((pos)->member.prev, typeof(*(pos)), member)
404 * list_for_each - iterate over a list
409 for (pos = (head)->next; pos != (head); pos = pos->next)
412 * list_for_each_prev - iterate over a list backwards
417 for (pos = (head)->prev; pos != (head); pos = pos->prev)
420 * list_for_each_safe - iterate over a list safe against removal of list entry
426 for (pos = (head)->next, n = pos->next; pos != (head); \
427 pos = n, n = pos->next)
430 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
436 for (pos = (head)->prev, n = pos->prev; \
438 pos = n, n = pos->prev)
441 * list_for_each_entry - iterate over list of given type
444 * @member: the name of the list_head within the struct.
448 &pos->member != (head); \
452 * list_for_each_entry_reverse - iterate backwards over list of given type.
455 * @member: the name of the list_head within the struct.
459 &pos->member != (head); \
463 * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
466 * @member: the name of the list_head within the struct.
468 * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
474 * list_for_each_entry_continue - continue iteration over list of given type
477 * @member: the name of the list_head within the struct.
484 &pos->member != (head); \
488 * list_for_each_entry_continue_reverse - iterate backwards from the given point
491 * @member: the name of the list_head within the struct.
498 &pos->member != (head); \
502 * list_for_each_entry_from - iterate over list of given type from the current point
505 * @member: the name of the list_head within the struct.
510 for (; &pos->member != (head); \
514 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
518 * @member: the name of the list_head within the struct.
523 &pos->member != (head); \
527 * list_for_each_entry_safe_continue - continue list iteration safe against removal
531 * @member: the name of the list_head within the struct.
534 * safe against removal of list entry.
539 &pos->member != (head); \
543 * list_for_each_entry_safe_from - iterate over list from current point safe against removal
547 * @member: the name of the list_head within the struct.
550 * removal of list entry.
554 &pos->member != (head); \
558 * list_for_each_entry_safe_reverse - iterate backwards over list safe against removal
562 * @member: the name of the list_head within the struct.
565 * of list entry.
570 &pos->member != (head); \
574 * list_safe_reset_next - reset a stale list_for_each_entry_safe loop
577 * @member: the name of the list_head within the struct.
582 * and list_safe_reset_next is called after re-taking the lock and before
596 #define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } argument
597 #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
600 h->next = NULL; in INIT_HLIST_NODE()
601 h->pprev = NULL; in INIT_HLIST_NODE()
606 return !h->pprev; in hlist_unhashed()
611 return !h->first; in hlist_empty()
616 struct hlist_node *next = n->next; in __hlist_del()
617 struct hlist_node **pprev = n->pprev; in __hlist_del()
621 next->pprev = pprev; in __hlist_del()
627 n->next = LIST_POISON1; in hlist_del()
628 n->pprev = LIST_POISON2; in hlist_del()
641 struct hlist_node *first = h->first; in hlist_add_head()
642 n->next = first; in hlist_add_head()
644 first->pprev = &n->next; in hlist_add_head()
645 h->first = n; in hlist_add_head()
646 n->pprev = &h->first; in hlist_add_head()
653 n->pprev = next->pprev; in hlist_add_before()
654 n->next = next; in hlist_add_before()
655 next->pprev = &n->next; in hlist_add_before()
656 *(n->pprev) = n; in hlist_add_before()
662 n->next = prev->next; in hlist_add_behind()
663 prev->next = n; in hlist_add_behind()
664 n->pprev = &prev->next; in hlist_add_behind()
666 if (n->next) in hlist_add_behind()
667 n->next->pprev = &n->next; in hlist_add_behind()
673 n->pprev = &n->next; in hlist_add_fake()
678 return h->pprev == &h->next; in hlist_fake()
683 * reference of the first entry if it exists.
688 new->first = old->first; in hlist_move_list()
689 if (new->first) in hlist_move_list()
690 new->first->pprev = &new->first; in hlist_move_list()
691 old->first = NULL; in hlist_move_list()
697 for (pos = (head)->first; pos ; pos = pos->next)
700 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
709 * hlist_for_each_entry - iterate over list of given type
712 * @member: the name of the hlist_node within the struct.
715 for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
717 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
720 * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
722 * @member: the name of the hlist_node within the struct.
725 for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member);\
727 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
730 * hlist_for_each_entry_from - iterate over a hlist continuing from current point
732 * @member: the name of the hlist_node within the struct.
736 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
739 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
743 * @member: the name of the hlist_node within the struct.
746 for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\
747 pos && ({ n = pos->member.next; 1; }); \
751 * list_del_range - deletes range of entries from list.
760 begin->prev->next = end->next; in list_del_range()
761 end->next->prev = begin->prev; in list_del_range()
765 * list_for_each_from - iterate over a list from one of its nodes
770 for (; pos != (head); pos = pos->next)