Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <jiri@mellanox.com>
Acked-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jiri Pirko and committed by
David S. Miller
b862815c 8708ecf0

+13
+13
include/linux/list.h
··· 527 527 pos = list_next_entry(pos, member)) 528 528 529 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 + 542 + /** 530 543 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry 531 544 * @pos: the type * to use as a loop cursor. 532 545 * @n: another type * to use as temporary storage