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