[package] libuuid needs to be compiled with fPIC/pic.
[openwrt.git] / package / mac80211 / patches / 011-move_ar9170_usb_compat_code.patch
1 --- a/drivers/net/wireless/ath/ar9170/usb.c
2 +++ b/drivers/net/wireless/ath/ar9170/usb.c
3 @@ -100,6 +100,225 @@ static struct usb_device_id ar9170_usb_i
4 };
5 MODULE_DEVICE_TABLE(usb, ar9170_usb_ids);
6
7 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
8 +
9 +/**
10 + * usb_unpoison_anchored_urbs - let an anchor be used successfully again
11 + * @anchor: anchor the requests are bound to
12 + *
13 + * Reverses the effect of usb_poison_anchored_urbs
14 + * the anchor can be used normally after it returns
15 + */
16 +void usb_unpoison_anchored_urbs(struct usb_anchor *anchor)
17 +{
18 + unsigned long flags;
19 + struct urb *lazarus;
20 +
21 + spin_lock_irqsave(&anchor->lock, flags);
22 + list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) {
23 + usb_unpoison_urb(lazarus);
24 + }
25 + //anchor->poisoned = 0; /* XXX: cannot backport */
26 + spin_unlock_irqrestore(&anchor->lock, flags);
27 +}
28 +EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs);
29 +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */
30 +
31 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
32 +
33 +/*
34 + * Compat-wireless notes for USB backport stuff:
35 + *
36 + * urb->reject exists on 2.6.27, the poison/unpoison helpers
37 + * did not though. The anchor poison does not exist so we cannot use them.
38 + *
39 + * USB anchor poising seems to exist to prevent future driver sumbissions
40 + * of usb_anchor_urb() to an anchor marked as poisoned. For older kernels
41 + * we cannot use that, so new usb_anchor_urb()s will be anchored. The down
42 + * side to this should be submission of URBs will continue being anchored
43 + * on an anchor instead of having them being rejected immediately when the
44 + * driver realized we needed to stop. For ar9170 we poison URBs upon the
45 + * ar9170 mac80211 stop callback(), don't think this should be so bad.
46 + * It mean there is period of time in older kernels for which we continue
47 + * to anchor new URBs to a known stopped anchor. We have two anchors
48 + * (TX, and RX)
49 + */
50 +
51 +#if 0
52 +/**
53 + * usb_poison_urb - reliably kill a transfer and prevent further use of an URB
54 + * @urb: pointer to URB describing a previously submitted request,
55 + * may be NULL
56 + *
57 + * This routine cancels an in-progress request. It is guaranteed that
58 + * upon return all completion handlers will have finished and the URB
59 + * will be totally idle and cannot be reused. These features make
60 + * this an ideal way to stop I/O in a disconnect() callback.
61 + * If the request has not already finished or been unlinked
62 + * the completion handler will see urb->status == -ENOENT.
63 + *
64 + * After and while the routine runs, attempts to resubmit the URB will fail
65 + * with error -EPERM. Thus even if the URB's completion handler always
66 + * tries to resubmit, it will not succeed and the URB will become idle.
67 + *
68 + * This routine may not be used in an interrupt context (such as a bottom
69 + * half or a completion handler), or when holding a spinlock, or in other
70 + * situations where the caller can't schedule().
71 + *
72 + * This routine should not be called by a driver after its disconnect
73 + * method has returned.
74 + */
75 +void usb_poison_urb(struct urb *urb)
76 +{
77 + might_sleep();
78 + if (!(urb && urb->dev && urb->ep))
79 + return;
80 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
81 + spin_lock_irq(&usb_reject_lock);
82 +#endif
83 + ++urb->reject;
84 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
85 + spin_unlock_irq(&usb_reject_lock);
86 +#endif
87 + /*
88 + * XXX: usb_hcd_unlink_urb() needs backporting... this is defined
89 + * on usb hcd.c but urb.c gets access to it. That is, older kernels
90 + * have usb_hcd_unlink_urb() but its not exported, nor can we
91 + * re-implement it exactly. This essentially dequeues the urb from
92 + * hw, we need to figure out a way to backport this.
93 + */
94 + //usb_hcd_unlink_urb(urb, -ENOENT);
95 +
96 + wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
97 +}
98 +EXPORT_SYMBOL_GPL(usb_poison_urb);
99 +#endif
100 +
101 +void usb_unpoison_urb(struct urb *urb)
102 +{
103 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
104 + unsigned long flags;
105 +#endif
106 +
107 + if (!urb)
108 + return;
109 +
110 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
111 + spin_lock_irqsave(&usb_reject_lock, flags);
112 +#endif
113 + --urb->reject;
114 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
115 + spin_unlock_irqrestore(&usb_reject_lock, flags);
116 +#endif
117 +}
118 +EXPORT_SYMBOL_GPL(usb_unpoison_urb);
119 +
120 +
121 +#if 0
122 +/**
123 + * usb_poison_anchored_urbs - cease all traffic from an anchor
124 + * @anchor: anchor the requests are bound to
125 + *
126 + * this allows all outstanding URBs to be poisoned starting
127 + * from the back of the queue. Newly added URBs will also be
128 + * poisoned
129 + *
130 + * This routine should not be called by a driver after its disconnect
131 + * method has returned.
132 + */
133 +void usb_poison_anchored_urbs(struct usb_anchor *anchor)
134 +{
135 + struct urb *victim;
136 +
137 + spin_lock_irq(&anchor->lock);
138 + // anchor->poisoned = 1; /* XXX: Cannot backport */
139 + while (!list_empty(&anchor->urb_list)) {
140 + victim = list_entry(anchor->urb_list.prev, struct urb,
141 + anchor_list);
142 + /* we must make sure the URB isn't freed before we kill it*/
143 + usb_get_urb(victim);
144 + spin_unlock_irq(&anchor->lock);
145 + /* this will unanchor the URB */
146 + usb_poison_urb(victim);
147 + usb_put_urb(victim);
148 + spin_lock_irq(&anchor->lock);
149 + }
150 + spin_unlock_irq(&anchor->lock);
151 +}
152 +EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs);
153 +#endif
154 +
155 +/**
156 + * usb_get_from_anchor - get an anchor's oldest urb
157 + * @anchor: the anchor whose urb you want
158 + *
159 + * this will take the oldest urb from an anchor,
160 + * unanchor and return it
161 + */
162 +struct urb *usb_get_from_anchor(struct usb_anchor *anchor)
163 +{
164 + struct urb *victim;
165 + unsigned long flags;
166 +
167 + spin_lock_irqsave(&anchor->lock, flags);
168 + if (!list_empty(&anchor->urb_list)) {
169 + victim = list_entry(anchor->urb_list.next, struct urb,
170 + anchor_list);
171 + usb_get_urb(victim);
172 + spin_unlock_irqrestore(&anchor->lock, flags);
173 + usb_unanchor_urb(victim);
174 + } else {
175 + spin_unlock_irqrestore(&anchor->lock, flags);
176 + victim = NULL;
177 + }
178 +
179 + return victim;
180 +}
181 +
182 +EXPORT_SYMBOL_GPL(usb_get_from_anchor);
183 +
184 +/**
185 + * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs
186 + * @anchor: the anchor whose urbs you want to unanchor
187 + *
188 + * use this to get rid of all an anchor's urbs
189 + */
190 +void usb_scuttle_anchored_urbs(struct usb_anchor *anchor)
191 +{
192 + struct urb *victim;
193 + unsigned long flags;
194 +
195 + spin_lock_irqsave(&anchor->lock, flags);
196 + while (!list_empty(&anchor->urb_list)) {
197 + victim = list_entry(anchor->urb_list.prev, struct urb,
198 + anchor_list);
199 + usb_get_urb(victim);
200 + spin_unlock_irqrestore(&anchor->lock, flags);
201 + /* this may free the URB */
202 + usb_unanchor_urb(victim);
203 + usb_put_urb(victim);
204 + spin_lock_irqsave(&anchor->lock, flags);
205 + }
206 + spin_unlock_irqrestore(&anchor->lock, flags);
207 +}
208 +
209 +EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs);
210 +
211 +/**
212 + * usb_anchor_empty - is an anchor empty
213 + * @anchor: the anchor you want to query
214 + *
215 + * returns 1 if the anchor has no urbs associated with it
216 + */
217 +int usb_anchor_empty(struct usb_anchor *anchor)
218 +{
219 + return list_empty(&anchor->urb_list);
220 +}
221 +
222 +EXPORT_SYMBOL_GPL(usb_anchor_empty);
223 +
224 +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) */
225 +
226 static void ar9170_usb_submit_urb(struct ar9170_usb *aru)
227 {
228 struct urb *urb;
229 --- a/net/wireless/compat-2.6.28.c
230 +++ b/net/wireless/compat-2.6.28.c
231 @@ -12,202 +12,8 @@
232
233 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
234
235 -#include <linux/usb.h>
236 -
237 /* 2.6.28 compat code goes here */
238
239 -/*
240 - * Compat-wireless notes for USB backport stuff:
241 - *
242 - * urb->reject exists on 2.6.27, the poison/unpoison helpers
243 - * did not though. The anchor poison does not exist so we cannot use them.
244 - *
245 - * USB anchor poising seems to exist to prevent future driver sumbissions
246 - * of usb_anchor_urb() to an anchor marked as poisoned. For older kernels
247 - * we cannot use that, so new usb_anchor_urb()s will be anchored. The down
248 - * side to this should be submission of URBs will continue being anchored
249 - * on an anchor instead of having them being rejected immediately when the
250 - * driver realized we needed to stop. For ar9170 we poison URBs upon the
251 - * ar9170 mac80211 stop callback(), don't think this should be so bad.
252 - * It mean there is period of time in older kernels for which we continue
253 - * to anchor new URBs to a known stopped anchor. We have two anchors
254 - * (TX, and RX)
255 - */
256 -
257 -#if 0
258 -/**
259 - * usb_poison_urb - reliably kill a transfer and prevent further use of an URB
260 - * @urb: pointer to URB describing a previously submitted request,
261 - * may be NULL
262 - *
263 - * This routine cancels an in-progress request. It is guaranteed that
264 - * upon return all completion handlers will have finished and the URB
265 - * will be totally idle and cannot be reused. These features make
266 - * this an ideal way to stop I/O in a disconnect() callback.
267 - * If the request has not already finished or been unlinked
268 - * the completion handler will see urb->status == -ENOENT.
269 - *
270 - * After and while the routine runs, attempts to resubmit the URB will fail
271 - * with error -EPERM. Thus even if the URB's completion handler always
272 - * tries to resubmit, it will not succeed and the URB will become idle.
273 - *
274 - * This routine may not be used in an interrupt context (such as a bottom
275 - * half or a completion handler), or when holding a spinlock, or in other
276 - * situations where the caller can't schedule().
277 - *
278 - * This routine should not be called by a driver after its disconnect
279 - * method has returned.
280 - */
281 -void usb_poison_urb(struct urb *urb)
282 -{
283 - might_sleep();
284 - if (!(urb && urb->dev && urb->ep))
285 - return;
286 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
287 - spin_lock_irq(&usb_reject_lock);
288 -#endif
289 - ++urb->reject;
290 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
291 - spin_unlock_irq(&usb_reject_lock);
292 -#endif
293 - /*
294 - * XXX: usb_hcd_unlink_urb() needs backporting... this is defined
295 - * on usb hcd.c but urb.c gets access to it. That is, older kernels
296 - * have usb_hcd_unlink_urb() but its not exported, nor can we
297 - * re-implement it exactly. This essentially dequeues the urb from
298 - * hw, we need to figure out a way to backport this.
299 - */
300 - //usb_hcd_unlink_urb(urb, -ENOENT);
301 -
302 - wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
303 -}
304 -EXPORT_SYMBOL_GPL(usb_poison_urb);
305 -#endif
306 -
307 -void usb_unpoison_urb(struct urb *urb)
308 -{
309 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
310 - unsigned long flags;
311 -#endif
312 -
313 - if (!urb)
314 - return;
315 -
316 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
317 - spin_lock_irqsave(&usb_reject_lock, flags);
318 -#endif
319 - --urb->reject;
320 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
321 - spin_unlock_irqrestore(&usb_reject_lock, flags);
322 -#endif
323 -}
324 -EXPORT_SYMBOL_GPL(usb_unpoison_urb);
325 -
326 -
327 -#if 0
328 -/**
329 - * usb_poison_anchored_urbs - cease all traffic from an anchor
330 - * @anchor: anchor the requests are bound to
331 - *
332 - * this allows all outstanding URBs to be poisoned starting
333 - * from the back of the queue. Newly added URBs will also be
334 - * poisoned
335 - *
336 - * This routine should not be called by a driver after its disconnect
337 - * method has returned.
338 - */
339 -void usb_poison_anchored_urbs(struct usb_anchor *anchor)
340 -{
341 - struct urb *victim;
342 -
343 - spin_lock_irq(&anchor->lock);
344 - // anchor->poisoned = 1; /* XXX: Cannot backport */
345 - while (!list_empty(&anchor->urb_list)) {
346 - victim = list_entry(anchor->urb_list.prev, struct urb,
347 - anchor_list);
348 - /* we must make sure the URB isn't freed before we kill it*/
349 - usb_get_urb(victim);
350 - spin_unlock_irq(&anchor->lock);
351 - /* this will unanchor the URB */
352 - usb_poison_urb(victim);
353 - usb_put_urb(victim);
354 - spin_lock_irq(&anchor->lock);
355 - }
356 - spin_unlock_irq(&anchor->lock);
357 -}
358 -EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs);
359 -#endif
360 -
361 -/**
362 - * usb_get_from_anchor - get an anchor's oldest urb
363 - * @anchor: the anchor whose urb you want
364 - *
365 - * this will take the oldest urb from an anchor,
366 - * unanchor and return it
367 - */
368 -struct urb *usb_get_from_anchor(struct usb_anchor *anchor)
369 -{
370 - struct urb *victim;
371 - unsigned long flags;
372 -
373 - spin_lock_irqsave(&anchor->lock, flags);
374 - if (!list_empty(&anchor->urb_list)) {
375 - victim = list_entry(anchor->urb_list.next, struct urb,
376 - anchor_list);
377 - usb_get_urb(victim);
378 - spin_unlock_irqrestore(&anchor->lock, flags);
379 - usb_unanchor_urb(victim);
380 - } else {
381 - spin_unlock_irqrestore(&anchor->lock, flags);
382 - victim = NULL;
383 - }
384 -
385 - return victim;
386 -}
387 -
388 -EXPORT_SYMBOL_GPL(usb_get_from_anchor);
389 -
390 -/**
391 - * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs
392 - * @anchor: the anchor whose urbs you want to unanchor
393 - *
394 - * use this to get rid of all an anchor's urbs
395 - */
396 -void usb_scuttle_anchored_urbs(struct usb_anchor *anchor)
397 -{
398 - struct urb *victim;
399 - unsigned long flags;
400 -
401 - spin_lock_irqsave(&anchor->lock, flags);
402 - while (!list_empty(&anchor->urb_list)) {
403 - victim = list_entry(anchor->urb_list.prev, struct urb,
404 - anchor_list);
405 - usb_get_urb(victim);
406 - spin_unlock_irqrestore(&anchor->lock, flags);
407 - /* this may free the URB */
408 - usb_unanchor_urb(victim);
409 - usb_put_urb(victim);
410 - spin_lock_irqsave(&anchor->lock, flags);
411 - }
412 - spin_unlock_irqrestore(&anchor->lock, flags);
413 -}
414 -
415 -EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs);
416 -
417 -/**
418 - * usb_anchor_empty - is an anchor empty
419 - * @anchor: the anchor you want to query
420 - *
421 - * returns 1 if the anchor has no urbs associated with it
422 - */
423 -int usb_anchor_empty(struct usb_anchor *anchor)
424 -{
425 - return list_empty(&anchor->urb_list);
426 -}
427 -
428 -EXPORT_SYMBOL_GPL(usb_anchor_empty);
429 -
430 -
431 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
432 {
433 /*
434 --- a/net/wireless/compat-2.6.29.c
435 +++ b/net/wireless/compat-2.6.29.c
436 @@ -12,29 +12,7 @@
437
438 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
439
440 -#include <linux/usb.h>
441 -
442 -/**
443 - * usb_unpoison_anchored_urbs - let an anchor be used successfully again
444 - * @anchor: anchor the requests are bound to
445 - *
446 - * Reverses the effect of usb_poison_anchored_urbs
447 - * the anchor can be used normally after it returns
448 - */
449 -void usb_unpoison_anchored_urbs(struct usb_anchor *anchor)
450 -{
451 - unsigned long flags;
452 - struct urb *lazarus;
453 -
454 - spin_lock_irqsave(&anchor->lock, flags);
455 - list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) {
456 - usb_unpoison_urb(lazarus);
457 - }
458 - //anchor->poisoned = 0; /* XXX: cannot backport */
459 - spin_unlock_irqrestore(&anchor->lock, flags);
460 -}
461 -EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs);
462 -
463 +/* 2.6.29 compat code goes here */
464
465 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */
466
467 --- a/include/net/compat-2.6.28.h
468 +++ b/include/net/compat-2.6.28.h
469 @@ -9,7 +9,6 @@
470
471 #include <linux/skbuff.h>
472 #include <linux/if_ether.h>
473 -#include <linux/usb.h>
474
475 #ifndef ETH_P_PAE
476 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
477 @@ -37,19 +36,6 @@
478 #define pcmcia_parse_tuple(tuple, parse) pccard_parse_tuple(tuple, parse)
479 #endif
480
481 -#if 0
482 -extern void usb_poison_urb(struct urb *urb);
483 -#endif
484 -extern void usb_unpoison_urb(struct urb *urb);
485 -
486 -#if 0
487 -extern void usb_poison_anchored_urbs(struct usb_anchor *anchor);
488 -#endif
489 -
490 -extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor);
491 -extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor);
492 -extern int usb_anchor_empty(struct usb_anchor *anchor);
493 -
494
495 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
496
497 --- a/include/net/compat-2.6.29.h
498 +++ b/include/net/compat-2.6.29.h
499 @@ -8,7 +8,6 @@
500 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
501
502 #include <linux/skbuff.h>
503 -#include <linux/usb.h>
504
505 /**
506 * skb_queue_is_first - check if skb is the first entry in the queue
507 @@ -41,8 +40,6 @@ static inline struct sk_buff *skb_queue_
508 return skb->prev;
509 }
510
511 -extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor);
512 -
513 #define DIV_ROUND_CLOSEST(x, divisor)( \
514 { \
515 typeof(divisor) __divisor = divisor; \
This page took 0.061481 seconds and 5 git commands to generate.