1 #ifndef LINUX_26_27_COMPAT_H
2 #define LINUX_26_27_COMPAT_H
4 #include <linux/autoconf.h>
5 #include <linux/version.h>
7 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
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>
22 #define PCI_PM_CAP_PME_SHIFT 11
24 /* I can't find a more suitable replacement... */
25 #define flush_work(work) cancel_work_sync(work)
28 * On older kernels we do not have net_device Multi Queue support, but
29 * since we no longer use MQ on mac80211 we can simply use the 0 queue.
30 * Note that if other fullmac drivers make use of this they then need
31 * to be backported somehow or deal with just 1 queueue from MQ.
33 static inline void netif_tx_wake_all_queues(struct net_device *dev)
35 netif_wake_queue(dev);
37 static inline void netif_tx_start_all_queues(struct net_device *dev)
39 netif_start_queue(dev);
41 static inline void netif_tx_stop_all_queues(struct net_device *dev)
43 netif_stop_queue(dev);
46 bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
49 * The net_device has a spin_lock on newer kernels, on older kernels we're out of luck
51 #define netif_addr_lock_bh(dev)
52 #define netif_addr_unlock_bh(dev)
55 * To port this properly we'd have to port warn_slowpath_null(),
56 * which I'm lazy to do so just do a regular print for now. If you
57 * want to port this read kernel/panic.c
59 #define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
61 /* This is ported directly as-is on newer kernels */
63 #define WARN(condition, format...) ({ \
64 int __ret_warn_on = !!(condition); \
65 if (unlikely(__ret_warn_on)) \
66 __WARN_printf(format); \
67 unlikely(__ret_warn_on); \
71 /* On 2.6.27 a second argument was added, on older kernels we ignore it */
72 #define dma_mapping_error(pdev, dma_addr) dma_mapping_error(dma_addr)
73 #define pci_dma_mapping_error(pdev, dma_addr) dma_mapping_error(pdev, dma_addr)
75 /* This is from include/linux/ieee80211.h */
76 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
78 /* New link list changes added as of 2.6.27, needed for ath9k */
80 static inline void __list_cut_position(struct list_head *list,
81 struct list_head *head, struct list_head *entry)
83 struct list_head *new_first = entry->next;
84 list->next = head->next;
85 list->next->prev = list;
88 head->next = new_first;
89 new_first->prev = head;
93 * list_cut_position - cut a list into two
94 * @list: a new list to add all removed entries
95 * @head: a list with entries
96 * @entry: an entry within head, could be the head itself
97 * and if so we won't cut the list
99 * This helper moves the initial part of @head, up to and
100 * including @entry, from @head to @list. You should
101 * pass on @entry an element you know is on @head. @list
102 * should be an empty list or a list you do not care about
106 static inline void list_cut_position(struct list_head *list,
107 struct list_head *head, struct list_head *entry)
109 if (list_empty(head))
111 if (list_is_singular(head) &&
112 (head->next != entry && head != entry))
115 INIT_LIST_HEAD(list);
117 __list_cut_position(list, head, entry);
121 /* __list_splice as re-implemented on 2.6.27, we backport it */
122 static inline void __compat_list_splice_new_27(const struct list_head *list,
123 struct list_head *prev,
124 struct list_head *next)
126 struct list_head *first = list->next;
127 struct list_head *last = list->prev;
137 * list_splice_tail - join two lists, each list being a queue
138 * @list: the new list to add.
139 * @head: the place to add it in the first list.
141 static inline void list_splice_tail(struct list_head *list,
142 struct list_head *head)
144 if (!list_empty(list))
145 __compat_list_splice_new_27(list, head->prev, head);
149 * list_splice_tail_init - join two lists and reinitialise the emptied list
150 * @list: the new list to add.
151 * @head: the place to add it in the first list.
153 * Each of the lists is a queue.
154 * The list at @list is reinitialised
156 static inline void list_splice_tail_init(struct list_head *list,
157 struct list_head *head)
159 if (!list_empty(list)) {
160 __compat_list_splice_new_27(list, head->prev, head);
161 INIT_LIST_HEAD(list);
165 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
166 extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int);
167 extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
168 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
170 #define iwe_stream_add_value(info, event, value, ends, iwe, event_len) iwe_stream_add_value(event, value, ends, iwe, event_len)
171 #define iwe_stream_add_point(info, stream, ends, iwe, extra) iwe_stream_add_point(stream, ends, iwe, extra)
172 #define iwe_stream_add_event(info, stream, ends, iwe, event_len) iwe_stream_add_event(stream, ends, iwe, event_len)
174 /* Flags available in struct iw_request_info */
175 #define IW_REQUEST_FLAG_COMPAT 0x0001 /* Compat ioctl call */
177 static inline int iwe_stream_lcp_len(struct iw_request_info *info)
180 if (info->flags & IW_REQUEST_FLAG_COMPAT)
181 return IW_EV_COMPAT_LCP_LEN;
183 return IW_EV_LCP_LEN;
186 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */
188 #endif /* LINUX_26_27_COMPAT_H */