wl1251: prevent scan when connected
[pandora-wifi.git] / include / linux / compat-2.6.27.h
1 #ifndef LINUX_26_27_COMPAT_H
2 #define LINUX_26_27_COMPAT_H
3
4 #include <linux/version.h>
5
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
7
8 #include <linux/debugfs.h>
9 #include <linux/list.h>
10 #include <linux/pci.h>
11 #include <linux/dma-mapping.h>
12 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
13 #include <linux/mmc/sdio.h>
14 #include <linux/mmc/sdio_func.h>
15 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
16 #include <linux/netdevice.h>
17 #include <linux/workqueue.h>
18 #include <net/iw_handler.h>
19 #include <asm-generic/bug.h>
20 #include <linux/wireless.h>
21
22 #define PCI_PM_CAP_PME_SHIFT    11
23
24 /* I can't find a more suitable replacement... */
25 #define flush_work(work) cancel_work_sync(work)
26
27 struct builtin_fw {
28         char *name;
29         void *data;
30         unsigned long size;
31 };
32
33 /*
34  * On older kernels we do not have net_device Multi Queue support, but
35  * since we no longer use MQ on mac80211 we can simply use the 0 queue.
36  * Note that if other fullmac drivers make use of this they then need
37  * to be backported somehow or deal with just 1 queueue from MQ.
38  */
39 static inline void netif_tx_wake_all_queues(struct net_device *dev)
40 {
41         netif_wake_queue(dev);
42 }
43 static inline void netif_tx_start_all_queues(struct net_device *dev)
44 {
45         netif_start_queue(dev);
46 }
47 static inline void netif_tx_stop_all_queues(struct net_device *dev)
48 {
49         netif_stop_queue(dev);
50 }
51
52 bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
53
54 /*
55  * The net_device has a spin_lock on newer kernels, on older kernels we're out of luck
56  */
57 #define netif_addr_lock_bh(dev)
58 #define netif_addr_unlock_bh(dev)
59
60 /*
61  * To port this properly we'd have to port warn_slowpath_null(),
62  * which I'm lazy to do so just do a regular print for now. If you
63  * want to port this read kernel/panic.c
64  */
65 #define __WARN_printf(arg...)   do { printk(arg); __WARN(); } while (0)
66
67 /* This is ported directly as-is on newer kernels */
68 #ifndef WARN
69 #define WARN(condition, format...) ({                                   \
70         int __ret_warn_on = !!(condition);                              \
71         if (unlikely(__ret_warn_on))                                    \
72                 __WARN_printf(format);                                  \
73         unlikely(__ret_warn_on);                                        \
74 })
75 #endif
76
77 /* On 2.6.27 a second argument was added, on older kernels we ignore it */
78 #define dma_mapping_error(pdev, dma_addr) dma_mapping_error(dma_addr)
79 #define pci_dma_mapping_error(pdev, dma_addr) dma_mapping_error(pdev, dma_addr)
80
81 /* This is from include/linux/ieee80211.h */
82 #define IEEE80211_HT_CAP_DSSSCCK40              0x1000
83
84 /* New link list changes added as of 2.6.27, needed for ath9k */
85
86 static inline void __list_cut_position(struct list_head *list,
87                 struct list_head *head, struct list_head *entry)
88 {
89         struct list_head *new_first = entry->next;
90         list->next = head->next;
91         list->next->prev = list;
92         list->prev = entry;
93         entry->next = list;
94         head->next = new_first;
95         new_first->prev = head;
96 }
97
98 /**
99  * list_cut_position - cut a list into two
100  * @list: a new list to add all removed entries
101  * @head: a list with entries
102  * @entry: an entry within head, could be the head itself
103  *      and if so we won't cut the list
104  *
105  * This helper moves the initial part of @head, up to and
106  * including @entry, from @head to @list. You should
107  * pass on @entry an element you know is on @head. @list
108  * should be an empty list or a list you do not care about
109  * losing its data.
110  *
111  */
112 static inline void list_cut_position(struct list_head *list,
113                 struct list_head *head, struct list_head *entry)
114 {
115         if (list_empty(head))
116                 return;
117         if (list_is_singular(head) &&
118                 (head->next != entry && head != entry))
119                 return;
120         if (entry == head)
121                 INIT_LIST_HEAD(list);
122         else
123                 __list_cut_position(list, head, entry);
124 }
125
126
127 /* __list_splice as re-implemented on 2.6.27, we backport it */
128 static inline void __compat_list_splice_new_27(const struct list_head *list,
129                                  struct list_head *prev,
130                                  struct list_head *next)
131 {
132         struct list_head *first = list->next;
133         struct list_head *last = list->prev;
134
135         first->prev = prev;
136         prev->next = first;
137
138         last->next = next;
139         next->prev = last;
140 }
141
142 /**
143  * list_splice_tail - join two lists, each list being a queue
144  * @list: the new list to add.
145  * @head: the place to add it in the first list.
146  */
147 static inline void list_splice_tail(struct list_head *list,
148                                 struct list_head *head)
149 {
150         if (!list_empty(list))
151                 __compat_list_splice_new_27(list, head->prev, head);
152 }
153
154 /**
155  * list_splice_tail_init - join two lists and reinitialise the emptied list
156  * @list: the new list to add.
157  * @head: the place to add it in the first list.
158  *
159  * Each of the lists is a queue.
160  * The list at @list is reinitialised
161  */
162 static inline void list_splice_tail_init(struct list_head *list,
163                                          struct list_head *head)
164 {
165         if (!list_empty(list)) {
166                 __compat_list_splice_new_27(list, head->prev, head);
167                 INIT_LIST_HEAD(list);
168         }
169 }
170
171 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
172 extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int);
173 extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
174 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
175
176 #define iwe_stream_add_value(info, event, value, ends, iwe, event_len) iwe_stream_add_value(event, value, ends, iwe, event_len)
177 #define iwe_stream_add_point(info, stream, ends, iwe, extra) iwe_stream_add_point(stream, ends, iwe, extra)
178 #define iwe_stream_add_event(info, stream, ends, iwe, event_len) iwe_stream_add_event(stream, ends, iwe, event_len)
179
180 /* Flags available in struct iw_request_info */
181 #define IW_REQUEST_FLAG_COMPAT  0x0001  /* Compat ioctl call */
182
183 static inline int iwe_stream_lcp_len(struct iw_request_info *info)
184 {
185 #ifdef CONFIG_COMPAT
186         if (info->flags & IW_REQUEST_FLAG_COMPAT)
187                 return IW_EV_COMPAT_LCP_LEN;
188 #endif
189         return IW_EV_LCP_LEN;
190 }
191
192 #ifdef CONFIG_ARM
193
194 /*
195  * The caller asks to handle a range between offset and offset + size,
196  * but we process a larger range from 0 to offset + size due to lack of
197  * offset support.
198  */
199
200 static inline void dma_sync_single_range_for_cpu(struct device *dev,
201                 dma_addr_t handle, unsigned long offset, size_t size,
202                 enum dma_data_direction dir)
203 {
204         dma_sync_single_for_cpu(dev, handle, offset + size, dir);
205 }
206
207 static inline void dma_sync_single_range_for_device(struct device *dev,
208                 dma_addr_t handle, unsigned long offset, size_t size,
209                 enum dma_data_direction dir)
210 {
211         dma_sync_single_for_device(dev, handle, offset + size, dir);
212 }
213
214 #endif /* arm */
215
216 #if defined(CONFIG_DEBUG_FS)
217 void debugfs_remove_recursive(struct dentry *dentry);
218 #else
219 static inline void debugfs_remove_recursive(struct dentry *dentry)
220 { }
221 #endif
222
223 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */
224
225 #endif /* LINUX_26_27_COMPAT_H */