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