c92c8b48de2e836e6444dec72a582dc41bd931bb
[~emulex/for-vlad/old/compat.git] / include / linux / compat-2.6.28.h
1 #ifndef LINUX_26_28_COMPAT_H
2 #define LINUX_26_28_COMPAT_H
3
4 #include <linux/version.h>
5
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
7
8 #include <linux/skbuff.h>
9 #include <linux/if_ether.h>
10 #include <linux/usb.h>
11
12 #ifndef ETH_P_PAE
13 #define ETH_P_PAE 0x888E      /* Port Access Entity (IEEE 802.1X) */
14 #endif
15
16 #include <linux/pci.h>
17
18 #ifndef WARN_ONCE
19 #define WARN_ONCE(condition, format...) ({                      \
20         static int __warned;                                    \
21         int __ret_warn_once = !!(condition);                    \
22                                                                 \
23         if (unlikely(__ret_warn_once))                          \
24                 if (WARN(!__warned, format))                    \
25                         __warned = 1;                           \
26         unlikely(__ret_warn_once);                              \
27 })
28 #endif /* From include/asm-generic/bug.h */
29
30 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
31
32 #include <pcmcia/cs_types.h>
33 #include <pcmcia/cs.h>
34 #include <pcmcia/cistpl.h>
35 #ifdef pcmcia_parse_tuple
36 #undef pcmcia_parse_tuple
37 #define pcmcia_parse_tuple(tuple, parse) pccard_parse_tuple(tuple, parse)
38 #endif
39
40 /* From : include/pcmcia/ds.h */
41 /* loop CIS entries for valid configuration */
42 int pcmcia_loop_config(struct pcmcia_device *p_dev,
43                        int      (*conf_check)   (struct pcmcia_device *p_dev,
44                                                  cistpl_cftable_entry_t *cfg,
45                                                  cistpl_cftable_entry_t *dflt,
46                                                  unsigned int vcc,
47                                                  void *priv_data),
48                        void *priv_data);
49
50 #endif /* CONFIG_PCMCIA */
51
52 /* USB anchors were added as of 2.6.23 */
53 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
54
55 #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
56 #if 0
57 extern void usb_poison_urb(struct urb *urb);
58 #endif
59 extern void usb_unpoison_urb(struct urb *urb);
60
61 #if 0
62 extern void usb_poison_anchored_urbs(struct usb_anchor *anchor);
63 #endif
64
65 extern int usb_anchor_empty(struct usb_anchor *anchor);
66 #endif /* CONFIG_USB */
67 #endif
68
69
70 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
71
72 /**
73  *      skb_queue_is_last - check if skb is the last entry in the queue
74  *      @list: queue head
75  *      @skb: buffer
76  *
77  *      Returns true if @skb is the last buffer on the list.
78  */
79 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
80                                      const struct sk_buff *skb)
81 {
82         return (skb->next == (struct sk_buff *) list);
83 }
84
85 /**
86  *      skb_queue_next - return the next packet in the queue
87  *      @list: queue head
88  *      @skb: current buffer
89  *
90  *      Return the next packet in @list after @skb.  It is only valid to
91  *      call this if skb_queue_is_last() evaluates to false.
92  */
93 static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list,
94                                              const struct sk_buff *skb)
95 {
96         /* This BUG_ON may seem severe, but if we just return then we
97          * are going to dereference garbage.
98          */
99         BUG_ON(skb_queue_is_last(list, skb));
100         return skb->next;
101 }
102
103 /**
104  *      __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head
105  *      @list: queue to initialize
106  *
107  *      This initializes only the list and queue length aspects of
108  *      an sk_buff_head object.  This allows to initialize the list
109  *      aspects of an sk_buff_head without reinitializing things like
110  *      the spinlock.  It can also be used for on-stack sk_buff_head
111  *      objects where the spinlock is known to not be used.
112  */
113 static inline void __skb_queue_head_init(struct sk_buff_head *list)
114 {
115         list->prev = list->next = (struct sk_buff *)list;
116         list->qlen = 0;
117 }
118
119 static inline void __skb_queue_splice(const struct sk_buff_head *list,
120                                       struct sk_buff *prev,
121                                       struct sk_buff *next)
122 {
123         struct sk_buff *first = list->next;
124         struct sk_buff *last = list->prev;
125
126         first->prev = prev;
127         prev->next = first;
128
129         last->next = next;
130         next->prev = last;
131 }
132
133 /**
134  *      skb_queue_splice - join two skb lists, this is designed for stacks
135  *      @list: the new list to add
136  *      @head: the place to add it in the first list
137  */
138 static inline void skb_queue_splice(const struct sk_buff_head *list,
139                                     struct sk_buff_head *head)
140 {
141         if (!skb_queue_empty(list)) {
142                 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
143                 head->qlen += list->qlen;
144         }
145 }
146
147 /**
148  *      skb_queue_splice - join two skb lists and reinitialise the emptied list
149  *      @list: the new list to add
150  *      @head: the place to add it in the first list
151  *
152  *      The list at @list is reinitialised
153  */
154 static inline void skb_queue_splice_init(struct sk_buff_head *list,
155                                          struct sk_buff_head *head)
156 {
157         if (!skb_queue_empty(list)) {
158                 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
159                 head->qlen += list->qlen;
160                 __skb_queue_head_init(list);
161         }
162 }
163
164 /**
165  *      skb_queue_splice_tail - join two skb lists and reinitialise the emptied list
166  *      @list: the new list to add
167  *      @head: the place to add it in the first list
168  *
169  *      Each of the lists is a queue.
170  *      The list at @list is reinitialised
171  */
172 static inline void skb_queue_splice_tail_init(struct sk_buff_head *list,
173                                               struct sk_buff_head *head)
174 {
175         if (!skb_queue_empty(list)) {
176                 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
177                 head->qlen += list->qlen;
178                 __skb_queue_head_init(list);
179         }
180 } /* From include/linux/skbuff.h */
181
182 /**
183  *      skb_queue_splice_tail - join two skb lists, each list being a queue
184  *      @list: the new list to add
185  *      @head: the place to add it in the first list
186  */
187 static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
188                                          struct sk_buff_head *head)
189 {
190         if (!skb_queue_empty(list)) {
191                 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
192                 head->qlen += list->qlen;
193         }
194 }
195
196 #ifndef DECLARE_TRACE
197
198 #define TP_PROTO(args...)       args
199 #define TP_ARGS(args...)                args
200
201 #define DECLARE_TRACE(name, proto, args)                                \
202         static inline void _do_trace_##name(struct tracepoint *tp, proto) \
203         { }                                                             \
204         static inline void trace_##name(proto)                          \
205         { }                                                             \
206         static inline int register_trace_##name(void (*probe)(proto))   \
207         {                                                               \
208                 return -ENOSYS;                                         \
209         }                                                               \
210         static inline int unregister_trace_##name(void (*probe)(proto)) \
211         {                                                               \
212                 return -ENOSYS;                                         \
213         }
214
215 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
216 #define EXPORT_TRACEPOINT_SYMBOL(name)
217
218
219 #endif
220
221 /* openSuse includes round_jiffies_up in it's kernel 2.6.27.
222  * This is needed to prevent conflicts with the openSuse definition.
223  */
224 #define round_jiffies_up backport_round_jiffies_up
225
226 unsigned long round_jiffies_up(unsigned long j);
227
228 extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
229                             int off, int size);
230
231 #define wake_up_interruptible_poll(x, m)                        \
232         __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m))
233
234 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
235                        unsigned int cmd, unsigned long arg);
236
237 int pci_wake_from_d3(struct pci_dev *dev, bool enable);
238
239 #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active)
240
241 #ifndef pr_fmt
242 #define pr_fmt(fmt) fmt
243 #endif
244
245 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */
246
247 #endif /* LINUX_26_28_COMPAT_H */