2002-04-08 20:28:01

by John Tyner

[permalink] [raw]
Subject: [PATCH] list_del_all

--- include/linux/list.h.orig Mon Apr 8 13:10:55 2002
+++ include/linux/list.h Mon Apr 8 13:22:48 2002
@@ -170,7 +170,23 @@
#define list_for_each_prev(pos, head) \
for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \
pos = pos->prev, prefetch(pos->prev))
-
+
+/**
+ * list_del_all - delete all entries in list and call func for each entry
+ * @head: the head for your list
+ * @func: callback that should be called for each entry
+ * @type: the type of the struct this is embedded in
+ * @member: the name of the list_struct within the struct
+ */
+#define list_del_all( head, func, type, member ) \
+ do { \
+ struct list_head *curr, *next; \
+ list_for_each_safe( curr, next, head ) { \
+ type *var = list_entry( curr, type, member ); \
+ list_del( curr ); \
+ func( var ); \
+ } \
+ } while ( 0 )

#endif /* __KERNEL__ || _LVM_H_INCLUDE */