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