[Intel-gfx] [PATCH 1/9] list.h: add list_for_each_entry_safe_from_reverse

Daniel Vetter daniel.vetter at ffwll.ch
Tue May 18 23:11:43 CEST 2010


i915 needs this.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 include/linux/list.h |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/linux/list.h b/include/linux/list.h
index 8392884..21cdd99 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -544,6 +544,21 @@ static inline void list_splice_tail_init(struct list_head *list,
 	     &pos->member != (head); 					\
 	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
 
+/**
+ * list_for_each_entry_safe_from_reverse - iterate backwards over list from the current point safe against removal
+ * @pos:	the type * to use as a loop cursor.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Iterate backwards over list of given type, safe against removal
+ * of list entry.
+ */
+#define list_for_each_entry_safe_from_reverse(pos, n, head, member)		\
+	for (n = list_entry(pos->member.prev, typeof(*pos), member);	\
+	     &pos->member != (head); 					\
+	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
 /*
  * Double linked lists with a single pointer list head.
  * Mostly useful for hash tables where the two pointer list head is
-- 
1.7.1




More information about the Intel-gfx mailing list