24 #include <linux/kernel.h>
25 #include <linux/module.h>
27 #include <linux/slab.h>
28 #include <linux/types.h>
29 #include <linux/sched.h>
30 #include <linux/errno.h>
38 #define VERSION "0.10"
42 { USB_DEVICE(0x08fd, 0x0002) },
59 #define HCI_VENDOR_HDR_SIZE 5
71 BT_DBG(
"%s queue %d buffer %p count %d", hdev->
name,
87 type = *((
__u8 *) buf);
128 BT_ERR(
"%s no memory for packet", hdev->
name);
132 skb->
dev = (
void *) hdev;
136 scb = (
void *) skb->cb;
142 scb = (
void *) skb->cb;
146 len =
min(len, count);
152 if (
scb->expect == 0) {
161 count -= len; buf += len;
167 static void bpa10x_tx_complete(
struct urb *
urb)
172 BT_DBG(
"%s urb %p status %d count %d", hdev->
name,
173 urb, urb->status, urb->actual_length);
179 hdev->
stat.byte_tx += urb->transfer_buffer_length;
184 kfree(urb->setup_packet);
189 static void bpa10x_rx_complete(
struct urb *urb)
191 struct hci_dev *hdev = urb->context;
195 BT_DBG(
"%s urb %p status %d count %d", hdev->
name,
196 urb, urb->status, urb->actual_length);
201 if (urb->status == 0) {
202 if (bpa10x_recv(hdev, usb_pipebulk(urb->pipe),
203 urb->transfer_buffer,
204 urb->actual_length) < 0) {
205 BT_ERR(
"%s corrupted event packet", hdev->
name);
214 BT_ERR(
"%s urb %p failed to resubmit (%d)",
215 hdev->
name, urb, -err);
220 static inline int bpa10x_submit_intr_urb(
struct hci_dev *hdev)
240 pipe = usb_rcvintpipe(data->
udev, 0x81);
242 usb_fill_int_urb(urb, data->
udev, pipe, buf, size,
243 bpa10x_rx_complete, hdev, 1);
245 urb->transfer_flags |= URB_FREE_BUFFER;
251 BT_ERR(
"%s urb %p submission failed (%d)",
252 hdev->
name, urb, -err);
261 static inline int bpa10x_submit_bulk_urb(
struct hci_dev *hdev)
281 pipe = usb_rcvbulkpipe(data->
udev, 0x82);
283 usb_fill_bulk_urb(urb, data->
udev, pipe,
284 buf, size, bpa10x_rx_complete, hdev);
286 urb->transfer_flags |= URB_FREE_BUFFER;
292 BT_ERR(
"%s urb %p submission failed (%d)",
293 hdev->
name, urb, -err);
302 static int bpa10x_open(
struct hci_dev *hdev)
312 err = bpa10x_submit_intr_urb(hdev);
316 err = bpa10x_submit_bulk_urb(hdev);
330 static int bpa10x_close(
struct hci_dev *hdev)
344 static int bpa10x_flush(
struct hci_dev *hdev)
355 static int bpa10x_send_frame(
struct sk_buff *skb)
376 switch (
bt_cb(skb)->pkt_type) {
390 pipe = usb_sndctrlpipe(data->
udev, 0x00);
392 usb_fill_control_urb(urb, data->
udev, pipe, (
void *) dr,
393 skb->
data, skb->
len, bpa10x_tx_complete, skb);
399 pipe = usb_sndbulkpipe(data->
udev, 0x02);
401 usb_fill_bulk_urb(urb, data->
udev, pipe,
402 skb->
data, skb->
len, bpa10x_tx_complete, skb);
408 pipe = usb_sndbulkpipe(data->
udev, 0x02);
410 usb_fill_bulk_urb(urb, data->
udev, pipe,
411 skb->
data, skb->
len, bpa10x_tx_complete, skb);
425 BT_ERR(
"%s urb %p submission failed", hdev->
name, urb);
426 kfree(urb->setup_packet);
441 BT_DBG(
"intf %p id %p", intf,
id);
443 if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
450 data->
udev = interface_to_usbdev(intf);
460 hci_set_drvdata(hdev, data);
466 hdev->
open = bpa10x_open;
467 hdev->
close = bpa10x_close;
468 hdev->
flush = bpa10x_flush;
469 hdev->
send = bpa10x_send_frame;
479 usb_set_intfdata(intf, data);
493 usb_set_intfdata(intf,
NULL);
502 static struct usb_driver bpa10x_driver = {
504 .probe = bpa10x_probe,
505 .disconnect = bpa10x_disconnect,
506 .id_table = bpa10x_table,
507 .disable_hub_initiated_lpm = 1,