Skip to content

Commit

Permalink
list: introduce list_for_each_entry_from_reverse helper
Browse files Browse the repository at this point in the history
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 <jiri@mellanox.com>
Acked-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Feb 3, 2017
1 parent 8708ecf commit b862815
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/linux/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,19 @@ static inline void list_splice_tail_init(struct list_head *list,
for (; &pos->member != (head); \
pos = list_next_entry(pos, member))

/**
* list_for_each_entry_from_reverse - iterate backwards over list of given type
* from the current point
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_head within the struct.
*
* Iterate backwards over list of given type, continuing from current position.
*/
#define list_for_each_entry_from_reverse(pos, head, member) \
for (; &pos->member != (head); \
pos = list_prev_entry(pos, member))

/**
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
* @pos: the type * to use as a loop cursor.
Expand Down

0 comments on commit b862815

Please sign in to comment.