1 #ifndef LINUX_26_26_COMPAT_H
2 #define LINUX_26_26_COMPAT_H
4 #include <linux/autoconf.h>
5 #include <linux/version.h>
7 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
9 #include <linux/device.h>
10 #include <linux/list.h>
11 #include <linux/kernel.h>
12 #include <linux/jiffies.h>
14 #include <net/net_namespace.h>
16 /* These jiffie helpers added as of 2.6.26 */
19 * These four macros compare jiffies and 'a' for convenience.
22 /* time_is_before_jiffies(a) return true if a is before jiffies */
23 #define time_is_before_jiffies(a) time_after(jiffies, a)
25 /* time_is_after_jiffies(a) return true if a is after jiffies */
26 #define time_is_after_jiffies(a) time_before(jiffies, a)
28 /* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/
29 #define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)
31 /* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/
32 #define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)
34 /* This comes from include/linux/input.h */
35 #define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any"
36 set = radio enabled */
39 #define USHORT_MAX ((u16)(~0U))
40 #define SHORT_MAX ((s16)(USHORT_MAX>>1))
41 #define SHORT_MIN (-SHORT_MAX - 1)
43 extern int dev_set_name(struct device *dev, const char *name, ...)
44 __attribute__((format(printf, 2, 3)));
47 * clamp_t - return a value clamped to a given range using a given type
48 * @type: the type of variable to use
50 * @min: minimum allowable value
51 * @max: maximum allowable value
53 * This macro does no typechecking and uses temporary variables of type
54 * 'type' to make all the comparisons.
56 #define clamp_t(type, val, min, max) ({ \
60 __val = __val < __min ? __min: __val; \
61 __val > __max ? __max: __val; })
64 /* from include/linux/device.h */
65 /* device_create_drvdata() is new */
66 extern struct device *device_create_drvdata(struct class *cls,
67 struct device *parent,
71 __attribute__((format(printf, 5, 6)));
73 /* This is from include/linux/list.h */
76 * list_is_singular - tests whether a list has just one entry.
77 * @head: the list to test.
79 static inline int list_is_singular(const struct list_head *head)
81 return !list_empty(head) && (head->next == head->prev);
84 /* This is from include/linux/device.h, which was added as of 2.6.26 */
85 static inline const char *dev_name(struct device *dev)
87 /* will be changed into kobject_name(&dev->kobj) in the near future */
91 /* This is from include/linux/kernel.h, which was added as of 2.6.26 */
94 * clamp_val - return a value clamped to a given range using val's type
96 * @min: minimum allowable value
97 * @max: maximum allowable value
99 * This macro does no typechecking and uses temporary variables of whatever
100 * type the input argument 'val' is. This is useful when val is an unsigned
101 * type and min and max are literals that will otherwise be assigned a signed
105 #define clamp_val(val, min, max) ({ \
106 typeof(val) __val = (val); \
107 typeof(val) __min = (min); \
108 typeof(val) __max = (max); \
109 __val = __val < __min ? __min: __val; \
110 __val > __max ? __max: __val; })
112 /* This comes from include/net/net_namespace.h */
116 int net_eq(const struct net *net1, const struct net *net2)
122 int net_eq(const struct net *net1, const struct net *net2)
129 void dev_net_set(struct net_device *dev, struct net *net)
132 release_net(dev->nd_net);
133 dev->nd_net = hold_net(net);
138 struct net *sock_net(const struct sock *sk)
147 /* This comes from include/linux/netdevice.h */
150 * Net namespace inlines
153 struct net *dev_net(const struct net_device *dev)
157 * compat-wirelss backport note:
158 * For older kernels we may just need to always return init_net,
159 * not sure when we added dev->nd_net.
169 * 2.6.26 added its own unaligned API which the
170 * new drivers can use. Lets port it here by including it in older
171 * kernels and also deal with the architecture handling here.
176 #include <linux/unaligned/be_struct.h>
177 #include <linux/unaligned/le_byteshift.h>
178 #include <linux/unaligned/generic.h>
184 #include <linux/unaligned/le_byteshift.h>
185 #include <linux/unaligned/be_byteshift.h>
186 #include <linux/unaligned/generic.h>
192 * AVR32 can handle some unaligned accesses, depending on the
193 * implementation. The AVR32 AP implementation can handle unaligned
194 * words, but halfwords must be halfword-aligned, and doublewords must
197 * However, swapped word loads must be word-aligned so we can't
198 * optimize word loads in general.
201 #include <linux/unaligned/be_struct.h>
202 #include <linux/unaligned/le_byteshift.h>
203 #include <linux/unaligned/generic.h>
206 #ifdef CONFIG_BLACKFIN
208 #include <linux/unaligned/le_struct.h>
209 #include <linux/unaligned/be_byteshift.h>
210 #include <linux/unaligned/generic.h>
212 #endif /* blackfin */
216 * CRIS can do unaligned accesses itself.
218 #include <linux/unaligned/access_ok.h>
219 #include <linux/unaligned/generic.h>
224 #include <linux/unaligned/le_byteshift.h>
225 #include <linux/unaligned/be_byteshift.h>
226 #include <linux/unaligned/generic.h>
231 #include <linux/unaligned/be_memmove.h>
232 #include <linux/unaligned/le_byteshift.h>
233 #include <linux/unaligned/generic.h>
238 #include <linux/unaligned/le_struct.h>
239 #include <linux/unaligned/be_byteshift.h>
240 #include <linux/unaligned/generic.h>
245 #if defined(__LITTLE_ENDIAN__)
246 # include <linux/unaligned/le_memmove.h>
247 # include <linux/unaligned/be_byteshift.h>
248 # include <linux/unaligned/generic.h>
250 # include <linux/unaligned/be_memmove.h>
251 # include <linux/unaligned/le_byteshift.h>
252 # include <linux/unaligned/generic.h>
256 #ifdef CONFIG_M68K /* this handles both m68k and m68knommu */
258 #ifdef CONFIG_COLDFIRE
259 #include <linux/unaligned/be_struct.h>
260 #include <linux/unaligned/le_byteshift.h>
261 #include <linux/unaligned/generic.h>
265 * The m68k can do unaligned accesses itself.
267 #include <linux/unaligned/access_ok.h>
268 #include <linux/unaligned/generic.h>
271 #endif /* m68k and m68knommu */
274 #if defined(__MIPSEB__)
275 # include <linux/unaligned/be_struct.h>
276 # include <linux/unaligned/le_byteshift.h>
277 # include <linux/unaligned/generic.h>
278 # define get_unaligned __get_unaligned_be
279 # define put_unaligned __put_unaligned_be
280 #elif defined(__MIPSEL__)
281 # include <linux/unaligned/le_struct.h>
282 # include <linux/unaligned/be_byteshift.h>
283 # include <linux/unaligned/generic.h>
287 #ifdef CONFIG_MN10300
289 #include <linux/unaligned/access_ok.h>
290 #include <linux/unaligned/generic.h>
295 #include <linux/unaligned/be_struct.h>
296 #include <linux/unaligned/le_byteshift.h>
297 #include <linux/unaligned/generic.h>
302 * The PowerPC can do unaligned accesses itself in big endian mode.
304 #include <linux/unaligned/access_ok.h>
305 #include <linux/unaligned/generic.h>
311 * The S390 can do unaligned accesses itself.
313 #include <linux/unaligned/access_ok.h>
314 #include <linux/unaligned/generic.h>
319 /* SH can't handle unaligned accesses. */
320 #ifdef __LITTLE_ENDIAN__
321 # include <linux/unaligned/le_struct.h>
322 # include <linux/unaligned/be_byteshift.h>
323 # include <linux/unaligned/generic.h>
325 # include <linux/unaligned/be_struct.h>
326 # include <linux/unaligned/le_byteshift.h>
327 # include <linux/unaligned/generic.h>
330 #endif /* sh - SUPERH */
333 /* sparc and sparc64 */
334 #include <linux/unaligned/be_struct.h>
335 #include <linux/unaligned/le_byteshift.h>
336 #include <linux/unaligned/generic.h>
341 #include "asm/arch/unaligned.h"
343 #endif /* um - uml */
346 #include <linux/unaligned/be_byteshift.h>
347 #include <linux/unaligned/le_byteshift.h>
348 #include <linux/unaligned/generic.h>
353 * The x86 can do unaligned accesses itself.
355 #include <linux/unaligned/access_ok.h>
356 #include <linux/unaligned/generic.h>
362 # include <linux/unaligned/le_memmove.h>
363 # include <linux/unaligned/be_byteshift.h>
364 # include <linux/unaligned/generic.h>
365 #elif defined(__XTENSA_EB__)
366 # include <linux/unaligned/be_memmove.h>
367 # include <linux/unaligned/le_byteshift.h>
368 # include <linux/unaligned/generic.h>
370 # error processor byte order undefined!
375 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */
377 #endif /* LINUX_26_26_COMPAT_H */