compat-wireless-2010-03-10
[pandora-wifi.git] / include / linux / compat-2.6.25.h
1 #ifndef LINUX_26_25_COMPAT_H
2 #define LINUX_26_25_COMPAT_H
3
4 #include <linux/version.h>
5
6 /* Compat work for 2.6.24 */
7 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
8
9 #include <linux/types.h>
10 #include <linux/io.h>
11 #include <linux/hw_random.h>
12 #include <linux/leds.h>
13 #include <linux/kernel.h>
14 #include <linux/netdevice.h>
15 #include <linux/pm.h>
16 #include <asm-generic/bug.h>
17 #include <linux/pm_qos_params.h>
18 #include <linux/pci.h>
19
20 /* The macro below uses a const upstream, this differs */
21
22 /**
23  * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
24  * @_table: device table name
25  *
26  * This macro is used to create a struct pci_device_id array (a device table)
27  * in a generic manner.
28  */
29 #define DEFINE_PCI_DEVICE_TABLE(_table) \
30         const struct pci_device_id _table[] __devinitdata
31
32 /*
33  * Backport work for QoS dependencies (kernel/pm_qos_params.c)
34  * pm-qos stuff written by mark gross mgross@linux.intel.com.
35  *
36  * ipw2100 now makes use of:
37  *
38  * pm_qos_add_requirement(),
39  * pm_qos_update_requirement() and
40  * pm_qos_remove_requirement() from it
41  *
42  * mac80211 uses the network latency to determine if to enable or not
43  * dynamic PS. mac80211 also and registers a notifier for when
44  * the latency changes. Since older kernels do no thave pm-qos stuff
45  * we just implement it completley here and register it upon cfg80211
46  * init. I haven't tested ipw2100 on 2.6.24 though.
47  *
48  * This pm-qos implementation is copied verbatim from the kernel
49  * written by mark gross mgross@linux.intel.com. You don't have
50  * to do anythinig to use pm-qos except use the same exported
51  * routines as used in newer kernels. The compat_pm_qos_power_init()
52  * defned below is used by the compat module to initialize pm-qos.
53  */
54 int compat_pm_qos_power_init(void);
55 int compat_pm_qos_power_deinit(void);
56
57 /*
58  * 2.6.25 adds PM_EVENT_HIBERNATE as well here but
59  * we don't have this on <= 2.6.23)
60  */
61 #define PM_EVENT_SLEEP  (PM_EVENT_SUSPEND)
62
63 /* Although we don't care about wimax this is needed for rfkill input stuff */
64 #define KEY_WIMAX               246
65
66 /* Although pm_qos stuff is not implemented on <= 2.6.24 lets keep the define */
67 #define PM_QOS_DEFAULT_VALUE -1
68
69 #define __WARN(foo) dump_stack()
70
71 #define dev_emerg(dev, format, arg...)          \
72         dev_printk(KERN_EMERG , dev , format , ## arg)
73 #define dev_alert(dev, format, arg...)          \
74         dev_printk(KERN_ALERT , dev , format , ## arg)
75 #define dev_crit(dev, format, arg...)           \
76         dev_printk(KERN_CRIT , dev , format , ## arg)
77
78 extern int              __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
79 extern void             __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
80
81 #define seq_file_net &init_net;
82
83 enum nf_inet_hooks {
84         NF_INET_PRE_ROUTING = 0,
85         NF_INET_LOCAL_IN = 1,
86         NF_INET_FORWARD = 2,
87         NF_INET_LOCAL_OUT = 3,
88         NF_INET_POST_ROUTING = 4,
89         NF_INET_NUMHOOKS = 5
90 };
91
92 /* The patch:
93  * commit 8b5f6883683c91ad7e1af32b7ceeb604d68e2865
94  * Author: Marcin Slusarz <marcin.slusarz@gmail.com>
95  * Date:   Fri Feb 8 04:20:12 2008 -0800
96  *
97  *     byteorder: move le32_add_cpu & friends from OCFS2 to core
98  *
99  * moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core
100  * header (1st) and converted some existing code to it. We port
101  * it here as later kernels will most likely use it.
102  */
103 static inline void le16_add_cpu(__le16 *var, u16 val)
104 {
105         *var = cpu_to_le16(le16_to_cpu(*var) + val);
106 }
107
108 static inline void le32_add_cpu(__le32 *var, u32 val)
109 {
110         *var = cpu_to_le32(le32_to_cpu(*var) + val);
111 }
112
113 static inline void le64_add_cpu(__le64 *var, u64 val)
114 {
115         *var = cpu_to_le64(le64_to_cpu(*var) + val);
116 }
117
118 static inline void be16_add_cpu(__be16 *var, u16 val)
119 {
120         u16 v = be16_to_cpu(*var);
121         *var = cpu_to_be16(v + val);
122 }
123
124 static inline void be32_add_cpu(__be32 *var, u32 val)
125 {
126         u32 v = be32_to_cpu(*var);
127         *var = cpu_to_be32(v + val);
128 }
129
130 static inline void be64_add_cpu(__be64 *var, u64 val)
131 {
132         u64 v = be64_to_cpu(*var);
133         *var = cpu_to_be64(v + val);
134 }
135
136 /* 2.6.25 changes hwrng_unregister()'s behaviour by supporting
137  * suspend of its parent device (the misc device, which is itself the
138  * hardware random number generator). It does this by passing a parameter to
139  * unregister_miscdev() which is not supported in older kernels. The suspend
140  * parameter allows us to enable access to the device's hardware
141  * number generator during suspend. As far as wireless is concerned this means
142  * if a driver goes to suspend it you won't have the HNR available in
143  * older kernels. */
144 static inline void __hwrng_unregister(struct hwrng *rng, bool suspended)
145 {
146         hwrng_unregister(rng);
147 }
148
149 static inline void led_classdev_unregister_suspended(struct led_classdev *lcd)
150 {
151         led_classdev_unregister(lcd);
152 }
153
154 /**
155  * The following things are out of ./include/linux/kernel.h
156  * The new iwlwifi driver is using them.
157  */
158 extern int strict_strtoul(const char *, unsigned int, unsigned long *);
159 extern int strict_strtol(const char *, unsigned int, long *);
160
161 #else
162 /*
163  * Kernels >= 2.6.25 have pm-qos and its initialized as part of
164  * the bootup process
165  */
166 static inline int compat_pm_qos_power_init(void)
167 {
168         return 0;
169 }
170
171 static inline int compat_pm_qos_power_deinit(void)
172 {
173         return 0;
174 }
175 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */
176
177 #endif /* LINUX_26_25_COMPAT_H */