compat: backport n_tty_ioctl_helper
[~tnikolova/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 struct urb *usb_get_from_anchor(struct usb_anchor *anchor);
66 extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor);
67 extern int usb_anchor_empty(struct usb_anchor *anchor);
68 #endif /* CONFIG_USB */
69 #endif
70
71
72 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
73
74 /**
75  *      skb_queue_is_last - check if skb is the last entry in the queue
76  *      @list: queue head
77  *      @skb: buffer
78  *
79  *      Returns true if @skb is the last buffer on the list.
80  */
81 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
82                                      const struct sk_buff *skb)
83 {
84         return (skb->next == (struct sk_buff *) list);
85 }
86
87 /**
88  *      skb_queue_next - return the next packet in the queue
89  *      @list: queue head
90  *      @skb: current buffer
91  *
92  *      Return the next packet in @list after @skb.  It is only valid to
93  *      call this if skb_queue_is_last() evaluates to false.
94  */
95 static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list,
96                                              const struct sk_buff *skb)
97 {
98         /* This BUG_ON may seem severe, but if we just return then we
99          * are going to dereference garbage.
100          */
101         BUG_ON(skb_queue_is_last(list, skb));
102         return skb->next;
103 }
104
105 /**
106  *      __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head
107  *      @list: queue to initialize
108  *
109  *      This initializes only the list and queue length aspects of
110  *      an sk_buff_head object.  This allows to initialize the list
111  *      aspects of an sk_buff_head without reinitializing things like
112  *      the spinlock.  It can also be used for on-stack sk_buff_head
113  *      objects where the spinlock is known to not be used.
114  */
115 static inline void __skb_queue_head_init(struct sk_buff_head *list)
116 {
117         list->prev = list->next = (struct sk_buff *)list;
118         list->qlen = 0;
119 }
120
121 static inline void __skb_queue_splice(const struct sk_buff_head *list,
122                                       struct sk_buff *prev,
123                                       struct sk_buff *next)
124 {
125         struct sk_buff *first = list->next;
126         struct sk_buff *last = list->prev;
127
128         first->prev = prev;
129         prev->next = first;
130
131         last->next = next;
132         next->prev = last;
133 }
134
135 /**
136  *      skb_queue_splice - join two skb lists, this is designed for stacks
137  *      @list: the new list to add
138  *      @head: the place to add it in the first list
139  */
140 static inline void skb_queue_splice(const struct sk_buff_head *list,
141                                     struct sk_buff_head *head)
142 {
143         if (!skb_queue_empty(list)) {
144                 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
145                 head->qlen += list->qlen;
146         }
147 }
148
149 /**
150  *      skb_queue_splice - join two skb lists and reinitialise the emptied list
151  *      @list: the new list to add
152  *      @head: the place to add it in the first list
153  *
154  *      The list at @list is reinitialised
155  */
156 static inline void skb_queue_splice_init(struct sk_buff_head *list,
157                                          struct sk_buff_head *head)
158 {
159         if (!skb_queue_empty(list)) {
160                 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
161                 head->qlen += list->qlen;
162                 __skb_queue_head_init(list);
163         }
164 }
165
166 /**
167  *      skb_queue_splice_tail - join two skb lists and reinitialise the emptied list
168  *      @list: the new list to add
169  *      @head: the place to add it in the first list
170  *
171  *      Each of the lists is a queue.
172  *      The list at @list is reinitialised
173  */
174 static inline void skb_queue_splice_tail_init(struct sk_buff_head *list,
175                                               struct sk_buff_head *head)
176 {
177         if (!skb_queue_empty(list)) {
178                 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
179                 head->qlen += list->qlen;
180                 __skb_queue_head_init(list);
181         }
182 } /* From include/linux/skbuff.h */
183
184 /**
185  *      skb_queue_splice_tail - join two skb lists, each list being a queue
186  *      @list: the new list to add
187  *      @head: the place to add it in the first list
188  */
189 static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
190                                          struct sk_buff_head *head)
191 {
192         if (!skb_queue_empty(list)) {
193                 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
194                 head->qlen += list->qlen;
195         }
196 }
197
198 #ifndef DECLARE_TRACE
199
200 #define TP_PROTO(args...)       args
201 #define TP_ARGS(args...)                args
202
203 #define DECLARE_TRACE(name, proto, args)                                \
204         static inline void _do_trace_##name(struct tracepoint *tp, proto) \
205         { }                                                             \
206         static inline void trace_##name(proto)                          \
207         { }                                                             \
208         static inline int register_trace_##name(void (*probe)(proto))   \
209         {                                                               \
210                 return -ENOSYS;                                         \
211         }                                                               \
212         static inline int unregister_trace_##name(void (*probe)(proto)) \
213         {                                                               \
214                 return -ENOSYS;                                         \
215         }
216
217 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
218 #define EXPORT_TRACEPOINT_SYMBOL(name)
219
220
221 #endif
222
223 /* openSuse includes round_jiffies_up in it's kernel 2.6.27.
224  * This is needed to prevent conflicts with the openSuse definition.
225  */
226 #define round_jiffies_up backport_round_jiffies_up
227
228 unsigned long round_jiffies_up(unsigned long j);
229
230 extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
231                             int off, int size);
232
233 #define wake_up_interruptible_poll(x, m)                        \
234         __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m))
235
236 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
237                        unsigned int cmd, unsigned long arg);
238
239 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */
240
241 #endif /* LINUX_26_28_COMPAT_H */