1 #ifndef LINUX_26_27_COMPAT_H
2 #define LINUX_26_27_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
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>
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)
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.
39 static inline void netif_tx_wake_all_queues(struct net_device *dev)
41 netif_wake_queue(dev);
43 static inline void netif_tx_start_all_queues(struct net_device *dev)
45 netif_start_queue(dev);
47 static inline void netif_tx_stop_all_queues(struct net_device *dev)
49 netif_stop_queue(dev);
52 bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
55 * The net_device has a spin_lock on newer kernels, on older kernels we're out of luck
57 #define netif_addr_lock_bh(dev)
58 #define netif_addr_unlock_bh(dev)
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
65 #define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
67 /* This is ported directly as-is on newer kernels */
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); \
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)
81 /* This is from include/linux/ieee80211.h */
82 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
84 /* New link list changes added as of 2.6.27, needed for ath9k */
86 static inline void __list_cut_position(struct list_head *list,
87 struct list_head *head, struct list_head *entry)
89 struct list_head *new_first = entry->next;
90 list->next = head->next;
91 list->next->prev = list;
94 head->next = new_first;
95 new_first->prev = head;
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
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
112 static inline void list_cut_position(struct list_head *list,
113 struct list_head *head, struct list_head *entry)
115 if (list_empty(head))
117 if (list_is_singular(head) &&
118 (head->next != entry && head != entry))
121 INIT_LIST_HEAD(list);
123 __list_cut_position(list, head, entry);
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)
132 struct list_head *first = list->next;
133 struct list_head *last = list->prev;
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.
147 static inline void list_splice_tail(struct list_head *list,
148 struct list_head *head)
150 if (!list_empty(list))
151 __compat_list_splice_new_27(list, head->prev, head);
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.
159 * Each of the lists is a queue.
160 * The list at @list is reinitialised
162 static inline void list_splice_tail_init(struct list_head *list,
163 struct list_head *head)
165 if (!list_empty(list)) {
166 __compat_list_splice_new_27(list, head->prev, head);
167 INIT_LIST_HEAD(list);
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) */
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)
180 /* Flags available in struct iw_request_info */
181 #define IW_REQUEST_FLAG_COMPAT 0x0001 /* Compat ioctl call */
183 static inline int iwe_stream_lcp_len(struct iw_request_info *info)
186 if (info->flags & IW_REQUEST_FLAG_COMPAT)
187 return IW_EV_COMPAT_LCP_LEN;
189 return IW_EV_LCP_LEN;
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
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)
204 dma_sync_single_for_cpu(dev, handle, offset + size, dir);
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)
211 dma_sync_single_for_device(dev, handle, offset + size, dir);
216 #if defined(CONFIG_DEBUG_FS)
217 void debugfs_remove_recursive(struct dentry *dentry);
219 static inline void debugfs_remove_recursive(struct dentry *dentry)
223 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */
225 #endif /* LINUX_26_27_COMPAT_H */