]> git.openfabrics.org - ~emulex/tmp/compat/.git/commitdiff
compat: backport list_for_each_entry_continue_rcu
authorHauke Mehrtens <hauke@hauke-m.de>
Wed, 15 Sep 2010 20:42:33 +0000 (13:42 -0700)
committerLuis R. Rodriguez <lrodriguez@atheros.com>
Wed, 15 Sep 2010 21:58:06 +0000 (14:58 -0700)
This is needed for new driver carl9170.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
include/linux/compat-2.6.31.h
include/linux/compat-2.6.33.h

index 54ddefdcd5a407fe00de53e090a4e17e1c97f0fd..6c454cb2068925dd629c6823f3ac5d0614f8af55 100644 (file)
@@ -191,6 +191,17 @@ void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp)
        cancel_work_sync(&comp->work);
 }
 
+/**
+ * list_entry_rcu - get the struct for this entry
+ * @ptr:        the &struct list_head pointer.
+ * @type:       the type of the struct this is embedded in.
+ * @member:     the name of the list_struct within the struct.
+ *
+ * This primitive may safely run concurrently with the _rcu list-mutation
+ * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
+ */
+#define list_entry_rcu(ptr, type, member) \
+       container_of(rcu_dereference(ptr), type, member)
 
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
 
index e4dff722a82515503405a33ac6c8082533692093..e7e20d94c8712807d6e663c85cf946bd56e36761 100644 (file)
@@ -98,6 +98,20 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
 #define kfifo_out(a, b, c) __kfifo_get(*a, b, c)
 #define kfifo_len(a) __kfifo_len(*a)
 
+/**
+ * list_for_each_entry_continue_rcu - continue iteration over list of given type
+ * @pos:       the type * to use as a loop cursor.
+ * @head:      the head for your list.
+ * @member:    the name of the list_struct within the struct.
+ *
+ * Continue to iterate over list of given type, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue_rcu(pos, head, member)            \
+       for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
+            prefetch(pos->member.next), &pos->member != (head);        \
+            pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
 
 #endif /* LINUX_26_33_COMPAT_H */