Bluetooth: Add support for Toshiba Bluetooth device [0930:0220]
[pandora-kernel.git] / drivers / bluetooth / btusb.c
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
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/init.h>
27 #include <linux/slab.h>
28 #include <linux/types.h>
29 #include <linux/sched.h>
30 #include <linux/errno.h>
31 #include <linux/skbuff.h>
32
33 #include <linux/usb.h>
34
35 #include <net/bluetooth/bluetooth.h>
36 #include <net/bluetooth/hci_core.h>
37
38 #define VERSION "0.6"
39
40 static int ignore_dga;
41 static int ignore_csr;
42 static int ignore_sniffer;
43 static int disable_scofix;
44 static int force_scofix;
45
46 static int reset = 1;
47
48 static struct usb_driver btusb_driver;
49
50 #define BTUSB_IGNORE            0x01
51 #define BTUSB_DIGIANSWER        0x02
52 #define BTUSB_CSR               0x04
53 #define BTUSB_SNIFFER           0x08
54 #define BTUSB_BCM92035          0x10
55 #define BTUSB_BROKEN_ISOC       0x20
56 #define BTUSB_WRONG_SCO_MTU     0x40
57 #define BTUSB_ATH3012           0x80
58
59 static struct usb_device_id btusb_table[] = {
60         /* Generic Bluetooth USB device */
61         { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
62
63         /* Apple-specific (Broadcom) devices */
64         { USB_VENDOR_AND_INTERFACE_INFO(0x05ac, 0xff, 0x01, 0x01) },
65
66         /* MediaTek MT76x0E */
67         { USB_DEVICE(0x0e8d, 0x763f) },
68
69         /* Broadcom SoftSailing reporting vendor specific */
70         { USB_DEVICE(0x0a5c, 0x21e1) },
71
72         /* Apple MacBookPro 7,1 */
73         { USB_DEVICE(0x05ac, 0x8213) },
74
75         /* Apple iMac11,1 */
76         { USB_DEVICE(0x05ac, 0x8215) },
77
78         /* Apple MacBookPro6,2 */
79         { USB_DEVICE(0x05ac, 0x8218) },
80
81         /* Apple MacBookAir3,1, MacBookAir3,2 */
82         { USB_DEVICE(0x05ac, 0x821b) },
83
84         /* Apple MacBookAir4,1 */
85         { USB_DEVICE(0x05ac, 0x821f) },
86
87         /* Apple MacBookPro8,2 */
88         { USB_DEVICE(0x05ac, 0x821a) },
89
90         /* Apple MacMini5,1 */
91         { USB_DEVICE(0x05ac, 0x8281) },
92
93         /* AVM BlueFRITZ! USB v2.0 */
94         { USB_DEVICE(0x057c, 0x3800) },
95
96         /* Bluetooth Ultraport Module from IBM */
97         { USB_DEVICE(0x04bf, 0x030a) },
98
99         /* ALPS Modules with non-standard id */
100         { USB_DEVICE(0x044e, 0x3001) },
101         { USB_DEVICE(0x044e, 0x3002) },
102
103         /* Ericsson with non-standard id */
104         { USB_DEVICE(0x0bdb, 0x1002) },
105
106         /* Canyon CN-BTU1 with HID interfaces */
107         { USB_DEVICE(0x0c10, 0x0000) },
108
109         /* Broadcom BCM20702A0 */
110         { USB_DEVICE(0x0b05, 0x17b5) },
111         { USB_DEVICE(0x0b05, 0x17cb) },
112         { USB_DEVICE(0x04ca, 0x2003) },
113         { USB_DEVICE(0x0489, 0xe042) },
114         { USB_DEVICE(0x413c, 0x8197) },
115
116         /* Foxconn - Hon Hai */
117         { USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
118
119         /*Broadcom devices with vendor specific id */
120         { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) },
121
122         /* Belkin F8065bf - Broadcom based */
123         { USB_VENDOR_AND_INTERFACE_INFO(0x050d, 0xff, 0x01, 0x01) },
124
125         { }     /* Terminating entry */
126 };
127
128 MODULE_DEVICE_TABLE(usb, btusb_table);
129
130 static struct usb_device_id blacklist_table[] = {
131         /* CSR BlueCore devices */
132         { USB_DEVICE(0x0a12, 0x0001), .driver_info = BTUSB_CSR },
133
134         /* Broadcom BCM2033 without firmware */
135         { USB_DEVICE(0x0a5c, 0x2033), .driver_info = BTUSB_IGNORE },
136
137         /* Atheros 3011 with sflash firmware */
138         { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
139         { USB_DEVICE(0x0cf3, 0xe019), .driver_info = BTUSB_IGNORE },
140         { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
141         { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
142         { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
143         { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE },
144
145         /* Atheros AR9285 Malbec with sflash firmware */
146         { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
147
148         /* Atheros 3012 with sflash firmware */
149         { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 },
150         { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
151         { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
152         { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
153         { USB_DEVICE(0x0cf3, 0x817a), .driver_info = BTUSB_ATH3012 },
154         { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
155         { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
156         { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
157         { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
158         { USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 },
159         { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
160         { USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
161         { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
162         { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
163         { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
164         { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
165         { USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 },
166         { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
167         { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
168         { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
169         { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
170         { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 },
171         { USB_DEVICE(0x04c5, 0x1330), .driver_info = BTUSB_ATH3012 },
172         { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 },
173         { USB_DEVICE(0x0cf3, 0x3121), .driver_info = BTUSB_ATH3012 },
174         { USB_DEVICE(0x0cf3, 0xe003), .driver_info = BTUSB_ATH3012 },
175         { USB_DEVICE(0x0489, 0xe05f), .driver_info = BTUSB_ATH3012 },
176
177         /* Atheros AR5BBU12 with sflash firmware */
178         { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
179
180         /* Atheros AR5BBU12 with sflash firmware */
181         { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
182         { USB_DEVICE(0x0489, 0xe036), .driver_info = BTUSB_ATH3012 },
183
184         /* Broadcom BCM2035 */
185         { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
186         { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
187         { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
188
189         /* Broadcom BCM2045 */
190         { USB_DEVICE(0x0a5c, 0x2039), .driver_info = BTUSB_WRONG_SCO_MTU },
191         { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_WRONG_SCO_MTU },
192
193         /* IBM/Lenovo ThinkPad with Broadcom chip */
194         { USB_DEVICE(0x0a5c, 0x201e), .driver_info = BTUSB_WRONG_SCO_MTU },
195         { USB_DEVICE(0x0a5c, 0x2110), .driver_info = BTUSB_WRONG_SCO_MTU },
196
197         /* HP laptop with Broadcom chip */
198         { USB_DEVICE(0x03f0, 0x171d), .driver_info = BTUSB_WRONG_SCO_MTU },
199
200         /* Dell laptop with Broadcom chip */
201         { USB_DEVICE(0x413c, 0x8126), .driver_info = BTUSB_WRONG_SCO_MTU },
202
203         /* Dell Wireless 370 and 410 devices */
204         { USB_DEVICE(0x413c, 0x8152), .driver_info = BTUSB_WRONG_SCO_MTU },
205         { USB_DEVICE(0x413c, 0x8156), .driver_info = BTUSB_WRONG_SCO_MTU },
206
207         /* Belkin F8T012 and F8T013 devices */
208         { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_WRONG_SCO_MTU },
209         { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_WRONG_SCO_MTU },
210
211         /* Asus WL-BTD202 device */
212         { USB_DEVICE(0x0b05, 0x1715), .driver_info = BTUSB_WRONG_SCO_MTU },
213
214         /* Kensington Bluetooth USB adapter */
215         { USB_DEVICE(0x047d, 0x105e), .driver_info = BTUSB_WRONG_SCO_MTU },
216
217         /* RTX Telecom based adapters with buggy SCO support */
218         { USB_DEVICE(0x0400, 0x0807), .driver_info = BTUSB_BROKEN_ISOC },
219         { USB_DEVICE(0x0400, 0x080a), .driver_info = BTUSB_BROKEN_ISOC },
220
221         /* CONWISE Technology based adapters with buggy SCO support */
222         { USB_DEVICE(0x0e5e, 0x6622), .driver_info = BTUSB_BROKEN_ISOC },
223
224         /* Digianswer devices */
225         { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
226         { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE },
227
228         /* CSR BlueCore Bluetooth Sniffer */
229         { USB_DEVICE(0x0a12, 0x0002), .driver_info = BTUSB_SNIFFER },
230
231         /* Frontline ComProbe Bluetooth Sniffer */
232         { USB_DEVICE(0x16d3, 0x0002), .driver_info = BTUSB_SNIFFER },
233
234         { }     /* Terminating entry */
235 };
236
237 #define BTUSB_MAX_ISOC_FRAMES   10
238
239 #define BTUSB_INTR_RUNNING      0
240 #define BTUSB_BULK_RUNNING      1
241 #define BTUSB_ISOC_RUNNING      2
242 #define BTUSB_SUSPENDING        3
243 #define BTUSB_DID_ISO_RESUME    4
244
245 struct btusb_data {
246         struct hci_dev       *hdev;
247         struct usb_device    *udev;
248         struct usb_interface *intf;
249         struct usb_interface *isoc;
250
251         spinlock_t lock;
252
253         unsigned long flags;
254
255         struct work_struct work;
256         struct work_struct waker;
257
258         struct usb_anchor tx_anchor;
259         struct usb_anchor intr_anchor;
260         struct usb_anchor bulk_anchor;
261         struct usb_anchor isoc_anchor;
262         struct usb_anchor deferred;
263         int tx_in_flight;
264         spinlock_t txlock;
265
266         struct usb_endpoint_descriptor *intr_ep;
267         struct usb_endpoint_descriptor *bulk_tx_ep;
268         struct usb_endpoint_descriptor *bulk_rx_ep;
269         struct usb_endpoint_descriptor *isoc_tx_ep;
270         struct usb_endpoint_descriptor *isoc_rx_ep;
271
272         __u8 cmdreq_type;
273
274         unsigned int sco_num;
275         int isoc_altsetting;
276         int suspend_count;
277 };
278
279 static int inc_tx(struct btusb_data *data)
280 {
281         unsigned long flags;
282         int rv;
283
284         spin_lock_irqsave(&data->txlock, flags);
285         rv = test_bit(BTUSB_SUSPENDING, &data->flags);
286         if (!rv)
287                 data->tx_in_flight++;
288         spin_unlock_irqrestore(&data->txlock, flags);
289
290         return rv;
291 }
292
293 static void btusb_intr_complete(struct urb *urb)
294 {
295         struct hci_dev *hdev = urb->context;
296         struct btusb_data *data = hdev->driver_data;
297         int err;
298
299         BT_DBG("%s urb %p status %d count %d", hdev->name,
300                                         urb, urb->status, urb->actual_length);
301
302         if (!test_bit(HCI_RUNNING, &hdev->flags))
303                 return;
304
305         if (urb->status == 0) {
306                 hdev->stat.byte_rx += urb->actual_length;
307
308                 if (hci_recv_fragment(hdev, HCI_EVENT_PKT,
309                                                 urb->transfer_buffer,
310                                                 urb->actual_length) < 0) {
311                         BT_ERR("%s corrupted event packet", hdev->name);
312                         hdev->stat.err_rx++;
313                 }
314         } else if (urb->status == -ENOENT) {
315                 /* Avoid suspend failed when usb_kill_urb */
316                 return;
317         }
318
319         if (!test_bit(BTUSB_INTR_RUNNING, &data->flags))
320                 return;
321
322         usb_mark_last_busy(data->udev);
323         usb_anchor_urb(urb, &data->intr_anchor);
324
325         err = usb_submit_urb(urb, GFP_ATOMIC);
326         if (err < 0) {
327                 /* -EPERM: urb is being killed;
328                  * -ENODEV: device got disconnected */
329                 if (err != -EPERM && err != -ENODEV)
330                         BT_ERR("%s urb %p failed to resubmit (%d)",
331                                                 hdev->name, urb, -err);
332                 usb_unanchor_urb(urb);
333         }
334 }
335
336 static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
337 {
338         struct btusb_data *data = hdev->driver_data;
339         struct urb *urb;
340         unsigned char *buf;
341         unsigned int pipe;
342         int err, size;
343
344         BT_DBG("%s", hdev->name);
345
346         if (!data->intr_ep)
347                 return -ENODEV;
348
349         urb = usb_alloc_urb(0, mem_flags);
350         if (!urb)
351                 return -ENOMEM;
352
353         size = le16_to_cpu(data->intr_ep->wMaxPacketSize);
354
355         buf = kmalloc(size, mem_flags);
356         if (!buf) {
357                 usb_free_urb(urb);
358                 return -ENOMEM;
359         }
360
361         pipe = usb_rcvintpipe(data->udev, data->intr_ep->bEndpointAddress);
362
363         usb_fill_int_urb(urb, data->udev, pipe, buf, size,
364                                                 btusb_intr_complete, hdev,
365                                                 data->intr_ep->bInterval);
366
367         urb->transfer_flags |= URB_FREE_BUFFER;
368
369         usb_anchor_urb(urb, &data->intr_anchor);
370
371         err = usb_submit_urb(urb, mem_flags);
372         if (err < 0) {
373                 BT_ERR("%s urb %p submission failed (%d)",
374                                                 hdev->name, urb, -err);
375                 usb_unanchor_urb(urb);
376         }
377
378         usb_free_urb(urb);
379
380         return err;
381 }
382
383 static void btusb_bulk_complete(struct urb *urb)
384 {
385         struct hci_dev *hdev = urb->context;
386         struct btusb_data *data = hdev->driver_data;
387         int err;
388
389         BT_DBG("%s urb %p status %d count %d", hdev->name,
390                                         urb, urb->status, urb->actual_length);
391
392         if (!test_bit(HCI_RUNNING, &hdev->flags))
393                 return;
394
395         if (urb->status == 0) {
396                 hdev->stat.byte_rx += urb->actual_length;
397
398                 if (hci_recv_fragment(hdev, HCI_ACLDATA_PKT,
399                                                 urb->transfer_buffer,
400                                                 urb->actual_length) < 0) {
401                         BT_ERR("%s corrupted ACL packet", hdev->name);
402                         hdev->stat.err_rx++;
403                 }
404         } else if (urb->status == -ENOENT) {
405                 /* Avoid suspend failed when usb_kill_urb */
406                 return;
407         }
408
409         if (!test_bit(BTUSB_BULK_RUNNING, &data->flags))
410                 return;
411
412         usb_anchor_urb(urb, &data->bulk_anchor);
413         usb_mark_last_busy(data->udev);
414
415         err = usb_submit_urb(urb, GFP_ATOMIC);
416         if (err < 0) {
417                 /* -EPERM: urb is being killed;
418                  * -ENODEV: device got disconnected */
419                 if (err != -EPERM && err != -ENODEV)
420                         BT_ERR("%s urb %p failed to resubmit (%d)",
421                                                 hdev->name, urb, -err);
422                 usb_unanchor_urb(urb);
423         }
424 }
425
426 static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
427 {
428         struct btusb_data *data = hdev->driver_data;
429         struct urb *urb;
430         unsigned char *buf;
431         unsigned int pipe;
432         int err, size = HCI_MAX_FRAME_SIZE;
433
434         BT_DBG("%s", hdev->name);
435
436         if (!data->bulk_rx_ep)
437                 return -ENODEV;
438
439         urb = usb_alloc_urb(0, mem_flags);
440         if (!urb)
441                 return -ENOMEM;
442
443         buf = kmalloc(size, mem_flags);
444         if (!buf) {
445                 usb_free_urb(urb);
446                 return -ENOMEM;
447         }
448
449         pipe = usb_rcvbulkpipe(data->udev, data->bulk_rx_ep->bEndpointAddress);
450
451         usb_fill_bulk_urb(urb, data->udev, pipe,
452                                         buf, size, btusb_bulk_complete, hdev);
453
454         urb->transfer_flags |= URB_FREE_BUFFER;
455
456         usb_mark_last_busy(data->udev);
457         usb_anchor_urb(urb, &data->bulk_anchor);
458
459         err = usb_submit_urb(urb, mem_flags);
460         if (err < 0) {
461                 BT_ERR("%s urb %p submission failed (%d)",
462                                                 hdev->name, urb, -err);
463                 usb_unanchor_urb(urb);
464         }
465
466         usb_free_urb(urb);
467
468         return err;
469 }
470
471 static void btusb_isoc_complete(struct urb *urb)
472 {
473         struct hci_dev *hdev = urb->context;
474         struct btusb_data *data = hdev->driver_data;
475         int i, err;
476
477         BT_DBG("%s urb %p status %d count %d", hdev->name,
478                                         urb, urb->status, urb->actual_length);
479
480         if (!test_bit(HCI_RUNNING, &hdev->flags))
481                 return;
482
483         if (urb->status == 0) {
484                 for (i = 0; i < urb->number_of_packets; i++) {
485                         unsigned int offset = urb->iso_frame_desc[i].offset;
486                         unsigned int length = urb->iso_frame_desc[i].actual_length;
487
488                         if (urb->iso_frame_desc[i].status)
489                                 continue;
490
491                         hdev->stat.byte_rx += length;
492
493                         if (hci_recv_fragment(hdev, HCI_SCODATA_PKT,
494                                                 urb->transfer_buffer + offset,
495                                                                 length) < 0) {
496                                 BT_ERR("%s corrupted SCO packet", hdev->name);
497                                 hdev->stat.err_rx++;
498                         }
499                 }
500         } else if (urb->status == -ENOENT) {
501                 /* Avoid suspend failed when usb_kill_urb */
502                 return;
503         }
504
505         if (!test_bit(BTUSB_ISOC_RUNNING, &data->flags))
506                 return;
507
508         usb_anchor_urb(urb, &data->isoc_anchor);
509
510         err = usb_submit_urb(urb, GFP_ATOMIC);
511         if (err < 0) {
512                 /* -EPERM: urb is being killed;
513                  * -ENODEV: device got disconnected */
514                 if (err != -EPERM && err != -ENODEV)
515                         BT_ERR("%s urb %p failed to resubmit (%d)",
516                                                 hdev->name, urb, -err);
517                 usb_unanchor_urb(urb);
518         }
519 }
520
521 static inline void __fill_isoc_descriptor(struct urb *urb, int len, int mtu)
522 {
523         int i, offset = 0;
524
525         BT_DBG("len %d mtu %d", len, mtu);
526
527         for (i = 0; i < BTUSB_MAX_ISOC_FRAMES && len >= mtu;
528                                         i++, offset += mtu, len -= mtu) {
529                 urb->iso_frame_desc[i].offset = offset;
530                 urb->iso_frame_desc[i].length = mtu;
531         }
532
533         if (len && i < BTUSB_MAX_ISOC_FRAMES) {
534                 urb->iso_frame_desc[i].offset = offset;
535                 urb->iso_frame_desc[i].length = len;
536                 i++;
537         }
538
539         urb->number_of_packets = i;
540 }
541
542 static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
543 {
544         struct btusb_data *data = hdev->driver_data;
545         struct urb *urb;
546         unsigned char *buf;
547         unsigned int pipe;
548         int err, size;
549
550         BT_DBG("%s", hdev->name);
551
552         if (!data->isoc_rx_ep)
553                 return -ENODEV;
554
555         urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, mem_flags);
556         if (!urb)
557                 return -ENOMEM;
558
559         size = le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize) *
560                                                 BTUSB_MAX_ISOC_FRAMES;
561
562         buf = kmalloc(size, mem_flags);
563         if (!buf) {
564                 usb_free_urb(urb);
565                 return -ENOMEM;
566         }
567
568         pipe = usb_rcvisocpipe(data->udev, data->isoc_rx_ep->bEndpointAddress);
569
570         usb_fill_int_urb(urb, data->udev, pipe, buf, size, btusb_isoc_complete,
571                                 hdev, data->isoc_rx_ep->bInterval);
572
573         urb->transfer_flags  = URB_FREE_BUFFER | URB_ISO_ASAP;
574
575         __fill_isoc_descriptor(urb, size,
576                         le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize));
577
578         usb_anchor_urb(urb, &data->isoc_anchor);
579
580         err = usb_submit_urb(urb, mem_flags);
581         if (err < 0) {
582                 BT_ERR("%s urb %p submission failed (%d)",
583                                                 hdev->name, urb, -err);
584                 usb_unanchor_urb(urb);
585         }
586
587         usb_free_urb(urb);
588
589         return err;
590 }
591
592 static void btusb_tx_complete(struct urb *urb)
593 {
594         struct sk_buff *skb = urb->context;
595         struct hci_dev *hdev = (struct hci_dev *) skb->dev;
596         struct btusb_data *data = hdev->driver_data;
597
598         BT_DBG("%s urb %p status %d count %d", hdev->name,
599                                         urb, urb->status, urb->actual_length);
600
601         if (!test_bit(HCI_RUNNING, &hdev->flags))
602                 goto done;
603
604         if (!urb->status)
605                 hdev->stat.byte_tx += urb->transfer_buffer_length;
606         else
607                 hdev->stat.err_tx++;
608
609 done:
610         spin_lock(&data->txlock);
611         data->tx_in_flight--;
612         spin_unlock(&data->txlock);
613
614         kfree(urb->setup_packet);
615
616         kfree_skb(skb);
617 }
618
619 static void btusb_isoc_tx_complete(struct urb *urb)
620 {
621         struct sk_buff *skb = urb->context;
622         struct hci_dev *hdev = (struct hci_dev *) skb->dev;
623
624         BT_DBG("%s urb %p status %d count %d", hdev->name,
625                                         urb, urb->status, urb->actual_length);
626
627         if (!test_bit(HCI_RUNNING, &hdev->flags))
628                 goto done;
629
630         if (!urb->status)
631                 hdev->stat.byte_tx += urb->transfer_buffer_length;
632         else
633                 hdev->stat.err_tx++;
634
635 done:
636         kfree(urb->setup_packet);
637
638         kfree_skb(skb);
639 }
640
641 static int btusb_open(struct hci_dev *hdev)
642 {
643         struct btusb_data *data = hdev->driver_data;
644         int err;
645
646         BT_DBG("%s", hdev->name);
647
648         err = usb_autopm_get_interface(data->intf);
649         if (err < 0)
650                 return err;
651
652         data->intf->needs_remote_wakeup = 1;
653
654         if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
655                 goto done;
656
657         if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags))
658                 goto done;
659
660         err = btusb_submit_intr_urb(hdev, GFP_KERNEL);
661         if (err < 0)
662                 goto failed;
663
664         err = btusb_submit_bulk_urb(hdev, GFP_KERNEL);
665         if (err < 0) {
666                 usb_kill_anchored_urbs(&data->intr_anchor);
667                 goto failed;
668         }
669
670         set_bit(BTUSB_BULK_RUNNING, &data->flags);
671         btusb_submit_bulk_urb(hdev, GFP_KERNEL);
672
673 done:
674         usb_autopm_put_interface(data->intf);
675         return 0;
676
677 failed:
678         clear_bit(BTUSB_INTR_RUNNING, &data->flags);
679         clear_bit(HCI_RUNNING, &hdev->flags);
680         usb_autopm_put_interface(data->intf);
681         return err;
682 }
683
684 static void btusb_stop_traffic(struct btusb_data *data)
685 {
686         usb_kill_anchored_urbs(&data->intr_anchor);
687         usb_kill_anchored_urbs(&data->bulk_anchor);
688         usb_kill_anchored_urbs(&data->isoc_anchor);
689 }
690
691 static int btusb_close(struct hci_dev *hdev)
692 {
693         struct btusb_data *data = hdev->driver_data;
694         int err;
695
696         BT_DBG("%s", hdev->name);
697
698         if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
699                 return 0;
700
701         cancel_work_sync(&data->work);
702         cancel_work_sync(&data->waker);
703
704         clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
705         clear_bit(BTUSB_BULK_RUNNING, &data->flags);
706         clear_bit(BTUSB_INTR_RUNNING, &data->flags);
707
708         btusb_stop_traffic(data);
709         err = usb_autopm_get_interface(data->intf);
710         if (err < 0)
711                 goto failed;
712
713         data->intf->needs_remote_wakeup = 0;
714         usb_autopm_put_interface(data->intf);
715
716 failed:
717         usb_scuttle_anchored_urbs(&data->deferred);
718         return 0;
719 }
720
721 static int btusb_flush(struct hci_dev *hdev)
722 {
723         struct btusb_data *data = hdev->driver_data;
724
725         BT_DBG("%s", hdev->name);
726
727         usb_kill_anchored_urbs(&data->tx_anchor);
728
729         return 0;
730 }
731
732 static int btusb_send_frame(struct sk_buff *skb)
733 {
734         struct hci_dev *hdev = (struct hci_dev *) skb->dev;
735         struct btusb_data *data = hdev->driver_data;
736         struct usb_ctrlrequest *dr;
737         struct urb *urb;
738         unsigned int pipe;
739         int err;
740
741         BT_DBG("%s", hdev->name);
742
743         if (!test_bit(HCI_RUNNING, &hdev->flags))
744                 return -EBUSY;
745
746         switch (bt_cb(skb)->pkt_type) {
747         case HCI_COMMAND_PKT:
748                 urb = usb_alloc_urb(0, GFP_ATOMIC);
749                 if (!urb)
750                         return -ENOMEM;
751
752                 dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
753                 if (!dr) {
754                         usb_free_urb(urb);
755                         return -ENOMEM;
756                 }
757
758                 dr->bRequestType = data->cmdreq_type;
759                 dr->bRequest     = 0;
760                 dr->wIndex       = 0;
761                 dr->wValue       = 0;
762                 dr->wLength      = __cpu_to_le16(skb->len);
763
764                 pipe = usb_sndctrlpipe(data->udev, 0x00);
765
766                 usb_fill_control_urb(urb, data->udev, pipe, (void *) dr,
767                                 skb->data, skb->len, btusb_tx_complete, skb);
768
769                 hdev->stat.cmd_tx++;
770                 break;
771
772         case HCI_ACLDATA_PKT:
773                 if (!data->bulk_tx_ep)
774                         return -ENODEV;
775
776                 urb = usb_alloc_urb(0, GFP_ATOMIC);
777                 if (!urb)
778                         return -ENOMEM;
779
780                 pipe = usb_sndbulkpipe(data->udev,
781                                         data->bulk_tx_ep->bEndpointAddress);
782
783                 usb_fill_bulk_urb(urb, data->udev, pipe,
784                                 skb->data, skb->len, btusb_tx_complete, skb);
785
786                 hdev->stat.acl_tx++;
787                 break;
788
789         case HCI_SCODATA_PKT:
790                 if (!data->isoc_tx_ep || hdev->conn_hash.sco_num < 1)
791                         return -ENODEV;
792
793                 urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, GFP_ATOMIC);
794                 if (!urb)
795                         return -ENOMEM;
796
797                 pipe = usb_sndisocpipe(data->udev,
798                                         data->isoc_tx_ep->bEndpointAddress);
799
800                 usb_fill_int_urb(urb, data->udev, pipe,
801                                 skb->data, skb->len, btusb_isoc_tx_complete,
802                                 skb, data->isoc_tx_ep->bInterval);
803
804                 urb->transfer_flags  = URB_ISO_ASAP;
805
806                 __fill_isoc_descriptor(urb, skb->len,
807                                 le16_to_cpu(data->isoc_tx_ep->wMaxPacketSize));
808
809                 hdev->stat.sco_tx++;
810                 goto skip_waking;
811
812         default:
813                 return -EILSEQ;
814         }
815
816         err = inc_tx(data);
817         if (err) {
818                 usb_anchor_urb(urb, &data->deferred);
819                 schedule_work(&data->waker);
820                 err = 0;
821                 goto done;
822         }
823
824 skip_waking:
825         usb_anchor_urb(urb, &data->tx_anchor);
826
827         err = usb_submit_urb(urb, GFP_ATOMIC);
828         if (err < 0) {
829                 BT_ERR("%s urb %p submission failed", hdev->name, urb);
830                 kfree(urb->setup_packet);
831                 usb_unanchor_urb(urb);
832         } else {
833                 usb_mark_last_busy(data->udev);
834         }
835
836 done:
837         usb_free_urb(urb);
838         return err;
839 }
840
841 static void btusb_destruct(struct hci_dev *hdev)
842 {
843         struct btusb_data *data = hdev->driver_data;
844
845         BT_DBG("%s", hdev->name);
846
847         kfree(data);
848 }
849
850 static void btusb_notify(struct hci_dev *hdev, unsigned int evt)
851 {
852         struct btusb_data *data = hdev->driver_data;
853
854         BT_DBG("%s evt %d", hdev->name, evt);
855
856         if (hdev->conn_hash.sco_num != data->sco_num) {
857                 data->sco_num = hdev->conn_hash.sco_num;
858                 schedule_work(&data->work);
859         }
860 }
861
862 static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
863 {
864         struct btusb_data *data = hdev->driver_data;
865         struct usb_interface *intf = data->isoc;
866         struct usb_endpoint_descriptor *ep_desc;
867         int i, err;
868
869         if (!data->isoc)
870                 return -ENODEV;
871
872         err = usb_set_interface(data->udev, 1, altsetting);
873         if (err < 0) {
874                 BT_ERR("%s setting interface failed (%d)", hdev->name, -err);
875                 return err;
876         }
877
878         data->isoc_altsetting = altsetting;
879
880         data->isoc_tx_ep = NULL;
881         data->isoc_rx_ep = NULL;
882
883         for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
884                 ep_desc = &intf->cur_altsetting->endpoint[i].desc;
885
886                 if (!data->isoc_tx_ep && usb_endpoint_is_isoc_out(ep_desc)) {
887                         data->isoc_tx_ep = ep_desc;
888                         continue;
889                 }
890
891                 if (!data->isoc_rx_ep && usb_endpoint_is_isoc_in(ep_desc)) {
892                         data->isoc_rx_ep = ep_desc;
893                         continue;
894                 }
895         }
896
897         if (!data->isoc_tx_ep || !data->isoc_rx_ep) {
898                 BT_ERR("%s invalid SCO descriptors", hdev->name);
899                 return -ENODEV;
900         }
901
902         return 0;
903 }
904
905 static void btusb_work(struct work_struct *work)
906 {
907         struct btusb_data *data = container_of(work, struct btusb_data, work);
908         struct hci_dev *hdev = data->hdev;
909         int err;
910
911         if (hdev->conn_hash.sco_num > 0) {
912                 if (!test_bit(BTUSB_DID_ISO_RESUME, &data->flags)) {
913                         err = usb_autopm_get_interface(data->isoc ? data->isoc : data->intf);
914                         if (err < 0) {
915                                 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
916                                 usb_kill_anchored_urbs(&data->isoc_anchor);
917                                 return;
918                         }
919
920                         set_bit(BTUSB_DID_ISO_RESUME, &data->flags);
921                 }
922                 if (data->isoc_altsetting != 2) {
923                         clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
924                         usb_kill_anchored_urbs(&data->isoc_anchor);
925
926                         if (__set_isoc_interface(hdev, 2) < 0)
927                                 return;
928                 }
929
930                 if (!test_and_set_bit(BTUSB_ISOC_RUNNING, &data->flags)) {
931                         if (btusb_submit_isoc_urb(hdev, GFP_KERNEL) < 0)
932                                 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
933                         else
934                                 btusb_submit_isoc_urb(hdev, GFP_KERNEL);
935                 }
936         } else {
937                 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
938                 usb_kill_anchored_urbs(&data->isoc_anchor);
939
940                 __set_isoc_interface(hdev, 0);
941                 if (test_and_clear_bit(BTUSB_DID_ISO_RESUME, &data->flags))
942                         usb_autopm_put_interface(data->isoc ? data->isoc : data->intf);
943         }
944 }
945
946 static void btusb_waker(struct work_struct *work)
947 {
948         struct btusb_data *data = container_of(work, struct btusb_data, waker);
949         int err;
950
951         err = usb_autopm_get_interface(data->intf);
952         if (err < 0)
953                 return;
954
955         usb_autopm_put_interface(data->intf);
956 }
957
958 static int btusb_probe(struct usb_interface *intf,
959                                 const struct usb_device_id *id)
960 {
961         struct usb_endpoint_descriptor *ep_desc;
962         struct btusb_data *data;
963         struct hci_dev *hdev;
964         int i, err;
965
966         BT_DBG("intf %p id %p", intf, id);
967
968         /* interface numbers are hardcoded in the spec */
969         if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
970                 return -ENODEV;
971
972         if (!id->driver_info) {
973                 const struct usb_device_id *match;
974                 match = usb_match_id(intf, blacklist_table);
975                 if (match)
976                         id = match;
977         }
978
979         if (id->driver_info == BTUSB_IGNORE)
980                 return -ENODEV;
981
982         if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER)
983                 return -ENODEV;
984
985         if (ignore_csr && id->driver_info & BTUSB_CSR)
986                 return -ENODEV;
987
988         if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER)
989                 return -ENODEV;
990
991         if (id->driver_info & BTUSB_ATH3012) {
992                 struct usb_device *udev = interface_to_usbdev(intf);
993
994                 /* Old firmware would otherwise let ath3k driver load
995                  * patch and sysconfig files */
996                 if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
997                         return -ENODEV;
998         }
999
1000         data = kzalloc(sizeof(*data), GFP_KERNEL);
1001         if (!data)
1002                 return -ENOMEM;
1003
1004         for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
1005                 ep_desc = &intf->cur_altsetting->endpoint[i].desc;
1006
1007                 if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) {
1008                         data->intr_ep = ep_desc;
1009                         continue;
1010                 }
1011
1012                 if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) {
1013                         data->bulk_tx_ep = ep_desc;
1014                         continue;
1015                 }
1016
1017                 if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) {
1018                         data->bulk_rx_ep = ep_desc;
1019                         continue;
1020                 }
1021         }
1022
1023         if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) {
1024                 kfree(data);
1025                 return -ENODEV;
1026         }
1027
1028         data->cmdreq_type = USB_TYPE_CLASS;
1029
1030         data->udev = interface_to_usbdev(intf);
1031         data->intf = intf;
1032
1033         spin_lock_init(&data->lock);
1034
1035         INIT_WORK(&data->work, btusb_work);
1036         INIT_WORK(&data->waker, btusb_waker);
1037         spin_lock_init(&data->txlock);
1038
1039         init_usb_anchor(&data->tx_anchor);
1040         init_usb_anchor(&data->intr_anchor);
1041         init_usb_anchor(&data->bulk_anchor);
1042         init_usb_anchor(&data->isoc_anchor);
1043         init_usb_anchor(&data->deferred);
1044
1045         hdev = hci_alloc_dev();
1046         if (!hdev) {
1047                 kfree(data);
1048                 return -ENOMEM;
1049         }
1050
1051         hdev->bus = HCI_USB;
1052         hdev->driver_data = data;
1053
1054         data->hdev = hdev;
1055
1056         SET_HCIDEV_DEV(hdev, &intf->dev);
1057
1058         hdev->open     = btusb_open;
1059         hdev->close    = btusb_close;
1060         hdev->flush    = btusb_flush;
1061         hdev->send     = btusb_send_frame;
1062         hdev->destruct = btusb_destruct;
1063         hdev->notify   = btusb_notify;
1064
1065         hdev->owner = THIS_MODULE;
1066
1067         /* Interface numbers are hardcoded in the specification */
1068         data->isoc = usb_ifnum_to_if(data->udev, 1);
1069
1070         if (!reset)
1071                 set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
1072
1073         if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) {
1074                 if (!disable_scofix)
1075                         set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks);
1076         }
1077
1078         if (id->driver_info & BTUSB_BROKEN_ISOC)
1079                 data->isoc = NULL;
1080
1081         if (id->driver_info & BTUSB_DIGIANSWER) {
1082                 data->cmdreq_type = USB_TYPE_VENDOR;
1083                 set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
1084         }
1085
1086         if (id->driver_info & BTUSB_CSR) {
1087                 struct usb_device *udev = data->udev;
1088
1089                 /* Old firmware would otherwise execute USB reset */
1090                 if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x117)
1091                         set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
1092         }
1093
1094         if (id->driver_info & BTUSB_SNIFFER) {
1095                 struct usb_device *udev = data->udev;
1096
1097                 /* New sniffer firmware has crippled HCI interface */
1098                 if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997)
1099                         set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
1100
1101                 data->isoc = NULL;
1102         }
1103
1104         if (id->driver_info & BTUSB_BCM92035) {
1105                 unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 };
1106                 struct sk_buff *skb;
1107
1108                 skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
1109                 if (skb) {
1110                         memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
1111                         skb_queue_tail(&hdev->driver_init, skb);
1112                 }
1113         }
1114
1115         if (data->isoc) {
1116                 err = usb_driver_claim_interface(&btusb_driver,
1117                                                         data->isoc, data);
1118                 if (err < 0) {
1119                         hci_free_dev(hdev);
1120                         kfree(data);
1121                         return err;
1122                 }
1123         }
1124
1125         err = hci_register_dev(hdev);
1126         if (err < 0) {
1127                 hci_free_dev(hdev);
1128                 kfree(data);
1129                 return err;
1130         }
1131
1132         usb_set_intfdata(intf, data);
1133
1134         return 0;
1135 }
1136
1137 static void btusb_disconnect(struct usb_interface *intf)
1138 {
1139         struct btusb_data *data = usb_get_intfdata(intf);
1140         struct hci_dev *hdev;
1141
1142         BT_DBG("intf %p", intf);
1143
1144         if (!data)
1145                 return;
1146
1147         hdev = data->hdev;
1148
1149         __hci_dev_hold(hdev);
1150
1151         usb_set_intfdata(data->intf, NULL);
1152
1153         if (data->isoc)
1154                 usb_set_intfdata(data->isoc, NULL);
1155
1156         hci_unregister_dev(hdev);
1157
1158         if (intf == data->isoc)
1159                 usb_driver_release_interface(&btusb_driver, data->intf);
1160         else if (data->isoc)
1161                 usb_driver_release_interface(&btusb_driver, data->isoc);
1162
1163         __hci_dev_put(hdev);
1164
1165         hci_free_dev(hdev);
1166 }
1167
1168 #ifdef CONFIG_PM
1169 static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
1170 {
1171         struct btusb_data *data = usb_get_intfdata(intf);
1172
1173         BT_DBG("intf %p", intf);
1174
1175         if (data->suspend_count++)
1176                 return 0;
1177
1178         spin_lock_irq(&data->txlock);
1179         if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
1180                 set_bit(BTUSB_SUSPENDING, &data->flags);
1181                 spin_unlock_irq(&data->txlock);
1182         } else {
1183                 spin_unlock_irq(&data->txlock);
1184                 data->suspend_count--;
1185                 return -EBUSY;
1186         }
1187
1188         cancel_work_sync(&data->work);
1189
1190         btusb_stop_traffic(data);
1191         usb_kill_anchored_urbs(&data->tx_anchor);
1192
1193         return 0;
1194 }
1195
1196 static void play_deferred(struct btusb_data *data)
1197 {
1198         struct urb *urb;
1199         int err;
1200
1201         while ((urb = usb_get_from_anchor(&data->deferred))) {
1202                 err = usb_submit_urb(urb, GFP_ATOMIC);
1203                 if (err < 0)
1204                         break;
1205
1206                 data->tx_in_flight++;
1207         }
1208         usb_scuttle_anchored_urbs(&data->deferred);
1209 }
1210
1211 static int btusb_resume(struct usb_interface *intf)
1212 {
1213         struct btusb_data *data = usb_get_intfdata(intf);
1214         struct hci_dev *hdev = data->hdev;
1215         int err = 0;
1216
1217         BT_DBG("intf %p", intf);
1218
1219         if (--data->suspend_count)
1220                 return 0;
1221
1222         if (!test_bit(HCI_RUNNING, &hdev->flags))
1223                 goto done;
1224
1225         if (test_bit(BTUSB_INTR_RUNNING, &data->flags)) {
1226                 err = btusb_submit_intr_urb(hdev, GFP_NOIO);
1227                 if (err < 0) {
1228                         clear_bit(BTUSB_INTR_RUNNING, &data->flags);
1229                         goto failed;
1230                 }
1231         }
1232
1233         if (test_bit(BTUSB_BULK_RUNNING, &data->flags)) {
1234                 err = btusb_submit_bulk_urb(hdev, GFP_NOIO);
1235                 if (err < 0) {
1236                         clear_bit(BTUSB_BULK_RUNNING, &data->flags);
1237                         goto failed;
1238                 }
1239
1240                 btusb_submit_bulk_urb(hdev, GFP_NOIO);
1241         }
1242
1243         if (test_bit(BTUSB_ISOC_RUNNING, &data->flags)) {
1244                 if (btusb_submit_isoc_urb(hdev, GFP_NOIO) < 0)
1245                         clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
1246                 else
1247                         btusb_submit_isoc_urb(hdev, GFP_NOIO);
1248         }
1249
1250         spin_lock_irq(&data->txlock);
1251         play_deferred(data);
1252         clear_bit(BTUSB_SUSPENDING, &data->flags);
1253         spin_unlock_irq(&data->txlock);
1254         schedule_work(&data->work);
1255
1256         return 0;
1257
1258 failed:
1259         usb_scuttle_anchored_urbs(&data->deferred);
1260 done:
1261         spin_lock_irq(&data->txlock);
1262         clear_bit(BTUSB_SUSPENDING, &data->flags);
1263         spin_unlock_irq(&data->txlock);
1264
1265         return err;
1266 }
1267 #endif
1268
1269 static struct usb_driver btusb_driver = {
1270         .name           = "btusb",
1271         .probe          = btusb_probe,
1272         .disconnect     = btusb_disconnect,
1273 #ifdef CONFIG_PM
1274         .suspend        = btusb_suspend,
1275         .resume         = btusb_resume,
1276 #endif
1277         .id_table       = btusb_table,
1278         .supports_autosuspend = 1,
1279 };
1280
1281 static int __init btusb_init(void)
1282 {
1283         BT_INFO("Generic Bluetooth USB driver ver %s", VERSION);
1284
1285         return usb_register(&btusb_driver);
1286 }
1287
1288 static void __exit btusb_exit(void)
1289 {
1290         usb_deregister(&btusb_driver);
1291 }
1292
1293 module_init(btusb_init);
1294 module_exit(btusb_exit);
1295
1296 module_param(ignore_dga, bool, 0644);
1297 MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001");
1298
1299 module_param(ignore_csr, bool, 0644);
1300 MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001");
1301
1302 module_param(ignore_sniffer, bool, 0644);
1303 MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002");
1304
1305 module_param(disable_scofix, bool, 0644);
1306 MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size");
1307
1308 module_param(force_scofix, bool, 0644);
1309 MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size");
1310
1311 module_param(reset, bool, 0644);
1312 MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
1313
1314 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
1315 MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION);
1316 MODULE_VERSION(VERSION);
1317 MODULE_LICENSE("GPL");