aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/Kconfig1
-rw-r--r--drivers/bluetooth/bfusb.c3
-rw-r--r--drivers/bluetooth/bt3c_cs.c3
-rw-r--r--drivers/bluetooth/hci_bcsp.c44
-rw-r--r--drivers/bluetooth/hci_ldisc.c6
-rw-r--r--drivers/bluetooth/hci_vhci.c14
6 files changed, 32 insertions, 39 deletions
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 075598e1c502..a235ca787465 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -71,6 +71,7 @@ config BT_HCIUART_H4
71config BT_HCIUART_BCSP 71config BT_HCIUART_BCSP
72 bool "BCSP protocol support" 72 bool "BCSP protocol support"
73 depends on BT_HCIUART 73 depends on BT_HCIUART
74 select BITREVERSE
74 help 75 help
75 BCSP (BlueCore Serial Protocol) is serial protocol for communication 76 BCSP (BlueCore Serial Protocol) is serial protocol for communication
76 between Bluetooth device and host. This protocol is required for non 77 between Bluetooth device and host. This protocol is required for non
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index b990805806af..0c211adbc063 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -566,7 +566,8 @@ static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg
566 return -ENOIOCTLCMD; 566 return -ENOIOCTLCMD;
567} 567}
568 568
569static int bfusb_load_firmware(struct bfusb_data *data, unsigned char *firmware, int count) 569static int bfusb_load_firmware(struct bfusb_data *data,
570 const unsigned char *firmware, int count)
570{ 571{
571 unsigned char *buf; 572 unsigned char *buf;
572 int err, pipe, len, size, sent = 0; 573 int err, pipe, len, size, sent = 0;
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 7703d6e06fd9..593b7c595038 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -470,7 +470,8 @@ static int bt3c_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long
470/* ======================== Card services HCI interaction ======================== */ 470/* ======================== Card services HCI interaction ======================== */
471 471
472 472
473static int bt3c_load_firmware(bt3c_info_t *info, unsigned char *firmware, int count) 473static int bt3c_load_firmware(bt3c_info_t *info, const unsigned char *firmware,
474 int count)
474{ 475{
475 char *ptr = (char *) firmware; 476 char *ptr = (char *) firmware;
476 char b[9]; 477 char b[9];
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 696f7528f022..4d37bb312ee3 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -39,6 +39,8 @@
39#include <linux/signal.h> 39#include <linux/signal.h>
40#include <linux/ioctl.h> 40#include <linux/ioctl.h>
41#include <linux/skbuff.h> 41#include <linux/skbuff.h>
42#include <linux/bitrev.h>
43#include <asm/unaligned.h>
42 44
43#include <net/bluetooth/bluetooth.h> 45#include <net/bluetooth/bluetooth.h>
44#include <net/bluetooth/hci_core.h> 46#include <net/bluetooth/hci_core.h>
@@ -124,27 +126,6 @@ static void bcsp_crc_update(u16 *crc, u8 d)
124 *crc = reg; 126 *crc = reg;
125} 127}
126 128
127/*
128 Get reverse of generated crc
129
130 Implementation note
131 The crc generator (bcsp_crc_init() and bcsp_crc_update())
132 creates a reversed crc, so it needs to be swapped back before
133 being passed on.
134*/
135static u16 bcsp_crc_reverse(u16 crc)
136{
137 u16 b, rev;
138
139 for (b = 0, rev = 0; b < 16; b++) {
140 rev = rev << 1;
141 rev |= (crc & 1);
142 crc = crc >> 1;
143 }
144
145 return (rev);
146}
147
148/* ---- BCSP core ---- */ 129/* ---- BCSP core ---- */
149 130
150static void bcsp_slip_msgdelim(struct sk_buff *skb) 131static void bcsp_slip_msgdelim(struct sk_buff *skb)
@@ -235,10 +216,10 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
235 } 216 }
236 217
237 if (hciextn && chan == 5) { 218 if (hciextn && chan == 5) {
238 struct hci_command_hdr *hdr = (struct hci_command_hdr *) data; 219 __le16 opcode = ((struct hci_command_hdr *)data)->opcode;
239 220
240 /* Vendor specific commands */ 221 /* Vendor specific commands */
241 if (hci_opcode_ogf(__le16_to_cpu(hdr->opcode)) == 0x3f) { 222 if (hci_opcode_ogf(__le16_to_cpu(opcode)) == 0x3f) {
242 u8 desc = *(data + HCI_COMMAND_HDR_SIZE); 223 u8 desc = *(data + HCI_COMMAND_HDR_SIZE);
243 if ((desc & 0xf0) == 0xc0) { 224 if ((desc & 0xf0) == 0xc0) {
244 data += HCI_COMMAND_HDR_SIZE + 1; 225 data += HCI_COMMAND_HDR_SIZE + 1;
@@ -296,7 +277,7 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
296 277
297 /* Put CRC */ 278 /* Put CRC */
298 if (bcsp->use_crc) { 279 if (bcsp->use_crc) {
299 bcsp_txmsg_crc = bcsp_crc_reverse(bcsp_txmsg_crc); 280 bcsp_txmsg_crc = bitrev16(bcsp_txmsg_crc);
300 bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff)); 281 bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff));
301 bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff)); 282 bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff));
302 } 283 }
@@ -566,6 +547,11 @@ static void bcsp_complete_rx_pkt(struct hci_uart *hu)
566 bcsp->rx_skb = NULL; 547 bcsp->rx_skb = NULL;
567} 548}
568 549
550static u16 bscp_get_crc(struct bcsp_struct *bcsp)
551{
552 return get_unaligned_be16(&bcsp->rx_skb->data[bcsp->rx_skb->len - 2]);
553}
554
569/* Recv data */ 555/* Recv data */
570static int bcsp_recv(struct hci_uart *hu, void *data, int count) 556static int bcsp_recv(struct hci_uart *hu, void *data, int count)
571{ 557{
@@ -624,14 +610,10 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
624 continue; 610 continue;
625 611
626 case BCSP_W4_CRC: 612 case BCSP_W4_CRC:
627 if (bcsp_crc_reverse(bcsp->message_crc) != 613 if (bitrev16(bcsp->message_crc) != bscp_get_crc(bcsp)) {
628 (bcsp->rx_skb->data[bcsp->rx_skb->len - 2] << 8) +
629 bcsp->rx_skb->data[bcsp->rx_skb->len - 1]) {
630
631 BT_ERR ("Checksum failed: computed %04x received %04x", 614 BT_ERR ("Checksum failed: computed %04x received %04x",
632 bcsp_crc_reverse(bcsp->message_crc), 615 bitrev16(bcsp->message_crc),
633 (bcsp->rx_skb-> data[bcsp->rx_skb->len - 2] << 8) + 616 bscp_get_crc(bcsp));
634 bcsp->rx_skb->data[bcsp->rx_skb->len - 1]);
635 617
636 kfree_skb(bcsp->rx_skb); 618 kfree_skb(bcsp->rx_skb);
637 bcsp->rx_state = BCSP_W4_PKT_DELIMITER; 619 bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index e5cd856a2fea..69df187d74ce 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -282,8 +282,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)
282 /* FIXME: why is this needed. Note don't use ldisc_ref here as the 282 /* FIXME: why is this needed. Note don't use ldisc_ref here as the
283 open path is before the ldisc is referencable */ 283 open path is before the ldisc is referencable */
284 284
285 if (tty->ldisc.flush_buffer) 285 if (tty->ldisc.ops->flush_buffer)
286 tty->ldisc.flush_buffer(tty); 286 tty->ldisc.ops->flush_buffer(tty);
287 tty_driver_flush_buffer(tty); 287 tty_driver_flush_buffer(tty);
288 288
289 return 0; 289 return 0;
@@ -514,7 +514,7 @@ static unsigned int hci_uart_tty_poll(struct tty_struct *tty,
514 514
515static int __init hci_uart_init(void) 515static int __init hci_uart_init(void)
516{ 516{
517 static struct tty_ldisc hci_uart_ldisc; 517 static struct tty_ldisc_ops hci_uart_ldisc;
518 int err; 518 int err;
519 519
520 BT_INFO("HCI UART driver ver %s", VERSION); 520 BT_INFO("HCI UART driver ver %s", VERSION);
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 0638730a4a19..d97700aa54a9 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -28,6 +28,7 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/smp_lock.h>
31#include <linux/types.h> 32#include <linux/types.h>
32#include <linux/errno.h> 33#include <linux/errno.h>
33#include <linux/sched.h> 34#include <linux/sched.h>
@@ -263,9 +264,11 @@ static int vhci_open(struct inode *inode, struct file *file)
263 skb_queue_head_init(&data->readq); 264 skb_queue_head_init(&data->readq);
264 init_waitqueue_head(&data->read_wait); 265 init_waitqueue_head(&data->read_wait);
265 266
267 lock_kernel();
266 hdev = hci_alloc_dev(); 268 hdev = hci_alloc_dev();
267 if (!hdev) { 269 if (!hdev) {
268 kfree(data); 270 kfree(data);
271 unlock_kernel();
269 return -ENOMEM; 272 return -ENOMEM;
270 } 273 }
271 274
@@ -286,10 +289,12 @@ static int vhci_open(struct inode *inode, struct file *file)
286 BT_ERR("Can't register HCI device"); 289 BT_ERR("Can't register HCI device");
287 kfree(data); 290 kfree(data);
288 hci_free_dev(hdev); 291 hci_free_dev(hdev);
292 unlock_kernel();
289 return -EBUSY; 293 return -EBUSY;
290 } 294 }
291 295
292 file->private_data = data; 296 file->private_data = data;
297 unlock_kernel();
293 298
294 return nonseekable_open(inode, file); 299 return nonseekable_open(inode, file);
295} 300}
@@ -313,18 +318,21 @@ static int vhci_release(struct inode *inode, struct file *file)
313static int vhci_fasync(int fd, struct file *file, int on) 318static int vhci_fasync(int fd, struct file *file, int on)
314{ 319{
315 struct vhci_data *data = file->private_data; 320 struct vhci_data *data = file->private_data;
316 int err; 321 int err = 0;
317 322
323 lock_kernel();
318 err = fasync_helper(fd, file, on, &data->fasync); 324 err = fasync_helper(fd, file, on, &data->fasync);
319 if (err < 0) 325 if (err < 0)
320 return err; 326 goto out;
321 327
322 if (on) 328 if (on)
323 data->flags |= VHCI_FASYNC; 329 data->flags |= VHCI_FASYNC;
324 else 330 else
325 data->flags &= ~VHCI_FASYNC; 331 data->flags &= ~VHCI_FASYNC;
326 332
327 return 0; 333out:
334 unlock_kernel();
335 return err;
328} 336}
329 337
330static const struct file_operations vhci_fops = { 338static const struct file_operations vhci_fops = {