1 #ifndef LINUX_26_28_COMPAT_H
2 #define LINUX_26_28_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
8 #include <linux/skbuff.h>
9 #include <linux/if_ether.h>
10 #include <linux/usb.h>
11 #include <linux/types.h>
12 #include <linux/types.h>
13 #include <linux/cpumask.h>
16 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
19 #include <linux/pci.h>
21 typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } compat_cpumask_t;
23 #if defined(CONFIG_X86) || defined(CONFIG_X86_64) || defined(CONFIG_PPC)
25 * CONFIG_PHYS_ADDR_T_64BIT was added as new to all architectures
26 * as of 2.6.28 but x86 and ppc had it already. x86 only got phys_addr_t
27 * as of 2.6.25 but then is backported in compat-2.6.25.h
30 #if defined(CONFIG_64BIT) || defined(CONFIG_X86_PAE) || defned(CONFIG_PPC64) || defined(CONFIG_PHYS_64BIT)
31 #define CONFIG_PHYS_ADDR_T_64BIT 1
32 typedef u64 phys_addr_t;
34 typedef u32 phys_addr_t;
37 #endif /* non x86 and ppc */
40 #define WARN_ONCE(condition, format...) ({ \
41 static int __warned; \
42 int __ret_warn_once = !!(condition); \
44 if (unlikely(__ret_warn_once)) \
45 if (WARN(!__warned, format)) \
47 unlikely(__ret_warn_once); \
49 #endif /* From include/asm-generic/bug.h */
51 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
53 #include <pcmcia/cs_types.h>
54 #include <pcmcia/cs.h>
55 #include <pcmcia/cistpl.h>
56 #ifdef pcmcia_parse_tuple
57 #undef pcmcia_parse_tuple
58 #define pcmcia_parse_tuple(tuple, parse) pccard_parse_tuple(tuple, parse)
61 /* From : include/pcmcia/ds.h */
62 /* loop CIS entries for valid configuration */
63 int pcmcia_loop_config(struct pcmcia_device *p_dev,
64 int (*conf_check) (struct pcmcia_device *p_dev,
65 cistpl_cftable_entry_t *cfg,
66 cistpl_cftable_entry_t *dflt,
71 #endif /* CONFIG_PCMCIA */
73 /* USB anchors were added as of 2.6.23 */
74 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
76 #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
78 extern void usb_poison_urb(struct urb *urb);
80 extern void usb_unpoison_urb(struct urb *urb);
83 extern void usb_poison_anchored_urbs(struct usb_anchor *anchor);
86 extern int usb_anchor_empty(struct usb_anchor *anchor);
87 #endif /* CONFIG_USB */
91 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
94 * skb_queue_is_last - check if skb is the last entry in the queue
98 * Returns true if @skb is the last buffer on the list.
100 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
101 const struct sk_buff *skb)
103 return (skb->next == (struct sk_buff *) list);
107 * skb_queue_next - return the next packet in the queue
109 * @skb: current buffer
111 * Return the next packet in @list after @skb. It is only valid to
112 * call this if skb_queue_is_last() evaluates to false.
114 static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list,
115 const struct sk_buff *skb)
117 /* This BUG_ON may seem severe, but if we just return then we
118 * are going to dereference garbage.
120 BUG_ON(skb_queue_is_last(list, skb));
125 * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head
126 * @list: queue to initialize
128 * This initializes only the list and queue length aspects of
129 * an sk_buff_head object. This allows to initialize the list
130 * aspects of an sk_buff_head without reinitializing things like
131 * the spinlock. It can also be used for on-stack sk_buff_head
132 * objects where the spinlock is known to not be used.
134 static inline void __skb_queue_head_init(struct sk_buff_head *list)
136 list->prev = list->next = (struct sk_buff *)list;
140 static inline void __skb_queue_splice(const struct sk_buff_head *list,
141 struct sk_buff *prev,
142 struct sk_buff *next)
144 struct sk_buff *first = list->next;
145 struct sk_buff *last = list->prev;
155 * skb_queue_splice - join two skb lists, this is designed for stacks
156 * @list: the new list to add
157 * @head: the place to add it in the first list
159 static inline void skb_queue_splice(const struct sk_buff_head *list,
160 struct sk_buff_head *head)
162 if (!skb_queue_empty(list)) {
163 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
164 head->qlen += list->qlen;
169 * skb_queue_splice - join two skb lists and reinitialise the emptied list
170 * @list: the new list to add
171 * @head: the place to add it in the first list
173 * The list at @list is reinitialised
175 static inline void skb_queue_splice_init(struct sk_buff_head *list,
176 struct sk_buff_head *head)
178 if (!skb_queue_empty(list)) {
179 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
180 head->qlen += list->qlen;
181 __skb_queue_head_init(list);
186 * skb_queue_splice_tail - join two skb lists and reinitialise the emptied list
187 * @list: the new list to add
188 * @head: the place to add it in the first list
190 * Each of the lists is a queue.
191 * The list at @list is reinitialised
193 static inline void skb_queue_splice_tail_init(struct sk_buff_head *list,
194 struct sk_buff_head *head)
196 if (!skb_queue_empty(list)) {
197 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
198 head->qlen += list->qlen;
199 __skb_queue_head_init(list);
201 } /* From include/linux/skbuff.h */
204 * skb_queue_splice_tail - join two skb lists, each list being a queue
205 * @list: the new list to add
206 * @head: the place to add it in the first list
208 static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
209 struct sk_buff_head *head)
211 if (!skb_queue_empty(list)) {
212 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
213 head->qlen += list->qlen;
217 #ifndef DECLARE_TRACE
219 #define TP_PROTO(args...) args
220 #define TP_ARGS(args...) args
222 #define DECLARE_TRACE(name, proto, args) \
223 static inline void _do_trace_##name(struct tracepoint *tp, proto) \
225 static inline void trace_##name(proto) \
227 static inline int register_trace_##name(void (*probe)(proto)) \
231 static inline int unregister_trace_##name(void (*probe)(proto)) \
236 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
237 #define EXPORT_TRACEPOINT_SYMBOL(name)
242 /* openSuse includes round_jiffies_up in it's kernel 2.6.27.
243 * This is needed to prevent conflicts with the openSuse definition.
245 #define round_jiffies_up backport_round_jiffies_up
247 unsigned long round_jiffies_up(unsigned long j);
249 extern void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
252 #define wake_up_interruptible_poll(x, m) \
253 __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m))
255 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
256 unsigned int cmd, unsigned long arg);
258 int pci_wake_from_d3(struct pci_dev *dev, bool enable);
260 #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active)
263 #define pr_fmt(fmt) fmt
266 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */
268 #endif /* LINUX_26_28_COMPAT_H */