mac80211: backport required changes to support 3.9-rc kernels
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 040-linux_3_9_compat.patch
1 --- a/include/linux/compat-2.6.h
2 +++ b/include/linux/compat-2.6.h
3 @@ -69,6 +69,7 @@ void compat_dependency_symbol(void);
4 #include <linux/compat-3.6.h>
5 #include <linux/compat-3.7.h>
6 #include <linux/compat-3.8.h>
7 +#include <linux/compat-3.9.h>
8
9 #endif /* __ASSEMBLY__ */
10
11 --- /dev/null
12 +++ b/include/linux/compat-3.9.h
13 @@ -0,0 +1,140 @@
14 +#ifndef LINUX_3_9_COMPAT_H
15 +#define LINUX_3_9_COMPAT_H
16 +
17 +#include <linux/version.h>
18 +
19 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
20 +
21 +#include <linux/idr.h>
22 +#include <linux/list.h>
23 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
24 +#include <linux/rculist.h>
25 +#endif
26 +#include <net/sock.h>
27 +#include <linux/tty.h>
28 +#include <linux/tty_flip.h>
29 +
30 +/* include this before changing hlist_for_each_* to use the old versions. */
31 +#include <net/sch_generic.h>
32 +
33 +
34 +/**
35 + * backport of idr idr_alloc() usage
36 + *
37 + * This backports a patch series send by Tejun Heo:
38 + * https://lkml.org/lkml/2013/2/2/159
39 + */
40 +static inline void compat_idr_destroy(struct idr *idp)
41 +{
42 + idr_remove_all(idp);
43 + idr_destroy(idp);
44 +}
45 +#define idr_destroy(idp) compat_idr_destroy(idp)
46 +
47 +static inline int idr_alloc(struct idr *idr, void *ptr, int start, int end,
48 + gfp_t gfp_mask)
49 +{
50 + int id, ret;
51 +
52 + do {
53 + if (!idr_pre_get(idr, gfp_mask))
54 + return -ENOMEM;
55 + ret = idr_get_new_above(idr, ptr, start, &id);
56 + if (!ret && id > end) {
57 + idr_remove(idr, id);
58 + ret = -ENOSPC;
59 + }
60 + } while (ret == -EAGAIN);
61 +
62 + return ret ? ret : id;
63 +}
64 +
65 +static inline void idr_preload(gfp_t gfp_mask)
66 +{
67 +}
68 +
69 +static inline void idr_preload_end(void)
70 +{
71 +}
72 +
73 +
74 +/**
75 + * backport:
76 + *
77 + * commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9
78 + * Author: Sasha Levin <sasha.levin@oracle.com>
79 + * Date: Thu Feb 7 12:32:18 2013 +1100
80 + *
81 + * hlist: drop the node parameter from iterators
82 + */
83 +
84 +#define hlist_entry_safe(ptr, type, member) \
85 + (ptr) ? hlist_entry(ptr, type, member) : NULL
86 +
87 +#undef hlist_for_each_entry
88 +/**
89 + * hlist_for_each_entry - iterate over list of given type
90 + * @pos: the type * to use as a loop cursor.
91 + * @head: the head for your list.
92 + * @member: the name of the hlist_node within the struct.
93 + */
94 +#define hlist_for_each_entry(pos, head, member) \
95 + for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \
96 + pos; \
97 + pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
98 +
99 +#undef hlist_for_each_entry_safe
100 +/**
101 + * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
102 + * @pos: the type * to use as a loop cursor.
103 + * @n: another &struct hlist_node to use as temporary storage
104 + * @head: the head for your list.
105 + * @member: the name of the hlist_node within the struct.
106 + */
107 +#define hlist_for_each_entry_safe(pos, n, head, member) \
108 + for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \
109 + pos && ({ n = pos->member.next; 1; }); \
110 + pos = hlist_entry_safe(n, typeof(*pos), member))
111 +
112 +#undef hlist_for_each_entry_rcu
113 +/**
114 + * hlist_for_each_entry_rcu - iterate over rcu list of given type
115 + * @pos: the type * to use as a loop cursor.
116 + * @head: the head for your list.
117 + * @member: the name of the hlist_node within the struct.
118 + *
119 + * This list-traversal primitive may safely run concurrently with
120 + * the _rcu list-mutation primitives such as hlist_add_head_rcu()
121 + * as long as the traversal is guarded by rcu_read_lock().
122 + */
123 +#define hlist_for_each_entry_rcu(pos, head, member) \
124 + for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\
125 + typeof(*(pos)), member); \
126 + pos; \
127 + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
128 + &(pos)->member)), typeof(*(pos)), member))
129 +
130 +#undef sk_for_each
131 +#define sk_for_each(__sk, list) \
132 + hlist_for_each_entry(__sk, list, sk_node)
133 +
134 +#define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty)
135 +#define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size)
136 +
137 +/**
138 + * backport of:
139 + *
140 + * commit 496ad9aa8ef448058e36ca7a787c61f2e63f0f54
141 + * Author: Al Viro <viro@zeniv.linux.org.uk>
142 + * Date: Wed Jan 23 17:07:38 2013 -0500
143 + *
144 + * new helper: file_inode(file)
145 + */
146 +static inline struct inode *file_inode(struct file *f)
147 +{
148 + return f->f_path.dentry->d_inode;
149 +}
150 +
151 +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */
152 +
153 +#endif /* LINUX_3_9_COMPAT_H */