011-move_ar9170_usb_compat_code.patch 15 KB

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