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_last_entry_or_null - get the last element from a list
391 * @member: the name of the list_head within the struct.
399 * list_next_entry - get the next element in list
401 * @member: the name of the list_head within the struct.
404 list_entry((pos)->member.next, typeof(*(pos)), member)
407 * list_prev_entry - get the prev element in list
409 * @member: the name of the list_head within the struct.
412 list_entry((pos)->member.prev, typeof(*(pos)), member)
415 * list_for_each - iterate over a list
420 for (pos = (head)->next; pos != (head); pos = pos->next)
423 * list_for_each_prev - iterate over a list backwards
428 for (pos = (head)->prev; pos != (head); pos = pos->prev)
431 * list_for_each_safe - iterate over a list safe against removal of list entry
437 for (pos = (head)->next, n = pos->next; pos != (head); \
438 pos = n, n = pos->next)
441 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
447 for (pos = (head)->prev, n = pos->prev; \
449 pos = n, n = pos->prev)
452 * list_for_each_entry - iterate over list of given type
455 * @member: the name of the list_head within the struct.
459 &pos->member != (head); \
463 * list_for_each_entry_reverse - iterate backwards over list of given type.
466 * @member: the name of the list_head within the struct.
470 &pos->member != (head); \
474 * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
477 * @member: the name of the list_head within the struct.
479 * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
485 * list_for_each_entry_continue - continue iteration over list of given type
488 * @member: the name of the list_head within the struct.
495 &pos->member != (head); \
499 * list_for_each_entry_continue_reverse - iterate backwards from the given point
502 * @member: the name of the list_head within the struct.
509 &pos->member != (head); \
513 * list_for_each_entry_from - iterate over list of given type from the current point
516 * @member: the name of the list_head within the struct.
521 for (; &pos->member != (head); \
525 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
529 * @member: the name of the list_head within the struct.
534 &pos->member != (head); \
538 * list_for_each_entry_safe_continue - continue list iteration safe against removal
542 * @member: the name of the list_head within the struct.
545 * safe against removal of list entry.
550 &pos->member != (head); \
554 * list_for_each_entry_safe_from - iterate over list from current point safe against removal
558 * @member: the name of the list_head within the struct.
561 * removal of list entry.
565 &pos->member != (head); \
569 * list_for_each_entry_safe_reverse - iterate backwards over list safe against removal
573 * @member: the name of the list_head within the struct.
576 * of list entry.
581 &pos->member != (head); \
585 * list_safe_reset_next - reset a stale list_for_each_entry_safe loop
588 * @member: the name of the list_head within the struct.
593 * and list_safe_reset_next is called after re-taking the lock and before
607 #define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } argument
608 #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
611 h->next = NULL; in INIT_HLIST_NODE()
612 h->pprev = NULL; in INIT_HLIST_NODE()
617 return !h->pprev; in hlist_unhashed()
622 return !h->first; in hlist_empty()
627 struct hlist_node *next = n->next; in __hlist_del()
628 struct hlist_node **pprev = n->pprev; in __hlist_del()
632 next->pprev = pprev; in __hlist_del()
638 n->next = LIST_POISON1; in hlist_del()
639 n->pprev = LIST_POISON2; in hlist_del()
652 struct hlist_node *first = h->first; in hlist_add_head()
653 n->next = first; in hlist_add_head()
655 first->pprev = &n->next; in hlist_add_head()
656 h->first = n; in hlist_add_head()
657 n->pprev = &h->first; in hlist_add_head()
664 n->pprev = next->pprev; in hlist_add_before()
665 n->next = next; in hlist_add_before()
666 next->pprev = &n->next; in hlist_add_before()
667 *(n->pprev) = n; in hlist_add_before()
673 n->next = prev->next; in hlist_add_behind()
674 prev->next = n; in hlist_add_behind()
675 n->pprev = &prev->next; in hlist_add_behind()
677 if (n->next) in hlist_add_behind()
678 n->next->pprev = &n->next; in hlist_add_behind()
684 n->pprev = &n->next; in hlist_add_fake()
689 return h->pprev == &h->next; in hlist_fake()
694 * reference of the first entry if it exists.
699 new->first = old->first; in hlist_move_list()
700 if (new->first) in hlist_move_list()
701 new->first->pprev = &new->first; in hlist_move_list()
702 old->first = NULL; in hlist_move_list()
708 for (pos = (head)->first; pos ; pos = pos->next)
711 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
720 * hlist_for_each_entry - iterate over list of given type
723 * @member: the name of the hlist_node within the struct.
726 for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
728 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
731 * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
733 * @member: the name of the hlist_node within the struct.
736 for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member);\
738 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
741 * hlist_for_each_entry_from - iterate over a hlist continuing from current point
743 * @member: the name of the hlist_node within the struct.
747 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
750 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
754 * @member: the name of the hlist_node within the struct.
757 for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\
758 pos && ({ n = pos->member.next; 1; }); \
762 * list_del_range - deletes range of entries from list.
771 begin->prev->next = end->next; in list_del_range()
772 end->next->prev = begin->prev; in list_del_range()
776 * list_for_each_from - iterate over a list from one of its nodes
781 for (; pos != (head); pos = pos->next)