btusb.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263
  1. /*
  2. *
  3. * Generic Bluetooth USB driver
  4. *
  5. * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <linux/module.h>
  24. #include <linux/usb.h>
  25. #include <net/bluetooth/bluetooth.h>
  26. #include <net/bluetooth/hci_core.h>
  27. #define VERSION "0.6"
  28. static bool ignore_dga;
  29. static bool ignore_csr;
  30. static bool ignore_sniffer;
  31. static bool disable_scofix;
  32. static bool force_scofix;
  33. static bool reset = 1;
  34. static struct usb_driver btusb_driver;
  35. #define BTUSB_IGNORE 0x01
  36. #define BTUSB_DIGIANSWER 0x02
  37. #define BTUSB_CSR 0x04
  38. #define BTUSB_SNIFFER 0x08
  39. #define BTUSB_BCM92035 0x10
  40. #define BTUSB_BROKEN_ISOC 0x20
  41. #define BTUSB_WRONG_SCO_MTU 0x40
  42. #define BTUSB_ATH3012 0x80
  43. static struct usb_device_id btusb_table[] = {
  44. /* Generic Bluetooth USB device */
  45. { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
  46. /* Apple-specific (Broadcom) devices */
  47. { USB_VENDOR_AND_INTERFACE_INFO(0x05ac, 0xff, 0x01, 0x01) },
  48. /* Broadcom SoftSailing reporting vendor specific */
  49. { USB_DEVICE(0x0a5c, 0x21e1) },
  50. /* Apple MacBookPro 7,1 */
  51. { USB_DEVICE(0x05ac, 0x8213) },
  52. /* Apple iMac11,1 */
  53. { USB_DEVICE(0x05ac, 0x8215) },
  54. /* Apple MacBookPro6,2 */
  55. { USB_DEVICE(0x05ac, 0x8218) },
  56. /* Apple MacBookAir3,1, MacBookAir3,2 */
  57. { USB_DEVICE(0x05ac, 0x821b) },
  58. /* Apple MacBookAir4,1 */
  59. { USB_DEVICE(0x05ac, 0x821f) },
  60. /* Apple MacBookPro8,2 */
  61. { USB_DEVICE(0x05ac, 0x821a) },
  62. /* Apple MacMini5,1 */
  63. { USB_DEVICE(0x05ac, 0x8281) },
  64. /* AVM BlueFRITZ! USB v2.0 */
  65. { USB_DEVICE(0x057c, 0x3800) },
  66. /* Bluetooth Ultraport Module from IBM */
  67. { USB_DEVICE(0x04bf, 0x030a) },
  68. /* ALPS Modules with non-standard id */
  69. { USB_DEVICE(0x044e, 0x3001) },
  70. { USB_DEVICE(0x044e, 0x3002) },
  71. /* Ericsson with non-standard id */
  72. { USB_DEVICE(0x0bdb, 0x1002) },
  73. /* Canyon CN-BTU1 with HID interfaces */
  74. { USB_DEVICE(0x0c10, 0x0000) },
  75. /* Broadcom BCM20702A0 */
  76. { USB_DEVICE(0x0b05, 0x17b5) },
  77. { USB_DEVICE(0x04ca, 0x2003) },
  78. { USB_DEVICE(0x0489, 0xe042) },
  79. { USB_DEVICE(0x413c, 0x8197) },
  80. /* Foxconn - Hon Hai */
  81. { USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
  82. /*Broadcom devices with vendor specific id */
  83. { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) },
  84. { } /* Terminating entry */
  85. };
  86. MODULE_DEVICE_TABLE(usb, btusb_table);
  87. static struct usb_device_id blacklist_table[] = {
  88. /* CSR BlueCore devices */
  89. { USB_DEVICE(0x0a12, 0x0001), .driver_info = BTUSB_CSR },
  90. /* Broadcom BCM2033 without firmware */
  91. { USB_DEVICE(0x0a5c, 0x2033), .driver_info = BTUSB_IGNORE },
  92. /* Atheros 3011 with sflash firmware */
  93. { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
  94. { USB_DEVICE(0x0cf3, 0xe019), .driver_info = BTUSB_IGNORE },
  95. { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
  96. { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
  97. { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
  98. { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE },
  99. /* Atheros AR9285 Malbec with sflash firmware */
  100. { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
  101. /* Atheros 3012 with sflash firmware */
  102. { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 },
  103. { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
  104. { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
  105. { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
  106. { USB_DEVICE(0x0cf3, 0x817a), .driver_info = BTUSB_ATH3012 },
  107. { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
  108. { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
  109. { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
  110. { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
  111. { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
  112. { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
  113. { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
  114. { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
  115. { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
  116. { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
  117. { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
  118. { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
  119. { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 },
  120. /* Atheros AR5BBU12 with sflash firmware */
  121. { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
  122. /* Atheros AR5BBU12 with sflash firmware */
  123. { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
  124. { USB_DEVICE(0x0489, 0xe036), .driver_info = BTUSB_ATH3012 },
  125. /* Broadcom BCM2035 */
  126. { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
  127. { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
  128. { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
  129. /* Broadcom BCM2045 */
  130. { USB_DEVICE(0x0a5c, 0x2039), .driver_info = BTUSB_WRONG_SCO_MTU },
  131. { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_WRONG_SCO_MTU },
  132. /* IBM/Lenovo ThinkPad with Broadcom chip */
  133. { USB_DEVICE(0x0a5c, 0x201e), .driver_info = BTUSB_WRONG_SCO_MTU },
  134. { USB_DEVICE(0x0a5c, 0x2110), .driver_info = BTUSB_WRONG_SCO_MTU },
  135. /* HP laptop with Broadcom chip */
  136. { USB_DEVICE(0x03f0, 0x171d), .driver_info = BTUSB_WRONG_SCO_MTU },
  137. /* Dell laptop with Broadcom chip */
  138. { USB_DEVICE(0x413c, 0x8126), .driver_info = BTUSB_WRONG_SCO_MTU },
  139. /* Dell Wireless 370 and 410 devices */
  140. { USB_DEVICE(0x413c, 0x8152), .driver_info = BTUSB_WRONG_SCO_MTU },
  141. { USB_DEVICE(0x413c, 0x8156), .driver_info = BTUSB_WRONG_SCO_MTU },
  142. /* Belkin F8T012 and F8T013 devices */
  143. { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_WRONG_SCO_MTU },
  144. { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_WRONG_SCO_MTU },
  145. /* Asus WL-BTD202 device */
  146. { USB_DEVICE(0x0b05, 0x1715), .driver_info = BTUSB_WRONG_SCO_MTU },
  147. /* Kensington Bluetooth USB adapter */
  148. { USB_DEVICE(0x047d, 0x105e), .driver_info = BTUSB_WRONG_SCO_MTU },
  149. /* RTX Telecom based adapters with buggy SCO support */
  150. { USB_DEVICE(0x0400, 0x0807), .driver_info = BTUSB_BROKEN_ISOC },
  151. { USB_DEVICE(0x0400, 0x080a), .driver_info = BTUSB_BROKEN_ISOC },
  152. /* CONWISE Technology based adapters with buggy SCO support */
  153. { USB_DEVICE(0x0e5e, 0x6622), .driver_info = BTUSB_BROKEN_ISOC },
  154. /* Digianswer devices */
  155. { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
  156. { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE },
  157. /* CSR BlueCore Bluetooth Sniffer */
  158. { USB_DEVICE(0x0a12, 0x0002), .driver_info = BTUSB_SNIFFER },
  159. /* Frontline ComProbe Bluetooth Sniffer */
  160. { USB_DEVICE(0x16d3, 0x0002), .driver_info = BTUSB_SNIFFER },
  161. { } /* Terminating entry */
  162. };
  163. #define BTUSB_MAX_ISOC_FRAMES 10
  164. #define BTUSB_INTR_RUNNING 0
  165. #define BTUSB_BULK_RUNNING 1
  166. #define BTUSB_ISOC_RUNNING 2
  167. #define BTUSB_SUSPENDING 3
  168. #define BTUSB_DID_ISO_RESUME 4
  169. struct btusb_data {
  170. struct hci_dev *hdev;
  171. struct usb_device *udev;
  172. struct usb_interface *intf;
  173. struct usb_interface *isoc;
  174. spinlock_t lock;
  175. unsigned long flags;
  176. struct work_struct work;
  177. struct work_struct waker;
  178. struct usb_anchor tx_anchor;
  179. struct usb_anchor intr_anchor;
  180. struct usb_anchor bulk_anchor;
  181. struct usb_anchor isoc_anchor;
  182. struct usb_anchor deferred;
  183. int tx_in_flight;
  184. spinlock_t txlock;
  185. struct usb_endpoint_descriptor *intr_ep;
  186. struct usb_endpoint_descriptor *bulk_tx_ep;
  187. struct usb_endpoint_descriptor *bulk_rx_ep;
  188. struct usb_endpoint_descriptor *isoc_tx_ep;
  189. struct usb_endpoint_descriptor *isoc_rx_ep;
  190. __u8 cmdreq_type;
  191. unsigned int sco_num;
  192. int isoc_altsetting;
  193. int suspend_count;
  194. };
  195. static int inc_tx(struct btusb_data *data)
  196. {
  197. unsigned long flags;
  198. int rv;
  199. spin_lock_irqsave(&data->txlock, flags);
  200. rv = test_bit(BTUSB_SUSPENDING, &data->flags);
  201. if (!rv)
  202. data->tx_in_flight++;
  203. spin_unlock_irqrestore(&data->txlock, flags);
  204. return rv;
  205. }
  206. static void btusb_intr_complete(struct urb *urb)
  207. {
  208. struct hci_dev *hdev = urb->context;
  209. struct btusb_data *data = hci_get_drvdata(hdev);
  210. int err;
  211. BT_DBG("%s urb %p status %d count %d", hdev->name,
  212. urb, urb->status, urb->actual_length);
  213. if (!test_bit(HCI_RUNNING, &hdev->flags))
  214. return;
  215. if (urb->status == 0) {
  216. hdev->stat.byte_rx += urb->actual_length;
  217. if (hci_recv_fragment(hdev, HCI_EVENT_PKT,
  218. urb->transfer_buffer,
  219. urb->actual_length) < 0) {
  220. BT_ERR("%s corrupted event packet", hdev->name);
  221. hdev->stat.err_rx++;
  222. }
  223. }
  224. if (!test_bit(BTUSB_INTR_RUNNING, &data->flags))
  225. return;
  226. usb_mark_last_busy(data->udev);
  227. usb_anchor_urb(urb, &data->intr_anchor);
  228. err = usb_submit_urb(urb, GFP_ATOMIC);
  229. if (err < 0) {
  230. /* -EPERM: urb is being killed;
  231. * -ENODEV: device got disconnected */
  232. if (err != -EPERM && err != -ENODEV)
  233. BT_ERR("%s urb %p failed to resubmit (%d)",
  234. hdev->name, urb, -err);
  235. usb_unanchor_urb(urb);
  236. }
  237. }
  238. static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
  239. {
  240. struct btusb_data *data = hci_get_drvdata(hdev);
  241. struct urb *urb;
  242. unsigned char *buf;
  243. unsigned int pipe;
  244. int err, size;
  245. BT_DBG("%s", hdev->name);
  246. if (!data->intr_ep)
  247. return -ENODEV;
  248. urb = usb_alloc_urb(0, mem_flags);
  249. if (!urb)
  250. return -ENOMEM;
  251. size = le16_to_cpu(data->intr_ep->wMaxPacketSize);
  252. buf = kmalloc(size, mem_flags);
  253. if (!buf) {
  254. usb_free_urb(urb);
  255. return -ENOMEM;
  256. }
  257. pipe = usb_rcvintpipe(data->udev, data->intr_ep->bEndpointAddress);
  258. usb_fill_int_urb(urb, data->udev, pipe, buf, size,
  259. btusb_intr_complete, hdev,
  260. data->intr_ep->bInterval);
  261. urb->transfer_flags |= URB_FREE_BUFFER;
  262. usb_anchor_urb(urb, &data->intr_anchor);
  263. err = usb_submit_urb(urb, mem_flags);
  264. if (err < 0) {
  265. if (err != -EPERM && err != -ENODEV)
  266. BT_ERR("%s urb %p submission failed (%d)",
  267. hdev->name, urb, -err);
  268. usb_unanchor_urb(urb);
  269. }
  270. usb_free_urb(urb);
  271. return err;
  272. }
  273. static void btusb_bulk_complete(struct urb *urb)
  274. {
  275. struct hci_dev *hdev = urb->context;
  276. struct btusb_data *data = hci_get_drvdata(hdev);
  277. int err;
  278. BT_DBG("%s urb %p status %d count %d", hdev->name,
  279. urb, urb->status, urb->actual_length);
  280. if (!test_bit(HCI_RUNNING, &hdev->flags))
  281. return;
  282. if (urb->status == 0) {
  283. hdev->stat.byte_rx += urb->actual_length;
  284. if (hci_recv_fragment(hdev, HCI_ACLDATA_PKT,
  285. urb->transfer_buffer,
  286. urb->actual_length) < 0) {
  287. BT_ERR("%s corrupted ACL packet", hdev->name);
  288. hdev->stat.err_rx++;
  289. }
  290. }
  291. if (!test_bit(BTUSB_BULK_RUNNING, &data->flags))
  292. return;
  293. usb_anchor_urb(urb, &data->bulk_anchor);
  294. usb_mark_last_busy(data->udev);
  295. err = usb_submit_urb(urb, GFP_ATOMIC);
  296. if (err < 0) {
  297. /* -EPERM: urb is being killed;
  298. * -ENODEV: device got disconnected */
  299. if (err != -EPERM && err != -ENODEV)
  300. BT_ERR("%s urb %p failed to resubmit (%d)",
  301. hdev->name, urb, -err);
  302. usb_unanchor_urb(urb);
  303. }
  304. }
  305. static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
  306. {
  307. struct btusb_data *data = hci_get_drvdata(hdev);
  308. struct urb *urb;
  309. unsigned char *buf;
  310. unsigned int pipe;
  311. int err, size = HCI_MAX_FRAME_SIZE;
  312. BT_DBG("%s", hdev->name);
  313. if (!data->bulk_rx_ep)
  314. return -ENODEV;
  315. urb = usb_alloc_urb(0, mem_flags);
  316. if (!urb)
  317. return -ENOMEM;
  318. buf = kmalloc(size, mem_flags);
  319. if (!buf) {
  320. usb_free_urb(urb);
  321. return -ENOMEM;
  322. }
  323. pipe = usb_rcvbulkpipe(data->udev, data->bulk_rx_ep->bEndpointAddress);
  324. usb_fill_bulk_urb(urb, data->udev, pipe,
  325. buf, size, btusb_bulk_complete, hdev);
  326. urb->transfer_flags |= URB_FREE_BUFFER;
  327. usb_mark_last_busy(data->udev);
  328. usb_anchor_urb(urb, &data->bulk_anchor);
  329. err = usb_submit_urb(urb, mem_flags);
  330. if (err < 0) {
  331. if (err != -EPERM && err != -ENODEV)
  332. BT_ERR("%s urb %p submission failed (%d)",
  333. hdev->name, urb, -err);
  334. usb_unanchor_urb(urb);
  335. }
  336. usb_free_urb(urb);
  337. return err;
  338. }
  339. static void btusb_isoc_complete(struct urb *urb)
  340. {
  341. struct hci_dev *hdev = urb->context;
  342. struct btusb_data *data = hci_get_drvdata(hdev);
  343. int i, err;
  344. BT_DBG("%s urb %p status %d count %d", hdev->name,
  345. urb, urb->status, urb->actual_length);
  346. if (!test_bit(HCI_RUNNING, &hdev->flags))
  347. return;
  348. if (urb->status == 0) {
  349. for (i = 0; i < urb->number_of_packets; i++) {
  350. unsigned int offset = urb->iso_frame_desc[i].offset;
  351. unsigned int length = urb->iso_frame_desc[i].actual_length;
  352. if (urb->iso_frame_desc[i].status)
  353. continue;
  354. hdev->stat.byte_rx += length;
  355. if (hci_recv_fragment(hdev, HCI_SCODATA_PKT,
  356. urb->transfer_buffer + offset,
  357. length) < 0) {
  358. BT_ERR("%s corrupted SCO packet", hdev->name);
  359. hdev->stat.err_rx++;
  360. }
  361. }
  362. }
  363. if (!test_bit(BTUSB_ISOC_RUNNING, &data->flags))
  364. return;
  365. usb_anchor_urb(urb, &data->isoc_anchor);
  366. err = usb_submit_urb(urb, GFP_ATOMIC);
  367. if (err < 0) {
  368. /* -EPERM: urb is being killed;
  369. * -ENODEV: device got disconnected */
  370. if (err != -EPERM && err != -ENODEV)
  371. BT_ERR("%s urb %p failed to resubmit (%d)",
  372. hdev->name, urb, -err);
  373. usb_unanchor_urb(urb);
  374. }
  375. }
  376. static inline void __fill_isoc_descriptor(struct urb *urb, int len, int mtu)
  377. {
  378. int i, offset = 0;
  379. BT_DBG("len %d mtu %d", len, mtu);
  380. for (i = 0; i < BTUSB_MAX_ISOC_FRAMES && len >= mtu;
  381. i++, offset += mtu, len -= mtu) {
  382. urb->iso_frame_desc[i].offset = offset;
  383. urb->iso_frame_desc[i].length = mtu;
  384. }
  385. if (len && i < BTUSB_MAX_ISOC_FRAMES) {
  386. urb->iso_frame_desc[i].offset = offset;
  387. urb->iso_frame_desc[i].length = len;
  388. i++;
  389. }
  390. urb->number_of_packets = i;
  391. }
  392. static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
  393. {
  394. struct btusb_data *data = hci_get_drvdata(hdev);
  395. struct urb *urb;
  396. unsigned char *buf;
  397. unsigned int pipe;
  398. int err, size;
  399. BT_DBG("%s", hdev->name);
  400. if (!data->isoc_rx_ep)
  401. return -ENODEV;
  402. urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, mem_flags);
  403. if (!urb)
  404. return -ENOMEM;
  405. size = le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize) *
  406. BTUSB_MAX_ISOC_FRAMES;
  407. buf = kmalloc(size, mem_flags);
  408. if (!buf) {
  409. usb_free_urb(urb);
  410. return -ENOMEM;
  411. }
  412. pipe = usb_rcvisocpipe(data->udev, data->isoc_rx_ep->bEndpointAddress);
  413. usb_fill_int_urb(urb, data->udev, pipe, buf, size, btusb_isoc_complete,
  414. hdev, data->isoc_rx_ep->bInterval);
  415. urb->transfer_flags = URB_FREE_BUFFER | URB_ISO_ASAP;
  416. __fill_isoc_descriptor(urb, size,
  417. le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize));
  418. usb_anchor_urb(urb, &data->isoc_anchor);
  419. err = usb_submit_urb(urb, mem_flags);
  420. if (err < 0) {
  421. if (err != -EPERM && err != -ENODEV)
  422. BT_ERR("%s urb %p submission failed (%d)",
  423. hdev->name, urb, -err);
  424. usb_unanchor_urb(urb);
  425. }
  426. usb_free_urb(urb);
  427. return err;
  428. }
  429. static void btusb_tx_complete(struct urb *urb)
  430. {
  431. struct sk_buff *skb = urb->context;
  432. struct hci_dev *hdev = (struct hci_dev *) skb->dev;
  433. struct btusb_data *data = hci_get_drvdata(hdev);
  434. BT_DBG("%s urb %p status %d count %d", hdev->name,
  435. urb, urb->status, urb->actual_length);
  436. if (!test_bit(HCI_RUNNING, &hdev->flags))
  437. goto done;
  438. if (!urb->status)
  439. hdev->stat.byte_tx += urb->transfer_buffer_length;
  440. else
  441. hdev->stat.err_tx++;
  442. done:
  443. spin_lock(&data->txlock);
  444. data->tx_in_flight--;
  445. spin_unlock(&data->txlock);
  446. kfree(urb->setup_packet);
  447. kfree_skb(skb);
  448. }
  449. static void btusb_isoc_tx_complete(struct urb *urb)
  450. {
  451. struct sk_buff *skb = urb->context;
  452. struct hci_dev *hdev = (struct hci_dev *) skb->dev;
  453. BT_DBG("%s urb %p status %d count %d", hdev->name,
  454. urb, urb->status, urb->actual_length);
  455. if (!test_bit(HCI_RUNNING, &hdev->flags))
  456. goto done;
  457. if (!urb->status)
  458. hdev->stat.byte_tx += urb->transfer_buffer_length;
  459. else
  460. hdev->stat.err_tx++;
  461. done:
  462. kfree(urb->setup_packet);
  463. kfree_skb(skb);
  464. }
  465. static int btusb_open(struct hci_dev *hdev)
  466. {
  467. struct btusb_data *data = hci_get_drvdata(hdev);
  468. int err;
  469. BT_DBG("%s", hdev->name);
  470. err = usb_autopm_get_interface(data->intf);
  471. if (err < 0)
  472. return err;
  473. data->intf->needs_remote_wakeup = 1;
  474. if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
  475. goto done;
  476. if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags))
  477. goto done;
  478. err = btusb_submit_intr_urb(hdev, GFP_KERNEL);
  479. if (err < 0)
  480. goto failed;
  481. err = btusb_submit_bulk_urb(hdev, GFP_KERNEL);
  482. if (err < 0) {
  483. usb_kill_anchored_urbs(&data->intr_anchor);
  484. goto failed;
  485. }
  486. set_bit(BTUSB_BULK_RUNNING, &data->flags);
  487. btusb_submit_bulk_urb(hdev, GFP_KERNEL);
  488. done:
  489. usb_autopm_put_interface(data->intf);
  490. return 0;
  491. failed:
  492. clear_bit(BTUSB_INTR_RUNNING, &data->flags);
  493. clear_bit(HCI_RUNNING, &hdev->flags);
  494. usb_autopm_put_interface(data->intf);
  495. return err;
  496. }
  497. static void btusb_stop_traffic(struct btusb_data *data)
  498. {
  499. usb_kill_anchored_urbs(&data->intr_anchor);
  500. usb_kill_anchored_urbs(&data->bulk_anchor);
  501. usb_kill_anchored_urbs(&data->isoc_anchor);
  502. }
  503. static int btusb_close(struct hci_dev *hdev)
  504. {
  505. struct btusb_data *data = hci_get_drvdata(hdev);
  506. int err;
  507. BT_DBG("%s", hdev->name);
  508. if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
  509. return 0;
  510. cancel_work_sync(&data->work);
  511. cancel_work_sync(&data->waker);
  512. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  513. clear_bit(BTUSB_BULK_RUNNING, &data->flags);
  514. clear_bit(BTUSB_INTR_RUNNING, &data->flags);
  515. btusb_stop_traffic(data);
  516. err = usb_autopm_get_interface(data->intf);
  517. if (err < 0)
  518. goto failed;
  519. data->intf->needs_remote_wakeup = 0;
  520. usb_autopm_put_interface(data->intf);
  521. failed:
  522. usb_scuttle_anchored_urbs(&data->deferred);
  523. return 0;
  524. }
  525. static int btusb_flush(struct hci_dev *hdev)
  526. {
  527. struct btusb_data *data = hci_get_drvdata(hdev);
  528. BT_DBG("%s", hdev->name);
  529. usb_kill_anchored_urbs(&data->tx_anchor);
  530. return 0;
  531. }
  532. static int btusb_send_frame(struct sk_buff *skb)
  533. {
  534. struct hci_dev *hdev = (struct hci_dev *) skb->dev;
  535. struct btusb_data *data = hci_get_drvdata(hdev);
  536. struct usb_ctrlrequest *dr;
  537. struct urb *urb;
  538. unsigned int pipe;
  539. int err;
  540. BT_DBG("%s", hdev->name);
  541. if (!test_bit(HCI_RUNNING, &hdev->flags))
  542. return -EBUSY;
  543. switch (bt_cb(skb)->pkt_type) {
  544. case HCI_COMMAND_PKT:
  545. urb = usb_alloc_urb(0, GFP_ATOMIC);
  546. if (!urb)
  547. return -ENOMEM;
  548. dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
  549. if (!dr) {
  550. usb_free_urb(urb);
  551. return -ENOMEM;
  552. }
  553. dr->bRequestType = data->cmdreq_type;
  554. dr->bRequest = 0;
  555. dr->wIndex = 0;
  556. dr->wValue = 0;
  557. dr->wLength = __cpu_to_le16(skb->len);
  558. pipe = usb_sndctrlpipe(data->udev, 0x00);
  559. usb_fill_control_urb(urb, data->udev, pipe, (void *) dr,
  560. skb->data, skb->len, btusb_tx_complete, skb);
  561. hdev->stat.cmd_tx++;
  562. break;
  563. case HCI_ACLDATA_PKT:
  564. if (!data->bulk_tx_ep)
  565. return -ENODEV;
  566. urb = usb_alloc_urb(0, GFP_ATOMIC);
  567. if (!urb)
  568. return -ENOMEM;
  569. pipe = usb_sndbulkpipe(data->udev,
  570. data->bulk_tx_ep->bEndpointAddress);
  571. usb_fill_bulk_urb(urb, data->udev, pipe,
  572. skb->data, skb->len, btusb_tx_complete, skb);
  573. hdev->stat.acl_tx++;
  574. break;
  575. case HCI_SCODATA_PKT:
  576. if (!data->isoc_tx_ep || hdev->conn_hash.sco_num < 1)
  577. return -ENODEV;
  578. urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, GFP_ATOMIC);
  579. if (!urb)
  580. return -ENOMEM;
  581. pipe = usb_sndisocpipe(data->udev,
  582. data->isoc_tx_ep->bEndpointAddress);
  583. usb_fill_int_urb(urb, data->udev, pipe,
  584. skb->data, skb->len, btusb_isoc_tx_complete,
  585. skb, data->isoc_tx_ep->bInterval);
  586. urb->transfer_flags = URB_ISO_ASAP;
  587. __fill_isoc_descriptor(urb, skb->len,
  588. le16_to_cpu(data->isoc_tx_ep->wMaxPacketSize));
  589. hdev->stat.sco_tx++;
  590. goto skip_waking;
  591. default:
  592. return -EILSEQ;
  593. }
  594. err = inc_tx(data);
  595. if (err) {
  596. usb_anchor_urb(urb, &data->deferred);
  597. schedule_work(&data->waker);
  598. err = 0;
  599. goto done;
  600. }
  601. skip_waking:
  602. usb_anchor_urb(urb, &data->tx_anchor);
  603. err = usb_submit_urb(urb, GFP_ATOMIC);
  604. if (err < 0) {
  605. if (err != -EPERM && err != -ENODEV)
  606. BT_ERR("%s urb %p submission failed (%d)",
  607. hdev->name, urb, -err);
  608. kfree(urb->setup_packet);
  609. usb_unanchor_urb(urb);
  610. } else {
  611. usb_mark_last_busy(data->udev);
  612. }
  613. done:
  614. usb_free_urb(urb);
  615. return err;
  616. }
  617. static void btusb_notify(struct hci_dev *hdev, unsigned int evt)
  618. {
  619. struct btusb_data *data = hci_get_drvdata(hdev);
  620. BT_DBG("%s evt %d", hdev->name, evt);
  621. if (hdev->conn_hash.sco_num != data->sco_num) {
  622. data->sco_num = hdev->conn_hash.sco_num;
  623. schedule_work(&data->work);
  624. }
  625. }
  626. static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
  627. {
  628. struct btusb_data *data = hci_get_drvdata(hdev);
  629. struct usb_interface *intf = data->isoc;
  630. struct usb_endpoint_descriptor *ep_desc;
  631. int i, err;
  632. if (!data->isoc)
  633. return -ENODEV;
  634. err = usb_set_interface(data->udev, 1, altsetting);
  635. if (err < 0) {
  636. BT_ERR("%s setting interface failed (%d)", hdev->name, -err);
  637. return err;
  638. }
  639. data->isoc_altsetting = altsetting;
  640. data->isoc_tx_ep = NULL;
  641. data->isoc_rx_ep = NULL;
  642. for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
  643. ep_desc = &intf->cur_altsetting->endpoint[i].desc;
  644. if (!data->isoc_tx_ep && usb_endpoint_is_isoc_out(ep_desc)) {
  645. data->isoc_tx_ep = ep_desc;
  646. continue;
  647. }
  648. if (!data->isoc_rx_ep && usb_endpoint_is_isoc_in(ep_desc)) {
  649. data->isoc_rx_ep = ep_desc;
  650. continue;
  651. }
  652. }
  653. if (!data->isoc_tx_ep || !data->isoc_rx_ep) {
  654. BT_ERR("%s invalid SCO descriptors", hdev->name);
  655. return -ENODEV;
  656. }
  657. return 0;
  658. }
  659. static void btusb_work(struct work_struct *work)
  660. {
  661. struct btusb_data *data = container_of(work, struct btusb_data, work);
  662. struct hci_dev *hdev = data->hdev;
  663. int new_alts;
  664. int err;
  665. if (hdev->conn_hash.sco_num > 0) {
  666. if (!test_bit(BTUSB_DID_ISO_RESUME, &data->flags)) {
  667. err = usb_autopm_get_interface(data->isoc ? data->isoc : data->intf);
  668. if (err < 0) {
  669. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  670. usb_kill_anchored_urbs(&data->isoc_anchor);
  671. return;
  672. }
  673. set_bit(BTUSB_DID_ISO_RESUME, &data->flags);
  674. }
  675. if (hdev->voice_setting & 0x0020) {
  676. static const int alts[3] = { 2, 4, 5 };
  677. new_alts = alts[hdev->conn_hash.sco_num - 1];
  678. } else {
  679. new_alts = hdev->conn_hash.sco_num;
  680. }
  681. if (data->isoc_altsetting != new_alts) {
  682. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  683. usb_kill_anchored_urbs(&data->isoc_anchor);
  684. if (__set_isoc_interface(hdev, new_alts) < 0)
  685. return;
  686. }
  687. if (!test_and_set_bit(BTUSB_ISOC_RUNNING, &data->flags)) {
  688. if (btusb_submit_isoc_urb(hdev, GFP_KERNEL) < 0)
  689. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  690. else
  691. btusb_submit_isoc_urb(hdev, GFP_KERNEL);
  692. }
  693. } else {
  694. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  695. usb_kill_anchored_urbs(&data->isoc_anchor);
  696. __set_isoc_interface(hdev, 0);
  697. if (test_and_clear_bit(BTUSB_DID_ISO_RESUME, &data->flags))
  698. usb_autopm_put_interface(data->isoc ? data->isoc : data->intf);
  699. }
  700. }
  701. static void btusb_waker(struct work_struct *work)
  702. {
  703. struct btusb_data *data = container_of(work, struct btusb_data, waker);
  704. int err;
  705. err = usb_autopm_get_interface(data->intf);
  706. if (err < 0)
  707. return;
  708. usb_autopm_put_interface(data->intf);
  709. }
  710. static int btusb_probe(struct usb_interface *intf,
  711. const struct usb_device_id *id)
  712. {
  713. struct usb_endpoint_descriptor *ep_desc;
  714. struct btusb_data *data;
  715. struct hci_dev *hdev;
  716. int i, err;
  717. BT_DBG("intf %p id %p", intf, id);
  718. /* interface numbers are hardcoded in the spec */
  719. if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
  720. return -ENODEV;
  721. if (!id->driver_info) {
  722. const struct usb_device_id *match;
  723. match = usb_match_id(intf, blacklist_table);
  724. if (match)
  725. id = match;
  726. }
  727. if (id->driver_info == BTUSB_IGNORE)
  728. return -ENODEV;
  729. if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER)
  730. return -ENODEV;
  731. if (ignore_csr && id->driver_info & BTUSB_CSR)
  732. return -ENODEV;
  733. if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER)
  734. return -ENODEV;
  735. if (id->driver_info & BTUSB_ATH3012) {
  736. struct usb_device *udev = interface_to_usbdev(intf);
  737. /* Old firmware would otherwise let ath3k driver load
  738. * patch and sysconfig files */
  739. if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
  740. return -ENODEV;
  741. }
  742. data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
  743. if (!data)
  744. return -ENOMEM;
  745. for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
  746. ep_desc = &intf->cur_altsetting->endpoint[i].desc;
  747. if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) {
  748. data->intr_ep = ep_desc;
  749. continue;
  750. }
  751. if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) {
  752. data->bulk_tx_ep = ep_desc;
  753. continue;
  754. }
  755. if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) {
  756. data->bulk_rx_ep = ep_desc;
  757. continue;
  758. }
  759. }
  760. if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep)
  761. return -ENODEV;
  762. data->cmdreq_type = USB_TYPE_CLASS;
  763. data->udev = interface_to_usbdev(intf);
  764. data->intf = intf;
  765. spin_lock_init(&data->lock);
  766. INIT_WORK(&data->work, btusb_work);
  767. INIT_WORK(&data->waker, btusb_waker);
  768. spin_lock_init(&data->txlock);
  769. init_usb_anchor(&data->tx_anchor);
  770. init_usb_anchor(&data->intr_anchor);
  771. init_usb_anchor(&data->bulk_anchor);
  772. init_usb_anchor(&data->isoc_anchor);
  773. init_usb_anchor(&data->deferred);
  774. hdev = hci_alloc_dev();
  775. if (!hdev)
  776. return -ENOMEM;
  777. hdev->bus = HCI_USB;
  778. hci_set_drvdata(hdev, data);
  779. data->hdev = hdev;
  780. SET_HCIDEV_DEV(hdev, &intf->dev);
  781. hdev->open = btusb_open;
  782. hdev->close = btusb_close;
  783. hdev->flush = btusb_flush;
  784. hdev->send = btusb_send_frame;
  785. hdev->notify = btusb_notify;
  786. /* Interface numbers are hardcoded in the specification */
  787. data->isoc = usb_ifnum_to_if(data->udev, 1);
  788. if (!reset)
  789. set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
  790. if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) {
  791. if (!disable_scofix)
  792. set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks);
  793. }
  794. if (id->driver_info & BTUSB_BROKEN_ISOC)
  795. data->isoc = NULL;
  796. if (id->driver_info & BTUSB_DIGIANSWER) {
  797. data->cmdreq_type = USB_TYPE_VENDOR;
  798. set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
  799. }
  800. if (id->driver_info & BTUSB_CSR) {
  801. struct usb_device *udev = data->udev;
  802. /* Old firmware would otherwise execute USB reset */
  803. if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x117)
  804. set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
  805. }
  806. if (id->driver_info & BTUSB_SNIFFER) {
  807. struct usb_device *udev = data->udev;
  808. /* New sniffer firmware has crippled HCI interface */
  809. if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997)
  810. set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
  811. data->isoc = NULL;
  812. }
  813. if (id->driver_info & BTUSB_BCM92035) {
  814. unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 };
  815. struct sk_buff *skb;
  816. skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
  817. if (skb) {
  818. memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
  819. skb_queue_tail(&hdev->driver_init, skb);
  820. }
  821. }
  822. if (data->isoc) {
  823. err = usb_driver_claim_interface(&btusb_driver,
  824. data->isoc, data);
  825. if (err < 0) {
  826. hci_free_dev(hdev);
  827. return err;
  828. }
  829. }
  830. err = hci_register_dev(hdev);
  831. if (err < 0) {
  832. hci_free_dev(hdev);
  833. return err;
  834. }
  835. usb_set_intfdata(intf, data);
  836. return 0;
  837. }
  838. static void btusb_disconnect(struct usb_interface *intf)
  839. {
  840. struct btusb_data *data = usb_get_intfdata(intf);
  841. struct hci_dev *hdev;
  842. BT_DBG("intf %p", intf);
  843. if (!data)
  844. return;
  845. hdev = data->hdev;
  846. usb_set_intfdata(data->intf, NULL);
  847. if (data->isoc)
  848. usb_set_intfdata(data->isoc, NULL);
  849. hci_unregister_dev(hdev);
  850. if (intf == data->isoc)
  851. usb_driver_release_interface(&btusb_driver, data->intf);
  852. else if (data->isoc)
  853. usb_driver_release_interface(&btusb_driver, data->isoc);
  854. hci_free_dev(hdev);
  855. }
  856. #ifdef CONFIG_PM
  857. static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
  858. {
  859. struct btusb_data *data = usb_get_intfdata(intf);
  860. BT_DBG("intf %p", intf);
  861. if (data->suspend_count++)
  862. return 0;
  863. spin_lock_irq(&data->txlock);
  864. if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
  865. set_bit(BTUSB_SUSPENDING, &data->flags);
  866. spin_unlock_irq(&data->txlock);
  867. } else {
  868. spin_unlock_irq(&data->txlock);
  869. data->suspend_count--;
  870. return -EBUSY;
  871. }
  872. cancel_work_sync(&data->work);
  873. btusb_stop_traffic(data);
  874. usb_kill_anchored_urbs(&data->tx_anchor);
  875. return 0;
  876. }
  877. static void play_deferred(struct btusb_data *data)
  878. {
  879. struct urb *urb;
  880. int err;
  881. while ((urb = usb_get_from_anchor(&data->deferred))) {
  882. err = usb_submit_urb(urb, GFP_ATOMIC);
  883. if (err < 0)
  884. break;
  885. data->tx_in_flight++;
  886. }
  887. usb_scuttle_anchored_urbs(&data->deferred);
  888. }
  889. static int btusb_resume(struct usb_interface *intf)
  890. {
  891. struct btusb_data *data = usb_get_intfdata(intf);
  892. struct hci_dev *hdev = data->hdev;
  893. int err = 0;
  894. BT_DBG("intf %p", intf);
  895. if (--data->suspend_count)
  896. return 0;
  897. if (!test_bit(HCI_RUNNING, &hdev->flags))
  898. goto done;
  899. if (test_bit(BTUSB_INTR_RUNNING, &data->flags)) {
  900. err = btusb_submit_intr_urb(hdev, GFP_NOIO);
  901. if (err < 0) {
  902. clear_bit(BTUSB_INTR_RUNNING, &data->flags);
  903. goto failed;
  904. }
  905. }
  906. if (test_bit(BTUSB_BULK_RUNNING, &data->flags)) {
  907. err = btusb_submit_bulk_urb(hdev, GFP_NOIO);
  908. if (err < 0) {
  909. clear_bit(BTUSB_BULK_RUNNING, &data->flags);
  910. goto failed;
  911. }
  912. btusb_submit_bulk_urb(hdev, GFP_NOIO);
  913. }
  914. if (test_bit(BTUSB_ISOC_RUNNING, &data->flags)) {
  915. if (btusb_submit_isoc_urb(hdev, GFP_NOIO) < 0)
  916. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  917. else
  918. btusb_submit_isoc_urb(hdev, GFP_NOIO);
  919. }
  920. spin_lock_irq(&data->txlock);
  921. play_deferred(data);
  922. clear_bit(BTUSB_SUSPENDING, &data->flags);
  923. spin_unlock_irq(&data->txlock);
  924. schedule_work(&data->work);
  925. return 0;
  926. failed:
  927. usb_scuttle_anchored_urbs(&data->deferred);
  928. done:
  929. spin_lock_irq(&data->txlock);
  930. clear_bit(BTUSB_SUSPENDING, &data->flags);
  931. spin_unlock_irq(&data->txlock);
  932. return err;
  933. }
  934. #endif
  935. static struct usb_driver btusb_driver = {
  936. .name = "btusb",
  937. .probe = btusb_probe,
  938. .disconnect = btusb_disconnect,
  939. #ifdef CONFIG_PM
  940. .suspend = btusb_suspend,
  941. .resume = btusb_resume,
  942. #endif
  943. .id_table = btusb_table,
  944. .supports_autosuspend = 1,
  945. .disable_hub_initiated_lpm = 1,
  946. };
  947. module_usb_driver(btusb_driver);
  948. module_param(ignore_dga, bool, 0644);
  949. MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001");
  950. module_param(ignore_csr, bool, 0644);
  951. MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001");
  952. module_param(ignore_sniffer, bool, 0644);
  953. MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002");
  954. module_param(disable_scofix, bool, 0644);
  955. MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size");
  956. module_param(force_scofix, bool, 0644);
  957. MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size");
  958. module_param(reset, bool, 0644);
  959. MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
  960. MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
  961. MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION);
  962. MODULE_VERSION(VERSION);
  963. MODULE_LICENSE("GPL");