Skip to content

Commit b862815

Browse files
jpirkodavem330
authored andcommitted
list: introduce list_for_each_entry_from_reverse helper
Similar to list_for_each_entry_continue and its reverse variant list_for_each_entry_continue_reverse, introduce reverse helper for list_for_each_entry_from. Signed-off-by: Jiri Pirko <[email protected]> Acked-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8708ecf commit b862815

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/linux/list.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,19 @@ static inline void list_splice_tail_init(struct list_head *list,
526526
for (; &pos->member != (head); \
527527
pos = list_next_entry(pos, member))
528528

529+
/**
530+
* list_for_each_entry_from_reverse - iterate backwards over list of given type
531+
* from the current point
532+
* @pos: the type * to use as a loop cursor.
533+
* @head: the head for your list.
534+
* @member: the name of the list_head within the struct.
535+
*
536+
* Iterate backwards over list of given type, continuing from current position.
537+
*/
538+
#define list_for_each_entry_from_reverse(pos, head, member) \
539+
for (; &pos->member != (head); \
540+
pos = list_prev_entry(pos, member))
541+
529542
/**
530543
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
531544
* @pos: the type * to use as a loop cursor.

0 commit comments

Comments
 (0)