1 #ifndef LINUX_26_39_COMPAT_H
2 #define LINUX_26_39_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
10 #include <linux/kernel.h>
11 #include <linux/netdevice.h>
13 #define tiocmget(tty) tiocmget(tty, NULL)
14 #define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear)
16 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
17 extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
18 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */
20 static inline int netif_is_bond_slave(struct net_device *dev)
22 return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;
25 #ifndef CONFIG_COMPAT_RHEL_6_4
26 static inline int irq_set_irq_wake(unsigned int irq, unsigned int on)
28 return set_irq_wake(irq, on);
30 static inline int irq_set_chip(unsigned int irq, struct irq_chip *chip)
32 return set_irq_chip(irq, chip);
34 static inline int irq_set_handler_data(unsigned int irq, void *data)
36 return set_irq_data(irq, data);
38 static inline int irq_set_chip_data(unsigned int irq, void *data)
40 return set_irq_chip_data(irq, data);
42 static inline int irq_set_irq_type(unsigned int irq, unsigned int type)
44 return set_irq_type(irq, type);
46 #endif /* CONFIG_COMPAT_RHEL_6_4 */
48 static inline int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
50 return set_irq_msi(irq, entry);
52 static inline struct irq_chip *irq_get_chip(unsigned int irq)
54 return get_irq_chip(irq);
56 static inline void *irq_get_chip_data(unsigned int irq)
58 return get_irq_chip_data(irq);
60 static inline void *irq_get_handler_data(unsigned int irq)
62 return get_irq_data(irq);
65 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
66 static inline void *irq_data_get_irq_handler_data(struct irq_data *d)
68 return irq_data_get_irq_data(d);
72 static inline struct msi_desc *irq_get_msi_desc(unsigned int irq)
74 return get_irq_msi(irq);
77 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
78 static inline void irq_set_noprobe(unsigned int irq)
82 static inline void irq_set_probe(unsigned int irq)
88 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
89 static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
91 return get_irq_desc_chip(desc);
93 static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
95 return get_irq_desc_data(desc);
98 static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
100 return get_irq_desc_chip_data(desc);
103 static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
105 return get_irq_desc_msi(desc);
107 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) */
109 #ifndef CONFIG_COMPAT_RHEL_6_4
111 * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the
112 * version included in compat-wireless. We use strict_strtol to check if
113 * kstrto* is already available.
115 #ifndef strict_strtol
116 /* Internal, do not use. */
117 int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res);
118 int __must_check _kstrtol(const char *s, unsigned int base, long *res);
120 int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res);
121 int __must_check kstrtoll(const char *s, unsigned int base, long long *res);
122 static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
125 * We want to shortcut function call, but
126 * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0.
128 if (sizeof(unsigned long) == sizeof(unsigned long long) &&
129 __alignof__(unsigned long) == __alignof__(unsigned long long))
130 return kstrtoull(s, base, (unsigned long long *)res);
132 return _kstrtoul(s, base, res);
135 static inline int __must_check kstrtol(const char *s, unsigned int base, long *res)
138 * We want to shortcut function call, but
139 * __builtin_types_compatible_p(long, long long) = 0.
141 if (sizeof(long) == sizeof(long long) &&
142 __alignof__(long) == __alignof__(long long))
143 return kstrtoll(s, base, (long long *)res);
145 return _kstrtol(s, base, res);
148 int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res);
149 int __must_check kstrtoint(const char *s, unsigned int base, int *res);
151 static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res)
153 return kstrtoull(s, base, res);
156 static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res)
158 return kstrtoll(s, base, res);
161 static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res)
163 return kstrtouint(s, base, res);
166 static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res)
168 return kstrtoint(s, base, res);
171 int __must_check kstrtou16(const char *s, unsigned int base, u16 *res);
172 int __must_check kstrtos16(const char *s, unsigned int base, s16 *res);
173 int __must_check kstrtou8(const char *s, unsigned int base, u8 *res);
174 int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);
175 #endif /* ifndef strict_strtol */
177 static inline int test_bit_le(int nr, const void *addr)
179 return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
182 static inline void __set_bit_le(int nr, void *addr)
184 __set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
187 static inline void __clear_bit_le(int nr, void *addr)
189 __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
191 #endif /* CONFIG_COMPAT_RHEL_6_4 */
193 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */
195 #endif /* LINUX_26_39_COMPAT_H */