1 #ifndef LINUX_26_25_COMPAT_H
2 #define LINUX_26_25_COMPAT_H
4 #include <linux/version.h>
6 /* Compat work for 2.6.24 */
7 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
9 #include <linux/types.h>
11 #include <linux/hw_random.h>
12 #include <linux/leds.h>
13 #include <linux/kernel.h>
14 #include <linux/netdevice.h>
16 #include <asm-generic/bug.h>
17 #include <linux/pm_qos_params.h>
18 #include <linux/pci.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/pci.h>
24 /* Backports b718989da7 */
25 #define pci_enable_device_mem LINUX_BACKPORT(pci_enable_device_mem)
26 int __must_check pci_enable_device_mem(struct pci_dev *dev);
29 * Backports 312b1485fb509c9bc32eda28ad29537896658cb8
30 * Author: Sam Ravnborg <sam@ravnborg.org>
31 * Date: Mon Jan 28 20:21:15 2008 +0100
33 * Introduce new section reference annotations tags: __ref, __refdata, __refconst
35 #define __ref __init_refok
36 #define __refdata __initdata_refok
39 * backports 2658fa803111dae1353602e7f586de8e537803e2
42 static inline bool ipv4_is_loopback(__be32 addr)
44 return (addr & htonl(0xff000000)) == htonl(0x7f000000);
47 static inline bool ipv4_is_multicast(__be32 addr)
49 return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
52 static inline bool ipv4_is_local_multicast(__be32 addr)
54 return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
57 static inline bool ipv4_is_lbcast(__be32 addr)
59 /* limited broadcast */
60 return addr == htonl(INADDR_BROADCAST);
63 static inline bool ipv4_is_zeronet(__be32 addr)
65 return (addr & htonl(0xff000000)) == htonl(0x00000000);
68 /* Special-Use IPv4 Addresses (RFC3330) */
70 static inline bool ipv4_is_private_10(__be32 addr)
72 return (addr & htonl(0xff000000)) == htonl(0x0a000000);
75 static inline bool ipv4_is_private_172(__be32 addr)
77 return (addr & htonl(0xfff00000)) == htonl(0xac100000);
80 static inline bool ipv4_is_private_192(__be32 addr)
82 return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
85 static inline bool ipv4_is_linklocal_169(__be32 addr)
87 return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
90 static inline bool ipv4_is_anycast_6to4(__be32 addr)
92 return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
95 static inline bool ipv4_is_test_192(__be32 addr)
97 return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
100 static inline bool ipv4_is_test_198(__be32 addr)
102 return (addr & htonl(0xfffe0000)) == htonl(0xc6120000);
106 * phys_addr_t was added as a generic arch typedef on 2.6.28,
107 * that backport is dealt with in compat-2.6.28.h
109 #if defined(CONFIG_X86) || defined(CONFIG_X86_64)
111 #if defined(CONFIG_64BIT) || defined(CONFIG_X86_PAE) || defined(CONFIG_PHYS_64BIT)
112 typedef u64 phys_addr_t;
114 typedef u32 phys_addr_t;
119 /* The macro below uses a const upstream, this differs */
122 * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
123 * @_table: device table name
125 * This macro is used to create a struct pci_device_id array (a device table)
126 * in a generic manner.
128 #define DEFINE_PCI_DEVICE_TABLE(_table) \
129 const struct pci_device_id _table[] __devinitdata
132 * Backport work for QoS dependencies (kernel/pm_qos_params.c)
133 * pm-qos stuff written by mark gross mgross@linux.intel.com.
135 * ipw2100 now makes use of:
137 * pm_qos_add_requirement(),
138 * pm_qos_update_requirement() and
139 * pm_qos_remove_requirement() from it
141 * mac80211 uses the network latency to determine if to enable or not
142 * dynamic PS. mac80211 also and registers a notifier for when
143 * the latency changes. Since older kernels do no thave pm-qos stuff
144 * we just implement it completley here and register it upon cfg80211
145 * init. I haven't tested ipw2100 on 2.6.24 though.
147 * This pm-qos implementation is copied verbatim from the kernel
148 * written by mark gross mgross@linux.intel.com. You don't have
149 * to do anythinig to use pm-qos except use the same exported
150 * routines as used in newer kernels. The backport_pm_qos_power_init()
151 * defned below is used by the compat module to initialize pm-qos.
153 int backport_pm_qos_power_init(void);
154 int backport_pm_qos_power_deinit(void);
157 * 2.6.25 adds PM_EVENT_HIBERNATE as well here but
158 * we don't have this on <= 2.6.23)
160 #ifndef PM_EVENT_SLEEP /* some distribution have mucked with their own headers to add this.. */
161 #define PM_EVENT_SLEEP (PM_EVENT_SUSPEND)
164 /* Although we don't care about wimax this is needed for rfkill input stuff */
165 #define KEY_WIMAX 246
167 /* Although pm_qos stuff is not implemented on <= 2.6.24 lets keep the define */
168 #define PM_QOS_DEFAULT_VALUE -1
170 #define __WARN(foo) dump_stack()
172 #define dev_emerg(dev, format, arg...) \
173 dev_printk(KERN_EMERG , dev , format , ## arg)
174 #define dev_alert(dev, format, arg...) \
175 dev_printk(KERN_ALERT , dev , format , ## arg)
176 #define dev_crit(dev, format, arg...) \
177 dev_printk(KERN_CRIT , dev , format , ## arg)
179 #define __dev_addr_sync LINUX_BACKPORT(__dev_addr_sync)
180 extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
181 #define __dev_addr_unsync LINUX_BACKPORT(__dev_addr_unsync)
182 extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
184 #define seq_file_net &init_net;
187 NF_INET_PRE_ROUTING = 0,
188 NF_INET_LOCAL_IN = 1,
190 NF_INET_LOCAL_OUT = 3,
191 NF_INET_POST_ROUTING = 4,
196 * commit 8b5f6883683c91ad7e1af32b7ceeb604d68e2865
197 * Author: Marcin Slusarz <marcin.slusarz@gmail.com>
198 * Date: Fri Feb 8 04:20:12 2008 -0800
200 * byteorder: move le32_add_cpu & friends from OCFS2 to core
202 * moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core
203 * header (1st) and converted some existing code to it. We port
204 * it here as later kernels will most likely use it.
206 static inline void le16_add_cpu(__le16 *var, u16 val)
208 *var = cpu_to_le16(le16_to_cpu(*var) + val);
211 static inline void le32_add_cpu(__le32 *var, u32 val)
213 *var = cpu_to_le32(le32_to_cpu(*var) + val);
216 static inline void le64_add_cpu(__le64 *var, u64 val)
218 *var = cpu_to_le64(le64_to_cpu(*var) + val);
221 static inline void be16_add_cpu(__be16 *var, u16 val)
223 u16 v = be16_to_cpu(*var);
224 *var = cpu_to_be16(v + val);
227 static inline void be32_add_cpu(__be32 *var, u32 val)
229 u32 v = be32_to_cpu(*var);
230 *var = cpu_to_be32(v + val);
233 static inline void be64_add_cpu(__be64 *var, u64 val)
235 u64 v = be64_to_cpu(*var);
236 *var = cpu_to_be64(v + val);
239 /* 2.6.25 changes hwrng_unregister()'s behaviour by supporting
240 * suspend of its parent device (the misc device, which is itself the
241 * hardware random number generator). It does this by passing a parameter to
242 * unregister_miscdev() which is not supported in older kernels. The suspend
243 * parameter allows us to enable access to the device's hardware
244 * number generator during suspend. As far as wireless is concerned this means
245 * if a driver goes to suspend it you won't have the HNR available in
247 static inline void __hwrng_unregister(struct hwrng *rng, bool suspended)
249 hwrng_unregister(rng);
252 static inline void led_classdev_unregister_suspended(struct led_classdev *lcd)
254 led_classdev_unregister(lcd);
258 * The following things are out of ./include/linux/kernel.h
259 * The new iwlwifi driver is using them.
261 #define strict_strtoul LINUX_BACKPORT(strict_strtoul)
262 extern int strict_strtoul(const char *, unsigned int, unsigned long *);
263 #define strict_strtol LINUX_BACKPORT(strict_strtol)
264 extern int strict_strtol(const char *, unsigned int, long *);
268 * Kernels >= 2.6.25 have pm-qos and its initialized as part of
271 static inline int backport_pm_qos_power_init(void)
276 static inline int backport_pm_qos_power_deinit(void)
280 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */
282 #endif /* LINUX_26_25_COMPAT_H */