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>
12 #define tiocmget(tty) tiocmget(tty, NULL)
13 #define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear)
15 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
16 extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
17 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */
19 static inline int irq_set_irq_wake(unsigned int irq, unsigned int on)
21 return set_irq_wake(irq, on);
23 static inline int irq_set_chip(unsigned int irq, struct irq_chip *chip)
25 return set_irq_chip(irq, chip);
27 static inline int irq_set_handler_data(unsigned int irq, void *data)
29 return set_irq_data(irq, data);
31 static inline int irq_set_chip_data(unsigned int irq, void *data)
33 return set_irq_chip_data(irq, data);
35 static inline int irq_set_irq_type(unsigned int irq, unsigned int type)
37 return set_irq_type(irq, type);
39 static inline int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
41 return set_irq_msi(irq, entry);
43 static inline struct irq_chip *irq_get_chip(unsigned int irq)
45 return get_irq_chip(irq);
47 static inline void *irq_get_chip_data(unsigned int irq)
49 return get_irq_chip_data(irq);
51 static inline void *irq_get_handler_data(unsigned int irq)
53 return get_irq_data(irq);
56 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
57 static inline void *irq_data_get_irq_handler_data(struct irq_data *d)
59 return irq_data_get_irq_data(d);
63 static inline struct msi_desc *irq_get_msi_desc(unsigned int irq)
65 return get_irq_msi(irq);
67 static inline void irq_set_noprobe(unsigned int irq)
71 static inline void irq_set_probe(unsigned int irq)
76 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
77 static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
79 return get_irq_desc_chip(desc);
81 static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
83 return get_irq_desc_data(desc);
86 static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
88 return get_irq_desc_chip_data(desc);
91 static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
93 return get_irq_desc_msi(desc);
95 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) */
98 * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the
99 * version included in compat-wireless. We use strict_strtol to check if
100 * kstrto* is already available.
102 #ifndef strict_strtol
103 /* Internal, do not use. */
104 int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res);
105 int __must_check _kstrtol(const char *s, unsigned int base, long *res);
107 int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res);
108 int __must_check kstrtoll(const char *s, unsigned int base, long long *res);
109 static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
112 * We want to shortcut function call, but
113 * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0.
115 if (sizeof(unsigned long) == sizeof(unsigned long long) &&
116 __alignof__(unsigned long) == __alignof__(unsigned long long))
117 return kstrtoull(s, base, (unsigned long long *)res);
119 return _kstrtoul(s, base, res);
122 static inline int __must_check kstrtol(const char *s, unsigned int base, long *res)
125 * We want to shortcut function call, but
126 * __builtin_types_compatible_p(long, long long) = 0.
128 if (sizeof(long) == sizeof(long long) &&
129 __alignof__(long) == __alignof__(long long))
130 return kstrtoll(s, base, (long long *)res);
132 return _kstrtol(s, base, res);
135 int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res);
136 int __must_check kstrtoint(const char *s, unsigned int base, int *res);
138 static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res)
140 return kstrtoull(s, base, res);
143 static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res)
145 return kstrtoll(s, base, res);
148 static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res)
150 return kstrtouint(s, base, res);
153 static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res)
155 return kstrtoint(s, base, res);
158 int __must_check kstrtou16(const char *s, unsigned int base, u16 *res);
159 int __must_check kstrtos16(const char *s, unsigned int base, s16 *res);
160 int __must_check kstrtou8(const char *s, unsigned int base, u8 *res);
161 int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);
162 #endif /* ifndef strict_strtol */
164 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */
166 #endif /* LINUX_26_39_COMPAT_H */