Commit 0ad42352c01788e41a33336577fdd270d8de55bb
Committed by
Linus Torvalds
1 parent
e329113ca4
Exists in
master
and in
7 other branches
[PATCH] Add list_for_each_entry_safe_reverse()
Add list_for_each_entry_safe_reverse() to linux/list.h This is needed by unmerged cachefs and be an as-yet-unreviewed device_shutdown() fix. Signed-off-by: David Howells <dhowells@redhat.com> Cc: Patrick Mochel <mochel@digitalimplant.org> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 14 additions and 0 deletions Side-by-side Diff
include/linux/list.h
... | ... | @@ -436,6 +436,20 @@ |
436 | 436 | pos = n, n = list_entry(n->member.next, typeof(*n), member)) |
437 | 437 | |
438 | 438 | /** |
439 | + * list_for_each_entry_safe_reverse - iterate backwards over list of given type safe against | |
440 | + * removal of list entry | |
441 | + * @pos: the type * to use as a loop counter. | |
442 | + * @n: another type * to use as temporary storage | |
443 | + * @head: the head for your list. | |
444 | + * @member: the name of the list_struct within the struct. | |
445 | + */ | |
446 | +#define list_for_each_entry_safe_reverse(pos, n, head, member) \ | |
447 | + for (pos = list_entry((head)->prev, typeof(*pos), member), \ | |
448 | + n = list_entry(pos->member.prev, typeof(*pos), member); \ | |
449 | + &pos->member != (head); \ | |
450 | + pos = n, n = list_entry(n->member.prev, typeof(*n), member)) | |
451 | + | |
452 | +/** | |
439 | 453 | * list_for_each_rcu - iterate over an rcu-protected list |
440 | 454 | * @pos: the &struct list_head to use as a loop counter. |
441 | 455 | * @head: the head for your list. |