| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * | |||
| 3 | * Digianswer Bluetooth USB driver | |||
| 4 | * | |||
| 5 | * Copyright (C) 2004-2005 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/config.h> | |||
| 25 | #include <linux/module.h> | |||
| 26 | ||||
| 27 | #include <linux/kernel.h> | |||
| 28 | #include <linux/init.h> | |||
| 29 | #include <linux/slab.h> | |||
| 30 | #include <linux/types.h> | |||
| 31 | #include <linux/errno.h> | |||
| 32 | ||||
| 33 | #include <linux/usb.h> | |||
| 34 | ||||
| 35 | #include <net/bluetooth/bluetooth.h> | |||
| 36 | #include <net/bluetooth/hci_core.h> | |||
| 37 | ||||
| 38 | #ifndef CONFIG_BT_HCIBPA10X_DEBUG | |||
| 39 | #undef BT_DBG | |||
| 40 | #define BT_DBG(D...) | |||
| 41 | #endif | |||
| 42 | ||||
| 43 | #define VERSION "0.8" | |||
| 44 | ||||
| 45 | static int ignore = 0; | |||
| 46 | ||||
| 47 | static struct usb_device_id bpa10x_table[] = { | |||
| 48 | /* Tektronix BPA 100/105 (Digianswer) */ | |||
| 49 | { USB_DEVICE(0x08fd, 0x0002) }, | |||
| 50 | ||||
| 51 | { } /* Terminating entry */ | |||
| 52 | }; | |||
| 53 | ||||
| 54 | MODULE_DEVICE_TABLE(usb, bpa10x_table); | |||
| 55 | ||||
| 56 | #define BPA10X_CMD_EP 0x00 | |||
| 57 | #define BPA10X_EVT_EP 0x81 | |||
| 58 | #define BPA10X_TX_EP 0x02 | |||
| 59 | #define BPA10X_RX_EP 0x82 | |||
| 60 | ||||
| 61 | #define BPA10X_CMD_BUF_SIZE 252 | |||
| 62 | #define BPA10X_EVT_BUF_SIZE 16 | |||
| 63 | #define BPA10X_TX_BUF_SIZE 384 | |||
| 64 | #define BPA10X_RX_BUF_SIZE 384 | |||
| 65 | ||||
| 66 | struct bpa10x_data { | |||
| 67 | struct hci_dev *hdev; | |||
| 68 | struct usb_device *udev; | |||
| 69 | ||||
| 70 | rwlock_t lock; | |||
| 71 | ||||
| 72 | struct sk_buff_head cmd_queue; | |||
| 73 | struct urb *cmd_urb; | |||
| 74 | struct urb *evt_urb; | |||
| 75 | struct sk_buff *evt_skb; | |||
| 76 | unsigned int evt_len; | |||
| 77 | ||||
| 78 | struct sk_buff_head tx_queue; | |||
| 79 | struct urb *tx_urb; | |||
| 80 | struct urb *rx_urb; | |||
| 81 | }; | |||
| 82 | ||||
| 83 | #define HCI_VENDOR_HDR_SIZE 5 | |||
| 84 | ||||
| 85 | struct hci_vendor_hdr { | |||
| 86 | __u8 type; | |||
| 87 | __le16 snum; | |||
| 88 | __le16 dlen; | |||
| 89 | } __attribute__ ((packed)); | |||
| 90 | ||||
| 0 | 0 | - | 91 | static void bpa10x_recv_bulk(struct bpa10x_data *data, unsigned char *buf, int count) |
| 92 | { | |||
| 93 | struct hci_acl_hdr *ah; | |||
| 94 | struct hci_sco_hdr *sh; | |||
| 95 | struct hci_vendor_hdr *vh; | |||
| 96 | struct sk_buff *skb; | |||
| 97 | int len; | |||
| 98 | ||||
| 0 | 0 | - | 99 | while (count) { |
| 100 | switch (*buf++) { | |||
| 0 | - | 101 | case HCI_ACLDATA_PKT: | |
| 102 | ah = (struct hci_acl_hdr *) buf; | |||
| 103 | len = HCI_ACL_HDR_SIZE + __le16_to_cpu(ah->dlen); | |||
| 104 | skb = bt_skb_alloc(len, GFP_ATOMIC); | |||
| 0 | 0 | - | 105 | if (skb) { |
| 106 | memcpy(skb_put(skb, len), buf, len); | |||
| 107 | skb->dev = (void *) data->hdev; | |||
| 108 | bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; | |||
| 109 | hci_recv_frame(skb); | |||
| 110 | } | |||
| 0 | - | 111 | break; | |
| 112 | ||||
| 0 | - | 113 | case HCI_SCODATA_PKT: | |
| 114 | sh = (struct hci_sco_hdr *) buf; | |||
| 115 | len = HCI_SCO_HDR_SIZE + sh->dlen; | |||
| 116 | skb = bt_skb_alloc(len, GFP_ATOMIC); | |||
| 0 | 0 | - | 117 | if (skb) { |
| 118 | memcpy(skb_put(skb, len), buf, len); | |||
| 119 | skb->dev = (void *) data->hdev; | |||
| 120 | bt_cb(skb)->pkt_type = HCI_SCODATA_PKT; | |||
| 121 | hci_recv_frame(skb); | |||
| 122 | } | |||
| 0 | - | 123 | break; | |
| 124 | ||||
| 0 | - | 125 | case HCI_VENDOR_PKT: | |
| 126 | vh = (struct hci_vendor_hdr *) buf; | |||
| 127 | len = HCI_VENDOR_HDR_SIZE + __le16_to_cpu(vh->dlen); | |||
| 128 | skb = bt_skb_alloc(len, GFP_ATOMIC); | |||
| 0 | 0 | - | 129 | if (skb) { |
| 130 | memcpy(skb_put(skb, len), buf, len); | |||
| 131 | skb->dev = (void *) data->hdev; | |||
| 132 | bt_cb(skb)->pkt_type = HCI_VENDOR_PKT; | |||
| 133 | hci_recv_frame(skb); | |||
| 134 | } | |||
| 0 | - | 135 | break; | |
| 136 | ||||
| 0 | - | 137 | default: | |
| 138 | len = count - 1; | |||
| 0 | - | 139 | break; | |
| 140 | } | |||
| 141 | ||||
| 142 | buf += len; | |||
| 143 | count -= (len + 1); | |||
| 144 | } | |||
| 145 | } | |||
| 146 | ||||
| 0 | 0 | - | 147 | static int bpa10x_recv_event(struct bpa10x_data *data, unsigned char *buf, int size) |
| 148 | { | |||
| 149 | BT_DBG("data %p buf %p size %d", data, buf, size); | |||
| 150 | ||||
| 0 | 0 | - | 151 | if (data->evt_skb) { |
| 152 | struct sk_buff *skb = data->evt_skb; | |||
| 153 | ||||
| 154 | memcpy(skb_put(skb, size), buf, size); | |||
| 155 | ||||
| 0 | 0 | - | 156 | if (skb->len == data->evt_len) { |
| 157 | data->evt_skb = NULL; | |||
| 158 | data->evt_len = 0; | |||
| 159 | hci_recv_frame(skb); | |||
| 160 | } | |||
| 161 | } else { | |||
| 162 | struct sk_buff *skb; | |||
| 163 | struct hci_event_hdr *hdr; | |||
| 164 | unsigned char pkt_type; | |||
| 165 | int pkt_len = 0; | |||
| 166 | ||||
| 0 | 0 | - | 167 | if (size < HCI_EVENT_HDR_SIZE + 1) { |
| 168 | BT_ERR("%s event packet block with size %d is too short", | |||
| 169 | data->hdev->name, size); | |||
| 0 | - | 170 | return -EILSEQ; | |
| 171 | } | |||
| 172 | ||||
| 173 | pkt_type = *buf++; | |||
| 174 | size--; | |||
| 175 | ||||
| 0 | 0 | - | 176 | if (pkt_type != HCI_EVENT_PKT) { |
| 177 | BT_ERR("%s unexpected event packet start byte 0x%02x", | |||
| 178 | data->hdev->name, pkt_type); | |||
| 0 | - | 179 | return -EPROTO; | |
| 180 | } | |||
| 181 | ||||
| 182 | hdr = (struct hci_event_hdr *) buf; | |||
| 183 | pkt_len = HCI_EVENT_HDR_SIZE + hdr->plen; | |||
| 184 | ||||
| 185 | skb = bt_skb_alloc(pkt_len, GFP_ATOMIC); | |||
| 0 | 0 | - | 186 | if (!skb) { |
| 187 | BT_ERR("%s no memory for new event packet", | |||
| 188 | data->hdev->name); | |||
| 0 | - | 189 | return -ENOMEM; | |
| 190 | } | |||
| 191 | ||||
| 192 | skb->dev = (void *) data->hdev; | |||
| 193 | bt_cb(skb)->pkt_type = pkt_type; | |||
| 194 | ||||
| 195 | memcpy(skb_put(skb, size), buf, size); | |||
| 196 | ||||
| 0 | 0 | - | 197 | if (pkt_len == size) { |
| 198 | hci_recv_frame(skb); | |||
| 199 | } else { | |||
| 200 | data->evt_skb = skb; | |||
| 201 | data->evt_len = pkt_len; | |||
| 202 | } | |||
| 203 | } | |||
| 204 | ||||
| 0 | - | 205 | return 0; | |
| 206 | } | |||
| 207 | ||||
| 0 | 0 | - | 208 | static void bpa10x_wakeup(struct bpa10x_data *data) |
| 209 | { | |||
| 210 | struct urb *urb; | |||
| 211 | struct sk_buff *skb; | |||
| 212 | int err; | |||
| 213 | ||||
| 214 | BT_DBG("data %p", data); | |||
| 215 | ||||
| 216 | urb = data->cmd_urb; | |||
| 0 | 0 | - | 217 | if (urb->status == -EINPROGRESS) |
| 218 | skb = NULL; | |||
| 219 | else | |||
| 220 | skb = skb_dequeue(&data->cmd_queue); | |||
| 221 | ||||
| 0 | 0 | - | 222 | if (skb) { |
| 223 | struct usb_ctrlrequest *cr; | |||
| 224 | ||||
| 0 | 0 | - | 225 | if (skb->len > BPA10X_CMD_BUF_SIZE) { |
| 226 | BT_ERR("%s command packet with size %d is too big", | |||
| 227 | data->hdev->name, skb->len); | |||
| 228 | kfree_skb(skb); | |||
| 0 | - | 229 | return; | |
| 230 | } | |||
| 231 | ||||
| 232 | cr = (struct usb_ctrlrequest *) urb->setup_packet; | |||
| 233 | cr->wLength = __cpu_to_le16(skb->len); | |||
| 234 | ||||
| 235 | memcpy(urb->transfer_buffer, skb->data, skb->len); | |||
| 236 | urb->transfer_buffer_length = skb->len; | |||
| 237 | ||||
| 238 | err = usb_submit_urb(urb, GFP_ATOMIC); | |||
| 0 | 0 | - | 239 | if (err < 0 && err != -ENODEV) { |
| 0 | - | 239 | T && T | |
| 0 | - | 239 | T && F | |
| 0 | - | 239 | F && _ | |
| 240 | BT_ERR("%s submit failed for command urb %p with error %d", | |||
| 241 | data->hdev->name, urb, err); | |||
| 242 | skb_queue_head(&data->cmd_queue, skb); | |||
| 243 | } else | |||
| 244 | kfree_skb(skb); | |||
| 245 | } | |||
| 246 | ||||
| 247 | urb = data->tx_urb; | |||
| 0 | 0 | - | 248 | if (urb->status == -EINPROGRESS) |
| 249 | skb = NULL; | |||
| 250 | else | |||
| 251 | skb = skb_dequeue(&data->tx_queue); | |||
| 252 | ||||
| 0 | 0 | - | 253 | if (skb) { |
| 254 | memcpy(urb->transfer_buffer, skb->data, skb->len); | |||
| 255 | urb->transfer_buffer_length = skb->len; | |||
| 256 | ||||
| 257 | err = usb_submit_urb(urb, GFP_ATOMIC); | |||
| 0 | 0 | - | 258 | if (err < 0 && err != -ENODEV) { |
| 0 | - | 258 | T && T | |
| 0 | - | 258 | T && F | |
| 0 | - | 258 | F && _ | |
| 259 | BT_ERR("%s submit failed for command urb %p with error %d", | |||
| 260 | data->hdev->name, urb, err); | |||
| 261 | skb_queue_head(&data->tx_queue, skb); | |||
| 262 | } else | |||
| 263 | kfree_skb(skb); | |||
| 264 | } | |||
| 265 | } | |||
| 266 | ||||
| 0 | 0 | - | 267 | static void bpa10x_complete(struct urb *urb, struct pt_regs *regs) |
| 268 | { | |||
| 269 | struct bpa10x_data *data = urb->context; | |||
| 270 | unsigned char *buf = urb->transfer_buffer; | |||
| 271 | int err, count = urb->actual_length; | |||
| 272 | ||||
| 273 | BT_DBG("data %p urb %p buf %p count %d", data, urb, buf, count); | |||
| 274 | ||||
| 275 | read_lock(&data->lock); | |||
| 275 | do | |||
| 0 | 0 | - | 275 | do-while (0) |
| 0 | 0 | - | 275 | do-while (0) |
| 276 | ||||
| 0 | 0 | - | 277 | if (!test_bit(HCI_RUNNING, &data->hdev->flags)) |
| 0 | 0 | - | 277 | ternary-?: __builtin_constant_p ( HCI_RUNNING ) |
| 0 | - | 278 | goto unlock; | |
| 279 | ||||
| 0 | 0 | - | 280 | if (urb->status < 0 || !count) |
| 0 | - | 280 | T || _ | |
| 0 | - | 280 | F || T | |
| 0 | - | 280 | F || F | |
| 0 | - | 281 | goto resubmit; | |
| 282 | ||||
| 0 | 0 | - | 283 | if (usb_pipein(urb->pipe)) { |
| 284 | data->hdev->stat.byte_rx += count; | |||
| 285 | ||||
| 0 | 0 | - | 286 | if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) |
| 287 | bpa10x_recv_event(data, buf, count); | |||
| 288 | ||||
| 0 | 0 | - | 289 | if (usb_pipetype(urb->pipe) == PIPE_BULK) |
| 290 | bpa10x_recv_bulk(data, buf, count); | |||
| 291 | } else { | |||
| 292 | data->hdev->stat.byte_tx += count; | |||
| 293 | ||||
| 294 | bpa10x_wakeup(data); | |||
| 295 | } | |||
| 296 | ||||
| 297 | resubmit: | |||
| 0 | 0 | - | 298 | if (usb_pipein(urb->pipe)) { |
| 299 | err = usb_submit_urb(urb, GFP_ATOMIC); | |||
| 0 | 0 | - | 300 | if (err < 0 && err != -ENODEV) { |
| 0 | - | 300 | T && T | |
| 0 | - | 300 | T && F | |
| 0 | - | 300 | F && _ | |
| 301 | BT_ERR("%s urb %p type %d resubmit status %d", | |||
| 302 | data->hdev->name, urb, usb_pipetype(urb->pipe), err); | |||
| 303 | } | |||
| 304 | } | |||
| 305 | ||||
| 306 | unlock: | |||
| 307 | read_unlock(&data->lock); | |||
| 307 | do | |||
| 0 | 0 | - | 307 | do-while (0) |
| 0 | 0 | - | 307 | do-while (0) |
| 308 | } | |||
| 309 | ||||
| 0 | 0 | - | 310 | static inline struct urb *bpa10x_alloc_urb(struct usb_device *udev, unsigned int pipe, |
| 311 | size_t size, gfp_t flags, void *data) | |||
| 312 | { | |||
| 313 | struct urb *urb; | |||
| 314 | struct usb_ctrlrequest *cr; | |||
| 315 | unsigned char *buf; | |||
| 316 | ||||
| 317 | BT_DBG("udev %p data %p", udev, data); | |||
| 318 | ||||
| 319 | urb = usb_alloc_urb(0, flags); | |||
| 0 | 0 | - | 320 | if (!urb) |
| 0 | - | 321 | return NULL; | |
| 322 | ||||
| 323 | buf = kmalloc(size, flags); | |||
| 0 | 0 | - | 324 | if (!buf) { |
| 325 | usb_free_urb(urb); | |||
| 0 | - | 326 | return NULL; | |
| 327 | } | |||
| 328 | ||||
| 329 | switch (usb_pipetype(pipe)) { | |||
| 0 | - | 330 | case PIPE_CONTROL: | |
| 331 | cr = kmalloc(sizeof(*cr), flags); | |||
| 0 | 0 | - | 332 | if (!cr) { |
| 333 | kfree(buf); | |||
| 334 | usb_free_urb(urb); | |||
| 0 | - | 335 | return NULL; | |
| 336 | } | |||
| 337 | ||||
| 338 | cr->bRequestType = USB_TYPE_VENDOR; | |||
| 339 | cr->bRequest = 0; | |||
| 340 | cr->wIndex = 0; | |||
| 341 | cr->wValue = 0; | |||
| 342 | cr->wLength = __cpu_to_le16(0); | |||
| 343 | ||||
| 344 | usb_fill_control_urb(urb, udev, pipe, (void *) cr, buf, 0, bpa10x_complete, data); | |||
| 0 | - | 345 | break; | |
| 346 | ||||
| 0 | - | 347 | case PIPE_INTERRUPT: | |
| 348 | usb_fill_int_urb(urb, udev, pipe, buf, size, bpa10x_complete, data, 1); | |||
| 0 | - | 349 | break; | |
| 350 | ||||
| 0 | - | 351 | case PIPE_BULK: | |
| 352 | usb_fill_bulk_urb(urb, udev, pipe, buf, size, bpa10x_complete, data); | |||
| 0 | - | 353 | break; | |
| 354 | ||||
| 0 | - | 355 | default: | |
| 356 | kfree(buf); | |||
| 357 | usb_free_urb(urb); | |||
| 0 | - | 358 | return NULL; | |
| 359 | } | |||
| 360 | ||||
| 0 | - | 361 | return urb; | |
| 362 | } | |||
| 363 | ||||
| 0 | 0 | - | 364 | static inline void bpa10x_free_urb(struct urb *urb) |
| 365 | { | |||
| 366 | BT_DBG("urb %p", urb); | |||
| 367 | ||||
| 0 | 0 | - | 368 | if (!urb) |
| 0 | - | 369 | return; | |
| 370 | ||||
| 371 | kfree(urb->setup_packet); | |||
| 372 | kfree(urb->transfer_buffer); | |||
| 373 | ||||
| 374 | usb_free_urb(urb); | |||
| 375 | } | |||
| 376 | ||||
| 0 | 0 | - | 377 | static int bpa10x_open(struct hci_dev *hdev) |
| 378 | { | |||
| 379 | struct bpa10x_data *data = hdev->driver_data; | |||
| 380 | struct usb_device *udev = data->udev; | |||
| 381 | unsigned long flags; | |||
| 382 | int err; | |||
| 383 | ||||
| 384 | BT_DBG("hdev %p data %p", hdev, data); | |||
| 385 | ||||
| 0 | 0 | - | 386 | if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) |
| 0 | - | 387 | return 0; | |
| 388 | ||||
| 389 | data->cmd_urb = bpa10x_alloc_urb(udev, usb_sndctrlpipe(udev, BPA10X_CMD_EP), | |||
| 390 | BPA10X_CMD_BUF_SIZE, GFP_KERNEL, data); | |||
| 0 | 0 | - | 391 | if (!data->cmd_urb) { |
| 392 | err = -ENOMEM; | |||
| 0 | - | 393 | goto done; | |
| 394 | } | |||
| 395 | ||||
| 396 | data->evt_urb = bpa10x_alloc_urb(udev, usb_rcvintpipe(udev, BPA10X_EVT_EP), | |||
| 397 | BPA10X_EVT_BUF_SIZE, GFP_KERNEL, data); | |||
| 0 | 0 | - | 398 | if (!data->evt_urb) { |
| 399 | bpa10x_free_urb(data->cmd_urb); | |||
| 400 | err = -ENOMEM; | |||
| 0 | - | 401 | goto done; | |
| 402 | } | |||
| 403 | ||||
| 404 | data->rx_urb = bpa10x_alloc_urb(udev, usb_rcvbulkpipe(udev, BPA10X_RX_EP), | |||
| 405 | BPA10X_RX_BUF_SIZE, GFP_KERNEL, data); | |||
| 0 | 0 | - | 406 | if (!data->rx_urb) { |
| 407 | bpa10x_free_urb(data->evt_urb); | |||
| 408 | bpa10x_free_urb(data->cmd_urb); | |||
| 409 | err = -ENOMEM; | |||
| 0 | - | 410 | goto done; | |
| 411 | } | |||
| 412 | ||||
| 413 | data->tx_urb = bpa10x_alloc_urb(udev, usb_sndbulkpipe(udev, BPA10X_TX_EP), | |||
| 414 | BPA10X_TX_BUF_SIZE, GFP_KERNEL, data); | |||
| 0 | 0 | - | 415 | if (!data->rx_urb) { |
| 416 | bpa10x_free_urb(data->rx_urb); | |||
| 417 | bpa10x_free_urb(data->evt_urb); | |||
| 418 | bpa10x_free_urb(data->cmd_urb); | |||
| 419 | err = -ENOMEM; | |||
| 0 | - | 420 | goto done; | |
| 421 | } | |||
| 422 | ||||
| 423 | write_lock_irqsave(&data->lock, flags); | |||
| 423 | do | |||
| 423 | do | |||
| 0 | 0 | - | 423 | do-while (0) |
| 0 | 0 | - | 423 | do-while (0) |
| 423 | do | |||
| 423 | do | |||
| 0 | 0 | - | 423 | do-while (0) |
| 0 | 0 | - | 423 | do-while (0) |
| 0 | 0 | - | 423 | do-while (0) |
| 424 | ||||
| 425 | err = usb_submit_urb(data->evt_urb, GFP_ATOMIC); | |||
| 0 | 0 | - | 426 | if (err < 0) { |
| 427 | BT_ERR("%s submit failed for event urb %p with error %d", | |||
| 428 | data->hdev->name, data->evt_urb, err); | |||
| 429 | } else { | |||
| 430 | err = usb_submit_urb(data->rx_urb, GFP_ATOMIC); | |||
| 0 | 0 | - | 431 | if (err < 0) { |
| 432 | BT_ERR("%s submit failed for rx urb %p with error %d", | |||
| 433 | data->hdev->name, data->evt_urb, err); | |||
| 434 | usb_kill_urb(data->evt_urb); | |||
| 435 | } | |||
| 436 | } | |||
| 437 | ||||
| 438 | write_unlock_irqrestore(&data->lock, flags); | |||
| 438 | do | |||
| 438 | do | |||
| 0 | 0 | - | 438 | do-while (0) |
| 0 | 0 | - | 438 | do-while (0) |
| 0 | 0 | - | 438 | do-while (0) |
| 439 | ||||
| 440 | done: | |||
| 0 | 0 | - | 441 | if (err < 0) |
| 442 | clear_bit(HCI_RUNNING, &hdev->flags); | |||
| 443 | ||||
| 0 | - | 444 | return err; | |
| 445 | } | |||
| 446 | ||||
| 0 | 0 | - | 447 | static int bpa10x_close(struct hci_dev *hdev) |
| 448 | { | |||
| 449 | struct bpa10x_data *data = hdev->driver_data; | |||
| 450 | unsigned long flags; | |||
| 451 | ||||
| 452 | BT_DBG("hdev %p data %p", hdev, data); | |||
| 453 | ||||
| 0 | 0 | - | 454 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) |
| 0 | - | 455 | return 0; | |
| 456 | ||||
| 457 | write_lock_irqsave(&data->lock, flags); | |||
| 457 | do | |||
| 457 | do | |||
| 0 | 0 | - | 457 | do-while (0) |
| 0 | 0 | - | 457 | do-while (0) |
| 457 | do | |||
| 457 | do | |||
| 0 | 0 | - | 457 | do-while (0) |
| 0 | 0 | - | 457 | do-while (0) |
| 0 | 0 | - | 457 | do-while (0) |
| 458 | ||||
| 459 | skb_queue_purge(&data->cmd_queue); | |||
| 460 | usb_kill_urb(data->cmd_urb); | |||
| 461 | usb_kill_urb(data->evt_urb); | |||
| 462 | usb_kill_urb(data->rx_urb); | |||
| 463 | usb_kill_urb(data->tx_urb); | |||
| 464 | ||||
| 465 | write_unlock_irqrestore(&data->lock, flags); | |||
| 465 | do | |||
| 465 | do | |||
| 0 | 0 | - | 465 | do-while (0) |
| 0 | 0 | - | 465 | do-while (0) |
| 0 | 0 | - | 465 | do-while (0) |
| 466 | ||||
| 467 | bpa10x_free_urb(data->cmd_urb); | |||
| 468 | bpa10x_free_urb(data->evt_urb); | |||
| 469 | bpa10x_free_urb(data->rx_urb); | |||
| 470 | bpa10x_free_urb(data->tx_urb); | |||
| 471 | ||||
| 0 | - | 472 | return 0; | |
| 473 | } | |||
| 474 | ||||
| 0 | 0 | - | 475 | static int bpa10x_flush(struct hci_dev *hdev) |
| 476 | { | |||
| 477 | struct bpa10x_data *data = hdev->driver_data; | |||
| 478 | ||||
| 479 | BT_DBG("hdev %p data %p", hdev, data); | |||
| 480 | ||||
| 481 | skb_queue_purge(&data->cmd_queue); | |||
| 482 | ||||
| 0 | - | 483 | return 0; | |
| 484 | } | |||
| 485 | ||||
| 0 | 0 | - | 486 | static int bpa10x_send_frame(struct sk_buff *skb) |
| 487 | { | |||
| 488 | struct hci_dev *hdev = (struct hci_dev *) skb->dev; | |||
| 489 | struct bpa10x_data *data; | |||
| 490 | ||||
| 491 | BT_DBG("hdev %p skb %p type %d len %d", hdev, skb, bt_cb(skb)->pkt_type, skb->len); | |||
| 492 | ||||
| 0 | 0 | - | 493 | if (!hdev) { |
| 494 | BT_ERR("Frame for&n | |||