diff options
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/bcm203x.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/bfusb.c | 317 | ||||
-rw-r--r-- | drivers/bluetooth/bluecard_cs.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/bpa10x.c | 1 | ||||
-rw-r--r-- | drivers/bluetooth/bt3c_cs.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/btuart_cs.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/dtl1_cs.c | 5 | ||||
-rw-r--r-- | drivers/bluetooth/hci_bcsp.c | 1 | ||||
-rw-r--r-- | drivers/bluetooth/hci_h4.c | 1 | ||||
-rw-r--r-- | drivers/bluetooth/hci_ldisc.c | 18 | ||||
-rw-r--r-- | drivers/bluetooth/hci_usb.c | 103 | ||||
-rw-r--r-- | drivers/bluetooth/hci_usb.h | 1 | ||||
-rw-r--r-- | drivers/bluetooth/hci_vhci.c | 101 |
13 files changed, 325 insertions, 231 deletions
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index 3e7a067cc08..13ba729cdd5 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c @@ -22,7 +22,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -235,6 +234,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id data->fw_data = kmalloc(firmware->size, GFP_KERNEL); if (!data->fw_data) { BT_ERR("Can't allocate memory for firmware image"); + release_firmware(firmware); usb_free_urb(data->urb); kfree(data->buffer); kfree(data); diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 8947c8837da..efcc28ec9d9 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -2,7 +2,7 @@ * * AVM BlueFRITZ! USB driver * - * Copyright (C) 2003 Marcel Holtmann <marcel@holtmann.org> + * Copyright (C) 2003-2006 Marcel Holtmann <marcel@holtmann.org> * * * This program is free software; you can redistribute it and/or modify @@ -21,7 +21,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -60,7 +59,6 @@ static struct usb_device_id bfusb_table[] = { MODULE_DEVICE_TABLE(usb, bfusb_table); - #define BFUSB_MAX_BLOCK_SIZE 256 #define BFUSB_BLOCK_TIMEOUT 3000 @@ -71,7 +69,7 @@ MODULE_DEVICE_TABLE(usb, bfusb_table); #define BFUSB_MAX_BULK_TX 2 #define BFUSB_MAX_BULK_RX 2 -struct bfusb { +struct bfusb_data { struct hci_dev *hdev; unsigned long state; @@ -93,137 +91,136 @@ struct bfusb { struct sk_buff_head completed_q; }; -struct bfusb_scb { +struct bfusb_data_scb { struct urb *urb; }; static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs); static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs); -static struct urb *bfusb_get_completed(struct bfusb *bfusb) +static struct urb *bfusb_get_completed(struct bfusb_data *data) { struct sk_buff *skb; struct urb *urb = NULL; - BT_DBG("bfusb %p", bfusb); + BT_DBG("bfusb %p", data); - skb = skb_dequeue(&bfusb->completed_q); + skb = skb_dequeue(&data->completed_q); if (skb) { - urb = ((struct bfusb_scb *) skb->cb)->urb; + urb = ((struct bfusb_data_scb *) skb->cb)->urb; kfree_skb(skb); } return urb; } -static void bfusb_unlink_urbs(struct bfusb *bfusb) +static void bfusb_unlink_urbs(struct bfusb_data *data) { struct sk_buff *skb; struct urb *urb; - BT_DBG("bfusb %p", bfusb); + BT_DBG("bfusb %p", data); - while ((skb = skb_dequeue(&bfusb->pending_q))) { - urb = ((struct bfusb_scb *) skb->cb)->urb; + while ((skb = skb_dequeue(&data->pending_q))) { + urb = ((struct bfusb_data_scb *) skb->cb)->urb; usb_kill_urb(urb); - skb_queue_tail(&bfusb->completed_q, skb); + skb_queue_tail(&data->completed_q, skb); } - while ((urb = bfusb_get_completed(bfusb))) + while ((urb = bfusb_get_completed(data))) usb_free_urb(urb); } - -static int bfusb_send_bulk(struct bfusb *bfusb, struct sk_buff *skb) +static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb) { - struct bfusb_scb *scb = (void *) skb->cb; - struct urb *urb = bfusb_get_completed(bfusb); + struct bfusb_data_scb *scb = (void *) skb->cb; + struct urb *urb = bfusb_get_completed(data); int err, pipe; - BT_DBG("bfusb %p skb %p len %d", bfusb, skb, skb->len); + BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len); if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC))) return -ENOMEM; - pipe = usb_sndbulkpipe(bfusb->udev, bfusb->bulk_out_ep); + pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep); - usb_fill_bulk_urb(urb, bfusb->udev, pipe, skb->data, skb->len, + usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, skb->len, bfusb_tx_complete, skb); scb->urb = urb; - skb_queue_tail(&bfusb->pending_q, skb); + skb_queue_tail(&data->pending_q, skb); err = usb_submit_urb(urb, GFP_ATOMIC); if (err) { BT_ERR("%s bulk tx submit failed urb %p err %d", - bfusb->hdev->name, urb, err); - skb_unlink(skb, &bfusb->pending_q); + data->hdev->name, urb, err); + skb_unlink(skb, &data->pending_q); usb_free_urb(urb); } else - atomic_inc(&bfusb->pending_tx); + atomic_inc(&data->pending_tx); return err; } -static void bfusb_tx_wakeup(struct bfusb *bfusb) +static void bfusb_tx_wakeup(struct bfusb_data *data) { struct sk_buff *skb; - BT_DBG("bfusb %p", bfusb); + BT_DBG("bfusb %p", data); - if (test_and_set_bit(BFUSB_TX_PROCESS, &bfusb->state)) { - set_bit(BFUSB_TX_WAKEUP, &bfusb->state); + if (test_and_set_bit(BFUSB_TX_PROCESS, &data->state)) { + set_bit(BFUSB_TX_WAKEUP, &data->state); return; } do { - clear_bit(BFUSB_TX_WAKEUP, &bfusb->state); + clear_bit(BFUSB_TX_WAKEUP, &data->state); - while ((atomic_read(&bfusb->pending_tx) < BFUSB_MAX_BULK_TX) && - (skb = skb_dequeue(&bfusb->transmit_q))) { - if (bfusb_send_bulk(bfusb, skb) < 0) { - skb_queue_head(&bfusb->transmit_q, skb); + while ((atomic_read(&data->pending_tx) < BFUSB_MAX_BULK_TX) && + (skb = skb_dequeue(&data->transmit_q))) { + if (bfusb_send_bulk(data, skb) < 0) { + skb_queue_head(&data->transmit_q, skb); break; } } - } while (test_bit(BFUSB_TX_WAKEUP, &bfusb->state)); + } while (test_bit(BFUSB_TX_WAKEUP, &data->state)); - clear_bit(BFUSB_TX_PROCESS, &bfusb->state); + clear_bit(BFUSB_TX_PROCESS, &data->state); } static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs) { struct sk_buff *skb = (struct sk_buff *) urb->context; - struct bfusb *bfusb = (struct bfusb *) skb->dev; + struct bfusb_data *data = (struct bfusb_data *) skb->dev; - BT_DBG("bfusb %p urb %p skb %p len %d", bfusb, urb, skb, skb->len); + BT_DBG("bfusb %p urb %p skb %p len %d", data, urb, skb, skb->len); - atomic_dec(&bfusb->pending_tx); + atomic_dec(&data->pending_tx); - if (!test_bit(HCI_RUNNING, &bfusb->hdev->flags)) + if (!test_bit(HCI_RUNNING, &data->hdev->flags)) return; if (!urb->status) - bfusb->hdev->stat.byte_tx += skb->len; + data->hdev->stat.byte_tx += skb->len; else - bfusb->hdev->stat.err_tx++; + data->hdev->stat.err_tx++; - read_lock(&bfusb->lock); + read_lock(&data->lock); - skb_unlink(skb, &bfusb->pending_q); - skb_queue_tail(&bfusb->completed_q, skb); + skb_unlink(skb, &data->pending_q); + skb_queue_tail(&data->completed_q, skb); - bfusb_tx_wakeup(bfusb); + bfusb_tx_wakeup(data); - read_unlock(&bfusb->lock); + read_unlock(&data->lock); } -static int bfusb_rx_submit(struct bfusb *bfusb, struct urb *urb) +static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb) { - struct bfusb_scb *scb; + struct bfusb_data_scb *scb; struct sk_buff *skb; int err, pipe, size = HCI_MAX_FRAME_SIZE + 32; @@ -232,28 +229,29 @@ static int bfusb_rx_submit(struct bfusb *bfusb, struct urb *urb) if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC))) return -ENOMEM; - if (!(skb = bt_skb_alloc(size, GFP_ATOMIC))) { + skb = bt_skb_alloc(size, GFP_ATOMIC); + if (!skb) { usb_free_urb(urb); return -ENOMEM; } - skb->dev = (void *) bfusb; + skb->dev = (void *) data; - scb = (struct bfusb_scb *) skb->cb; + scb = (struct bfusb_data_scb *) skb->cb; scb->urb = urb; - pipe = usb_rcvbulkpipe(bfusb->udev, bfusb->bulk_in_ep); + pipe = usb_rcvbulkpipe(data->udev, data->bulk_in_ep); - usb_fill_bulk_urb(urb, bfusb->udev, pipe, skb->data, size, + usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, size, bfusb_rx_complete, skb); - skb_queue_tail(&bfusb->pending_q, skb); + skb_queue_tail(&data->pending_q, skb); err = usb_submit_urb(urb, GFP_ATOMIC); if (err) { BT_ERR("%s bulk rx submit failed urb %p err %d", - bfusb->hdev->name, urb, err); - skb_unlink(skb, &bfusb->pending_q); + data->hdev->name, urb, err); + skb_unlink(skb, &data->pending_q); kfree_skb(skb); usb_free_urb(urb); } @@ -261,15 +259,15 @@ static int bfusb_rx_submit(struct bfusb *bfusb, struct urb *urb) return err; } -static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char *data, int len) +static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned char *buf, int len) { - BT_DBG("bfusb %p hdr 0x%02x data %p len %d", bfusb, hdr, data, len); + BT_DBG("bfusb %p hdr 0x%02x data %p len %d", data, hdr, buf, len); if (hdr & 0x10) { - BT_ERR("%s error in block", bfusb->hdev->name); - if (bfusb->reassembly) - kfree_skb(bfusb->reassembly); - bfusb->reassembly = NULL; + BT_ERR("%s error in block", data->hdev->name); + if (data->reassembly) + kfree_skb(data->reassembly); + data->reassembly = NULL; return -EIO; } @@ -278,46 +276,46 @@ static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char * unsigned char pkt_type; int pkt_len = 0; - if (bfusb->reassembly) { - BT_ERR("%s unexpected start block", bfusb->hdev->name); - kfree_skb(bfusb->reassembly); - bfusb->reassembly = NULL; + if (data->reassembly) { + BT_ERR("%s unexpected start block", data->hdev->name); + kfree_skb(data->reassembly); + data->reassembly = NULL; } if (len < 1) { - BT_ERR("%s no packet type found", bfusb->hdev->name); + BT_ERR("%s no packet type found", data->hdev->name); return -EPROTO; } - pkt_type = *data++; len--; + pkt_type = *buf++; len--; switch (pkt_type) { case HCI_EVENT_PKT: if (len >= HCI_EVENT_HDR_SIZE) { - struct hci_event_hdr *hdr = (struct hci_event_hdr *) data; + struct hci_event_hdr *hdr = (struct hci_event_hdr *) buf; pkt_len = HCI_EVENT_HDR_SIZE + hdr->plen; } else { - BT_ERR("%s event block is too short", bfusb->hdev->name); + BT_ERR("%s event block is too short", data->hdev->name); return -EILSEQ; } break; case HCI_ACLDATA_PKT: if (len >= HCI_ACL_HDR_SIZE) { - struct hci_acl_hdr *hdr = (struct hci_acl_hdr *) data; + struct hci_acl_hdr *hdr = (struct hci_acl_hdr *) buf; pkt_len = HCI_ACL_HDR_SIZE + __le16_to_cpu(hdr->dlen); } else { - BT_ERR("%s data block is too short", bfusb->hdev->name); + BT_ERR("%s data block is too short", data->hdev->name); return -EILSEQ; } break; case HCI_SCODATA_PKT: if (len >= HCI_SCO_HDR_SIZE) { - struct hci_sco_hdr *hdr = (struct hci_sco_hdr *) data; + struct hci_sco_hdr *hdr = (struct hci_sco_hdr *) buf; pkt_len = HCI_SCO_HDR_SIZE + hdr->dlen; } else { - BT_ERR("%s audio block is too short", bfusb->hdev->name); + BT_ERR("%s audio block is too short", data->hdev->name); return -EILSEQ; } break; @@ -325,27 +323,27 @@ static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char * skb = bt_skb_alloc(pkt_len, GFP_ATOMIC); if (!skb) { - BT_ERR("%s no memory for the packet", bfusb->hdev->name); + BT_ERR("%s no memory for the packet", data->hdev->name); return -ENOMEM; } - skb->dev = (void *) bfusb->hdev; + skb->dev = (void *) data->hdev; bt_cb(skb)->pkt_type = pkt_type; - bfusb->reassembly = skb; + data->reassembly = skb; } else { - if (!bfusb->reassembly) { - BT_ERR("%s unexpected continuation block", bfusb->hdev->name); + if (!data->reassembly) { + BT_ERR("%s unexpected continuation block", data->hdev->name); return -EIO; } } if (len > 0) - memcpy(skb_put(bfusb->reassembly, len), data, len); + memcpy(skb_put(data->reassembly, len), buf, len); if (hdr & 0x08) { - hci_recv_frame(bfusb->reassembly); - bfusb->reassembly = NULL; + hci_recv_frame(data->reassembly); + data->reassembly = NULL; } return 0; @@ -354,22 +352,22 @@ static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char * static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs) { struct sk_buff *skb = (struct sk_buff *) urb->context; - struct bfusb *bfusb = (struct bfusb *) skb->dev; + struct bfusb_data *data = (struct bfusb_data *) skb->dev; unsigned char *buf = urb->transfer_buffer; int count = urb->actual_length; int err, hdr, len; BT_DBG("bfusb %p urb %p skb %p len %d", bfusb, urb, skb, skb->len); - read_lock(&bfusb->lock); + read_lock(&data->lock); - if (!test_bit(HCI_RUNNING, &bfusb->hdev->flags)) + if (!test_bit(HCI_RUNNING, &data->hdev->flags)) goto unlock; if (urb->status || !count) goto resubmit; - bfusb->hdev->stat.byte_rx += count; + data->hdev->stat.byte_rx += count; skb_put(skb, count); @@ -388,90 +386,89 @@ static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs) if (count < len) { BT_ERR("%s block extends over URB buffer ranges", - bfusb->hdev->name); + data->hdev->name); } if ((hdr & 0xe1) == 0xc1) - bfusb_recv_block(bfusb, hdr, buf, len); + bfusb_recv_block(data, hdr, buf, len); count -= len; buf += len; } - skb_unlink(skb, &bfusb->pending_q); + skb_unlink(skb, &data->pending_q); kfree_skb(skb); - bfusb_rx_submit(bfusb, urb); + bfusb_rx_submit(data, urb); - read_unlock(&bfusb->lock); + read_unlock(&data->lock); return; resubmit: - urb->dev = bfusb->udev; + urb->dev = data->udev; err = usb_submit_urb(urb, GFP_ATOMIC); if (err) { BT_ERR("%s bulk resubmit failed urb %p err %d", - bfusb->hdev->name, urb, err); + data->hdev->name, urb, err); } unlock: - read_unlock(&bfusb->lock); + read_unlock(&data->lock); } - static int bfusb_open(struct hci_dev *hdev) { - struct bfusb *bfusb = (struct bfusb *) hdev->driver_data; + struct bfusb_data *data = hdev->driver_data; unsigned long flags; int i, err; - BT_DBG("hdev %p bfusb %p", hdev, bfusb); + BT_DBG("hdev %p bfusb %p", hdev, data); if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) return 0; - write_lock_irqsave(&bfusb->lock, flags); + write_lock_irqsave(&data->lock, flags); - err = bfusb_rx_submit(bfusb, NULL); + err = bfusb_rx_submit(data, NULL); if (!err) { for (i = 1; i < BFUSB_MAX_BULK_RX; i++) - bfusb_rx_submit(bfusb, NULL); + bfusb_rx_submit(data, NULL); } else { clear_bit(HCI_RUNNING, &hdev->flags); } - write_unlock_irqrestore(&bfusb->lock, flags); + write_unlock_irqrestore(&data->lock, flags); return err; } static int bfusb_flush(struct hci_dev *hdev) { - struct bfusb *bfusb = (struct bfusb *) hdev->driver_data; + struct bfusb_data *data = hdev->driver_data; - BT_DBG("hdev %p bfusb %p", hdev, bfusb); + BT_DBG("hdev %p bfusb %p", hdev, data); - skb_queue_purge(&bfusb->transmit_q); + skb_queue_purge(&data->transmit_q); return 0; } static int bfusb_close(struct hci_dev *hdev) { - struct bfusb *bfusb = (struct bfusb *) hdev->driver_data; + struct bfusb_data *data = hdev->driver_data; unsigned long flags; - BT_DBG("hdev %p bfusb %p", hdev, bfusb); + BT_DBG("hdev %p bfusb %p", hdev, data); if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) return 0; - write_lock_irqsave(&bfusb->lock, flags); - write_unlock_irqrestore(&bfusb->lock, flags); + write_lock_irqsave(&data->lock, flags); + write_unlock_irqrestore(&data->lock, flags); - bfusb_unlink_urbs(bfusb); + bfusb_unlink_urbs(data); bfusb_flush(hdev); return 0; @@ -480,7 +477,7 @@ static int bfusb_close(struct hci_dev *hdev) static int bfusb_send_frame(struct sk_buff *skb) { struct hci_dev *hdev = (struct hci_dev *) skb->dev; - struct bfusb *bfusb; + struct bfusb_data *data; struct sk_buff *nskb; unsigned char buf[3]; int sent = 0, size, count; @@ -495,7 +492,7 @@ static int bfusb_send_frame(struct sk_buff *skb) if (!test_bit(HCI_RUNNING, &hdev->flags)) return -EBUSY; - bfusb = (struct bfusb *) hdev->driver_data; + data = hdev->driver_data; switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: @@ -515,12 +512,13 @@ static int bfusb_send_frame(struct sk_buff *skb) count = skb->len; /* Max HCI frame size seems to be 1511 + 1 */ - if (!(nskb = bt_skb_alloc(count + 32, GFP_ATOMIC))) { + nskb = bt_skb_alloc(count + 32, GFP_ATOMIC); + if (!nskb) { BT_ERR("Can't allocate memory for new packet"); return -ENOMEM; } - nskb->dev = (void *) bfusb; + nskb->dev = (void *) data; while (count) { size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE); @@ -537,18 +535,18 @@ static int bfusb_send_frame(struct sk_buff *skb) } /* Don't send frame with multiple size of bulk max packet */ - if ((nskb->len % bfusb->bulk_pkt_size) == 0) { + if ((nskb->len % data->bulk_pkt_size) == 0) { buf[0] = 0xdd; buf[1] = 0x00; memcpy(skb_put(nskb, 2), buf, 2); } - read_lock(&bfusb->lock); + read_lock(&data->lock); - skb_queue_tail(&bfusb->transmit_q, nskb); - bfusb_tx_wakeup(bfusb); + skb_queue_tail(&data->transmit_q, nskb); + bfusb_tx_wakeup(data); - read_unlock(&bfusb->lock); + read_unlock(&data->lock); kfree_skb(skb); @@ -557,11 +555,11 @@ static int bfusb_send_frame(struct sk_buff *skb) static void bfusb_destruct(struct hci_dev *hdev) { - struct bfusb *bfusb = (struct bfusb *) hdev->driver_data; + struct bfusb_data *data = hdev->driver_data; - BT_DBG("hdev %p bfusb %p", hdev, bfusb); + BT_DBG("hdev %p bfusb %p", hdev, data); - kfree(bfusb); + kfree(data); } static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) @@ -569,25 +567,24 @@ static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg return -ENOIOCTLCMD; } - -static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int count) +static int bfusb_load_firmware(struct bfusb_data *data, unsigned char *firmware, int count) { unsigned char *buf; int err, pipe, len, size, sent = 0; - BT_DBG("bfusb %p udev %p", bfusb, bfusb->udev); + BT_DBG("bfusb %p udev %p", data, data->udev); BT_INFO("BlueFRITZ! USB loading firmware"); - pipe = usb_sndctrlpipe(bfusb->udev, 0); + pipe = usb_sndctrlpipe(data->udev, 0); - if (usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION, + if (usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, 0, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT) < 0) { BT_ERR("Can't change to loading configuration"); return -EBUSY; } - bfusb->udev->toggle[0] = bfusb->udev->toggle[1] = 0; + data->udev->toggle[0] = data->udev->toggle[1] = 0; buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_ATOMIC); if (!buf) { @@ -595,14 +592,14 @@ static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int return -ENOMEM; } - pipe = usb_sndbulkpipe(bfusb->udev, bfusb->bulk_out_ep); + pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep); while (count) { size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE + 3); memcpy(buf, firmware + sent, size); - err = usb_bulk_msg(bfusb->udev, pipe, buf, size, + err = usb_bulk_msg(data->udev, pipe, buf, size, &len, BFUSB_BLOCK_TIMEOUT); if (err || (len != size)) { @@ -614,21 +611,23 @@ static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int count -= size; } - if ((err = usb_bulk_msg(bfusb->udev, pipe, NULL, 0, - &len, BFUSB_BLOCK_TIMEOUT)) < 0) { + err = usb_bulk_msg(data->udev, pipe, NULL, 0, + &len, BFUSB_BLOCK_TIMEOUT); + if (err < 0) { BT_ERR("Error in null packet request"); goto error; } - pipe = usb_sndctrlpipe(bfusb->udev, 0); + pipe = usb_sndctrlpipe(data->udev, 0); - if ((err = usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION, - 0, 2, 0, NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) { + err = usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, + 0, 2, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); + if (err < 0) { BT_ERR("Can't change to running configuration"); goto error; } - bfusb->udev->toggle[0] = bfusb->udev->toggle[1] = 0; + data->udev->toggle[0] = data->udev->toggle[1] = 0; BT_INFO("BlueFRITZ! USB device ready"); @@ -638,9 +637,9 @@ static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int error: kfree(buf); - pipe = usb_sndctrlpipe(bfusb->udev, 0); + pipe = usb_sndctrlpipe(data->udev, 0); - usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION, + usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, 0, 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); return err; @@ -653,7 +652,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i struct usb_host_endpoint *bulk_out_ep; struct usb_host_endpoint *bulk_in_ep; struct hci_dev *hdev; - struct bfusb *bfusb; + struct bfusb_data *data; BT_DBG("intf %p id %p", intf, id); @@ -673,23 +672,24 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i } /* Initialize control structure and load firmware */ - if (!(bfusb = kzalloc(sizeof(struct bfusb), GFP_KERNEL))) { + data = kzalloc(sizeof(struct bfusb_data), GFP_KERNEL); + if (!data) { BT_ERR("Can't allocate memory for control structure"); goto done; } - bfusb->udev = udev; - bfusb->bulk_in_ep = bulk_in_ep->desc.bEndpointAddress; - bfusb->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress; - bfusb->bulk_pkt_size = le16_to_cpu(bulk_out_ep->desc.wMaxPacketSize); + data->udev = udev; + data->bulk_in_ep = bulk_in_ep->desc.bEndpointAddress; + data->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress; + data->bulk_pkt_size = le16_to_cpu(bulk_out_ep->desc.wMaxPacketSize); - rwlock_init(&bfusb->lock); + rwlock_init(&data->lock); - bfusb->reassembly = NULL; + data->reassembly = NULL; - skb_queue_head_init(&bfusb->transmit_q); - skb_queue_head_init(&bfusb->pending_q); - skb_queue_head_init(&bfusb->completed_q); + skb_queue_head_init(&data->transmit_q); + skb_queue_head_init(&data->pending_q); + skb_queue_head_init(&data->completed_q); if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) { BT_ERR("Firmware request failed"); @@ -698,7 +698,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i BT_DBG("firmware data %p size %d", firmware->data, firmware->size); - if (bfusb_load_firmware(bfusb, firmware->data, firmware->size) < 0) { + if (bfusb_load_firmware(data, firmware->data, firmware->size) < 0) { BT_ERR("Firmware loading failed"); goto release; } @@ -712,10 +712,10 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i goto error; } - bfusb->hdev = hdev; + data->hdev = hdev; hdev->type = HCI_USB; - hdev->driver_data = bfusb; + hdev->driver_data = data; SET_HCIDEV_DEV(hdev, &intf->dev); hdev->open = bfusb_open; @@ -733,7 +733,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i goto error; } - usb_set_intfdata(intf, bfusb); + usb_set_intfdata(intf, data); return 0; @@ -741,7 +741,7 @@ release: release_firmware(firmware); error: - kfree(bfusb); + kfree(data); done: return -EIO; @@ -749,8 +749,8 @@ done: static void bfusb_disconnect(struct usb_interface *intf) { - struct bfusb *bfusb = usb_get_intfdata(intf); - struct hci_dev *hdev = bfusb->hdev; + struct bfusb_data *data = usb_get_intfdata(intf); + struct hci_dev *hdev = data->hdev; BT_DBG("intf %p", intf); @@ -780,7 +780,8 @@ static int __init bfusb_init(void) BT_INFO("BlueFRITZ! USB driver ver %s", VERSION); - if ((err = usb_register(&bfusb_driver)) < 0) + err = usb_register(&bfusb_driver); + if (err < 0) BT_ERR("Failed to register BlueFRITZ! USB driver"); return err; diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 473a13b22b2..8eebf9ca378 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -20,7 +20,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -740,6 +739,7 @@ static int bluecard_open(bluecard_info_t *info) hdev->type = HCI_PCCARD; hdev->driver_data = info; + SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = bluecard_hci_open; hdev->close = bluecard_hci_close; diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 9446960ac74..e0231dc2cb1 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c @@ -21,7 +21,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index b94ac2f9f7b..df7bb016df4 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -21,7 +21,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -583,6 +582,7 @@ static int bt3c_open(bt3c_info_t *info) hdev->type = HCI_PCCARD; hdev->driver_data = info; + SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = bt3c_hci_open; hdev->close = bt3c_hci_close; diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 9ce4c93467e..746ccca97f6 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -20,7 +20,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -503,6 +502,7 @@ static int btuart_open(btuart_info_t *info) hdev->type = HCI_PCCARD; hdev->driver_data = info; + SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = btuart_hci_open; hdev->close = btuart_hci_close; diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index a71a240611e..0e99def8a1e 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -20,7 +20,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -423,6 +422,9 @@ static int dtl1_hci_send_frame(struct sk_buff *skb) nsh.len = skb->len; s = bt_skb_alloc(NSHL + skb->len + 1, GFP_ATOMIC); + if (!s) + return -ENOMEM; + skb_reserve(s, NSHL); memcpy(skb_put(s, skb->len), skb->data, skb->len); if (skb->len & 0x0001) @@ -482,6 +484,7 @@ static int dtl1_open(dtl1_info_t *info) hdev->type = HCI_PCCARD; hdev->driver_data = info; + SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = dtl1_hci_open; hdev->close = dtl1_hci_close; diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c index 7bd4ef90411..d0cface535f 100644 --- a/drivers/bluetooth/hci_bcsp.c +++ b/drivers/bluetooth/hci_bcsp.c @@ -22,7 +22,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index 4804d474dc8..ad62abbbb73 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c @@ -23,7 +23,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 613673b12fa..420b645c4c9 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -23,7 +23,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -192,7 +191,7 @@ static int hci_uart_flush(struct hci_dev *hdev) /* Flush any pending characters in the driver and discipline. */ tty_ldisc_flush(tty); - if (tty->driver->flush_buffer) + if (tty->driver && tty->driver->flush_buffer) tty->driver->flush_buffer(tty); if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) @@ -242,15 +241,11 @@ static int hci_uart_send_frame(struct sk_buff *skb) static void hci_uart_destruct(struct hci_dev *hdev) { - struct hci_uart *hu; - if (!hdev) return; BT_DBG("%s", hdev->name); - - hu = (struct hci_uart *) hdev->driver_data; - kfree(hu); + kfree(hdev->driver_data); } /* ------ LDISC part ------ */ @@ -273,7 +268,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) return -EEXIST; if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) { - BT_ERR("Can't allocate controll structure"); + BT_ERR("Can't allocate control structure"); return -ENFILE; } @@ -291,7 +286,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) if (tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty); - if (tty->driver->flush_buffer) + if (tty->driver && tty->driver->flush_buffer) tty->driver->flush_buffer(tty); return 0; @@ -361,7 +356,7 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty) * * Return Value: None */ -static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char *flags, int count) +static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count) { struct hci_uart *hu = (void *)tty->disc_data; @@ -376,7 +371,8 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char hu->hdev->stat.byte_rx += count; spin_unlock(&hu->rx_lock); - if (test_and_clear_bit(TTY_THROTTLED,&tty->flags) && tty->driver->unthrottle) + if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && + tty->driver->unthrottle) tty->driver->unthrottle(tty); } diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index 92382e82328..0801af4ad2b 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c @@ -31,7 +31,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -68,6 +67,8 @@ static int ignore = 0; static int ignore_dga = 0; static int ignore_csr = 0; static int ignore_sniffer = 0; +static int disable_scofix = 0; +static int force_scofix = 0; static int reset = 0; #ifdef CONFIG_BT_HCIUSB_SCO @@ -95,6 +96,9 @@ static struct usb_device_id bluetooth_ids[] = { /* Ericsson with non-standard id */ { USB_DEVICE(0x0bdb, 0x1002) }, + /* Canyon CN-BTU1 with HID interfaces */ + { USB_DEVICE(0x0c10, 0x0000), .driver_info = HCI_RESET }, + { } /* Terminating entry */ }; @@ -108,9 +112,12 @@ static struct usb_device_id blacklist_ids[] = { { USB_DEVICE(0x0a5c, 0x2033), .driver_info = HCI_IGNORE }, /* Broadcom BCM2035 */ - { USB_DEVICE(0x0a5c, 0x200a), .driver_info = HCI_RESET | HCI_BROKEN_ISOC }, + { USB_DEVICE(0x0a5c, 0x200a), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU }, { USB_DEVICE(0x0a5c, 0x2009), .driver_info = HCI_BCM92035 }, + /* IBM/Lenovo ThinkPad with Broadcom chip */ + { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_WRONG_SCO_MTU }, + /* Microsoft Wireless Transceiver for Bluetooth 2.0 */ { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET }, @@ -120,8 +127,13 @@ static struct usb_device_id blacklist_ids[] = { /* ISSC Bluetooth Adapter v3.1 */ { USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET }, - /* RTX Telecom based adapter with buggy SCO support */ + /* RTX Telecom based adapters with buggy SCO support */ { USB_DEVICE(0x0400, 0x0807), .driver_info = HCI_BROKEN_ISOC }, + { USB_DEVICE(0x0400, 0x080a), .driver_info = HCI_BROKEN_ISOC }, + + /* Belkin F8T012 and F8T013 devices */ + { USB_DEVICE(0x050d, 0x0012), .driver_info = HCI_WRONG_SCO_MTU }, + { USB_DEVICE(0x050d, 0x0013), .driver_info = HCI_WRONG_SCO_MTU }, /* Digianswer devices */ { USB_DEVICE(0x08fd, 0x0001), .driver_info = HCI_DIGIANSWER }, @@ -130,6 +142,9 @@ static struct usb_device_id blacklist_ids[] = { /* CSR BlueCore Bluetooth Sniffer */ { USB_DEVICE(0x0a12, 0x0002), .driver_info = HCI_SNIFFER }, + /* Frontline ComProbe Bluetooth Sniffer */ + { USB_DEVICE(0x16d3, 0x0002), .driver_info = HCI_SNIFFER }, + { } /* Terminating entry */ }; @@ -985,6 +1000,11 @@ static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id if (reset || id->driver_info & HCI_RESET) set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks); + if (force_scofix || id->driver_info & HCI_WRONG_SCO_MTU) { + if (!disable_scofix) + set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks); + } + if (id->driver_info & HCI_SNIFFER) { if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); @@ -1043,10 +1063,81 @@ static void hci_usb_disconnect(struct usb_interface *intf) hci_free_dev(hdev); } +static int hci_usb_suspend(struct usb_interface *intf, pm_message_t message) +{ + struct hci_usb *husb = usb_get_intfdata(intf); + struct list_head killed; + unsigned long flags; + int i; + + if (!husb || intf == husb->isoc_iface) + return 0; + + hci_suspend_dev(husb->hdev); + + INIT_LIST_HEAD(&killed); + + for (i = 0; i < 4; i++) { + struct _urb_queue *q = &husb->pending_q[i]; + struct _urb *_urb, *_tmp; + + while ((_urb = _urb_dequeue(q))) { + /* reset queue since _urb_dequeue sets it to NULL */ + _urb->queue = q; + usb_kill_urb(&_urb->urb); + list_add(&_urb->list, &killed); + } + + spin_lock_irqsave(&q->lock, flags); + + list_for_each_entry_safe(_urb, _tmp, &killed, list) { + list_move_tail(&_urb->list, &q->head); + } + + spin_unlock_irqrestore(&q->lock, flags); + } + + return 0; +} + +static int hci_usb_resume(struct usb_interface *intf) +{ + struct hci_usb *husb = usb_get_intfdata(intf); + unsigned long flags; + int i, err = 0; + + if (!husb || intf == husb->isoc_iface) + return 0; + + for (i = 0; i < 4; i++) { + struct _urb_queue *q = &husb->pending_q[i]; + struct _urb *_urb; + + spin_lock_irqsave(&q->lock, flags); + + list_for_each_entry(_urb, &q->head, list) { + err = usb_submit_urb(&_urb->urb, GFP_ATOMIC); + if (err) + break; + } + + spin_unlock_irqrestore(&q->lock, flags); + + if (err) + return -EIO; + } + + hci_resume_dev(husb->hdev); + + return 0; +} + static struct usb_driver hci_usb_driver = { .name = "hci_usb", .probe = hci_usb_probe, .disconnect = hci_usb_disconnect, + .suspend = hci_usb_suspend, + .resume = hci_usb_resume, .id_table = bluetooth_ids, }; @@ -1082,6 +1173,12 @@ MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001"); module_param(ignore_sniffer, bool, 0644); MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002"); +module_param(disable_scofix, bool, 0644); +MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size"); + +module_param(force_scofix, bool, 0644); +MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size"); + module_param(reset, bool, 0644); MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); diff --git a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h index 37100a6ea1a..963fc55cdc8 100644 --- a/drivers/bluetooth/hci_usb.h +++ b/drivers/bluetooth/hci_usb.h @@ -35,6 +35,7 @@ #define HCI_SNIFFER 0x10 #define HCI_BCM92035 0x20 #define HCI_BROKEN_ISOC 0x40 +#define HCI_WRONG_SCO_MTU 0x80 #define HCI_MAX_IFACE_NUM 3 diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 85738223ff0..a278d98a915 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -2,9 +2,9 @@ * * Bluetooth virtual HCI driver * - * Copyright (C) 2000-2001 Qualcomm Incorporated - * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> - * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> + * Copyright (C) 2000-2001 Qualcomm Incorporated + * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> + * Copyright (C) 2004-2006 Marcel Holtmann <marcel@holtmann.org> * * * This program is free software; you can redistribute it and/or modify @@ -23,7 +23,6 @@ * */ -#include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -73,21 +72,21 @@ static int vhci_open_dev(struct hci_dev *hdev) static int vhci_close_dev(struct hci_dev *hdev) { - struct vhci_data *vhci = hdev->driver_data; + struct vhci_data *data = hdev->driver_data; if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) return 0; - skb_queue_purge(&vhci->readq); + skb_queue_purge(&data->readq); return 0; } static int vhci_flush(struct hci_dev *hdev) { - struct vhci_data *vhci = hdev->driver_data; + struct vhci_data *data = hdev->driver_data; - skb_queue_purge(&vhci->readq); + skb_queue_purge(&data->readq); return 0; } @@ -95,7 +94,7 @@ static int vhci_flush(struct hci_dev *hdev) static int vhci_send_frame(struct sk_buff *skb) { struct hci_dev* hdev = (struct hci_dev *) skb->dev; - struct vhci_data *vhci; + struct vhci_data *data; if (!hdev) { BT_ERR("Frame for unknown HCI device (hdev=NULL)"); @@ -105,15 +104,15 @@ static int vhci_send_frame(struct sk_buff *skb) if (!test_bit(HCI_RUNNING, &hdev->flags)) return -EBUSY; - vhci = hdev->driver_data; + data = hdev->driver_data; memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); - skb_queue_tail(&vhci->readq, skb); + skb_queue_tail(&data->readq, skb); - if (vhci->flags & VHCI_FASYNC) - kill_fasync(&vhci->fasync, SIGIO, POLL_IN); + if (data->flags & VHCI_FASYNC) + kill_fasync(&data->fasync, SIGIO, POLL_IN); - wake_up_interruptible(&vhci->read_wait); + wake_up_interruptible(&data->read_wait); return 0; } @@ -123,7 +122,7 @@ static void vhci_destruct(struct hci_dev *hdev) kfree(hdev->driver_data); } -static inline ssize_t vhci_get_user(struct vhci_data *vhci, +static inline ssize_t vhci_get_user(struct vhci_data *data, const char __user *buf, size_t count) { struct sk_buff *skb; @@ -140,7 +139,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *vhci, return -EFAULT; } - skb->dev = (void *) vhci->hdev; + skb->dev = (void *) data->hdev; bt_cb(skb)->pkt_type = *((__u8 *) skb->data); skb_pull(skb, 1); @@ -149,7 +148,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *vhci, return count; } -static inline ssize_t vhci_put_user(struct vhci_data *vhci, +static inline ssize_t vhci_put_user(struct vhci_data *data, struct sk_buff *skb, char __user *buf, int count) { char __user *ptr = buf; @@ -162,42 +161,43 @@ static inline ssize_t vhci_put_user(struct vhci_data *vhci, total += len; - vhci->hdev->stat.byte_tx += len; + data->hdev->stat.byte_tx += len; switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: - vhci->hdev->stat.cmd_tx++; + data->hdev->stat.cmd_tx++; break; case HCI_ACLDATA_PKT: - vhci->hdev->stat.acl_tx++; + data->hdev->stat.acl_tx++; break; case HCI_SCODATA_PKT: - vhci->hdev->stat.cmd_tx++; + data->hdev->stat.cmd_tx++; break; }; return total; } -static loff_t vhci_llseek(struct file * file, loff_t offset, int origin) +static loff_t vhci_llseek(struct file *file, loff_t offset, int origin) { return -ESPIPE; } -static ssize_t vhci_read(struct file * file, char __user * buf, size_t count, loff_t *pos) +static ssize_t vhci_read(struct file *file, + char __user *buf, size_t count, loff_t *pos) { DECLARE_WAITQUEUE(wait, current); - struct vhci_data *vhci = file->private_data; + struct vhci_data *data = file->private_data; struct sk_buff *skb; ssize_t ret = 0; - add_wait_queue(&vhci->read_wait, &wait); + add_wait_queue(&data->read_wait, &wait); while (count) { set_current_state(TASK_INTERRUPTIBLE); - skb = skb_dequeue(&vhci->readq); + skb = skb_dequeue(&data->readq); if (!skb) { if (file->f_flags & O_NONBLOCK) { ret = -EAGAIN; @@ -214,7 +214,7 @@ static ssize_t vhci_read(struct file * file, char __user * buf, size_t count, lo } if (access_ok(VERIFY_WRITE, buf, count)) - ret = vhci_put_user(vhci, skb, buf, count); + ret = vhci_put_user(data, skb, buf, count); else ret = -EFAULT; @@ -222,7 +222,7 @@ static ssize_t vhci_read(struct file * file, char __user * buf, size_t count, lo break; } set_current_state(TASK_RUNNING); - remove_wait_queue(&vhci->read_wait, &wait); + remove_wait_queue(&data->read_wait, &wait); return ret; } @@ -230,21 +230,21 @@ static ssize_t vhci_read(struct file * file, char __user * buf, size_t count, lo static ssize_t vhci_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { - struct vhci_data *vhci = file->private_data; + struct vhci_data *data = file->private_data; if (!access_ok(VERIFY_READ, buf, count)) return -EFAULT; - return vhci_get_user(vhci, buf, count); + return vhci_get_user(data, buf, count); } static unsigned int vhci_poll(struct file *file, poll_table *wait) { - struct vhci_data *vhci = file->private_data; + struct vhci_data *data = file->private_data; - poll_wait(file, &vhci->read_wait, wait); + poll_wait(file, &data->read_wait, wait); - if (!skb_queue_empty(&vhci->readq)) + if (!skb_queue_empty(&data->readq)) return POLLIN | POLLRDNORM; return POLLOUT | POLLWRNORM; @@ -258,27 +258,26 @@ static int vhci_ioctl(struct inode *inode, struct file *file, static int vhci_open(struct inode *inode, struct file *file) { - struct vhci_data *vhci; + struct vhci_data *data; struct hci_dev *hdev; - vhci = kzalloc(sizeof(struct vhci_data), GFP_KERNEL); - if (!vhci) + data = kzalloc(sizeof(struct vhci_data), GFP_KERNEL); + if (!data) return -ENOMEM; - skb_queue_head_init(&vhci->readq); - init_waitqueue_head(&vhci->read_wait); + skb_queue_head_init(&data->readq); + init_waitqueue_head(&data->read_wait); hdev = hci_alloc_dev(); if (!hdev) { - kfree(vhci); + kfree(data); return -ENOMEM; } - vhci->hdev = hdev; + data->hdev = hdev; - hdev->type = HCI_VHCI; - hdev->driver_data = vhci; - SET_HCIDEV_DEV(hdev, vhci_miscdev.dev); + hdev->type = HCI_VIRTUAL; + hdev->driver_data = data; hdev->open = vhci_open_dev; hdev->close = vhci_close_dev; @@ -290,20 +289,20 @@ static int vhci_open(struct inode *inode, struct file *file) if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); - kfree(vhci); + kfree(data); hci_free_dev(hdev); return -EBUSY; } - file->private_data = vhci; + file->private_data = data; return nonseekable_open(inode, file); } static int vhci_release(struct inode *inode, struct file *file) { - struct vhci_data *vhci = file->private_data; - struct hci_dev *hdev = vhci->hdev; + struct vhci_data *data = file->private_data; + struct hci_dev *hdev = data->hdev; if (hci_unregister_dev(hdev) < 0) { BT_ERR("Can't unregister HCI device %s", hdev->name); @@ -318,17 +317,17 @@ static int vhci_release(struct inode *inode, struct file *file) static int vhci_fasync(int fd, struct file *file, int on) { - struct vhci_data *vhci = file->private_data; + struct vhci_data *data = file->private_data; int err; - err = fasync_helper(fd, file, on, &vhci->fasync); + err = fasync_helper(fd, file, on, &data->fasync); if (err < 0) return err; if (on) - vhci->flags |= VHCI_FASYNC; + data->flags |= VHCI_FASYNC; else - vhci->flags &= ~VHCI_FASYNC; + data->flags &= ~VHCI_FASYNC; return 0; } |