btusb.c 30 KB

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