[backfire] package/mac80211: backport list_for_each_entry_continue_rcu to fix carl1970
[openwrt-10.03/.git] / package / mac80211 / patches / 900-backport_list_for_each_entry_continue_rcu.patch
1 diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h
2 index 54ddefd..6c454cb 100644
3 --- a/include/linux/compat-2.6.31.h
4 +++ b/include/linux/compat-2.6.31.h
5 @@ -191,6 +191,17 @@ void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp)
6         cancel_work_sync(&comp->work);
7  }
8  
9 +/**
10 + * list_entry_rcu - get the struct for this entry
11 + * @ptr:        the &struct list_head pointer.
12 + * @type:       the type of the struct this is embedded in.
13 + * @member:     the name of the list_struct within the struct.
14 + *
15 + * This primitive may safely run concurrently with the _rcu list-mutation
16 + * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
17 + */
18 +#define list_entry_rcu(ptr, type, member) \
19 +       container_of(rcu_dereference(ptr), type, member)
20  
21  #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
22  
23 diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h
24 index e4dff72..e7e20d9 100644
25 --- a/include/linux/compat-2.6.33.h
26 +++ b/include/linux/compat-2.6.33.h
27 @@ -98,6 +98,20 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
28  #define kfifo_out(a, b, c) __kfifo_get(*a, b, c)
29  #define kfifo_len(a) __kfifo_len(*a)
30  
31 +/**
32 + * list_for_each_entry_continue_rcu - continue iteration over list of given type
33 + * @pos:       the type * to use as a loop cursor.
34 + * @head:      the head for your list.
35 + * @member:    the name of the list_struct within the struct.
36 + *
37 + * Continue to iterate over list of given type, continuing after
38 + * the current position.
39 + */
40 +#define list_for_each_entry_continue_rcu(pos, head, member)            \
41 +       for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
42 +            prefetch(pos->member.next), &pos->member != (head);        \
43 +            pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
44 +
45  #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
46  
47  #endif /* LINUX_26_33_COMPAT_H */