aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/bluetooth
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/Kconfig13
-rw-r--r--drivers/bluetooth/Makefile1
-rw-r--r--drivers/bluetooth/ath3k.c189
-rw-r--r--drivers/bluetooth/bcm203x.c2
-rw-r--r--drivers/bluetooth/bfusb.c2
-rw-r--r--drivers/bluetooth/bluecard_cs.c22
-rw-r--r--drivers/bluetooth/bpa10x.c2
-rw-r--r--drivers/bluetooth/bt3c_cs.c19
-rw-r--r--drivers/bluetooth/btmrvl_debugfs.c16
-rw-r--r--drivers/bluetooth/btmrvl_drv.h2
-rw-r--r--drivers/bluetooth/btmrvl_main.c57
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c12
-rw-r--r--drivers/bluetooth/btsdio.c2
-rw-r--r--drivers/bluetooth/btuart_cs.c19
-rw-r--r--drivers/bluetooth/btusb.c5
-rw-r--r--drivers/bluetooth/dtl1_cs.c18
-rw-r--r--drivers/bluetooth/hci_ldisc.c4
-rw-r--r--drivers/bluetooth/hci_vhci.c22
18 files changed, 297 insertions, 110 deletions
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 652367aa6546..058fbccf2f52 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -195,5 +195,16 @@ config BT_MRVL_SDIO
195 Say Y here to compile support for Marvell BT-over-SDIO driver 195 Say Y here to compile support for Marvell BT-over-SDIO driver
196 into the kernel or say M to compile it as module. 196 into the kernel or say M to compile it as module.
197 197
198endmenu 198config BT_ATH3K
199 tristate "Atheros firmware download driver"
200 depends on BT_HCIBTUSB
201 select FW_LOADER
202 help
203 Bluetooth firmware download driver.
204 This driver loads the firmware into the Atheros Bluetooth
205 chipset.
199 206
207 Say Y here to compile support for "Atheros firmware download driver"
208 into the kernel or say M to compile it as module (ath3k).
209
210endmenu
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index b3f57d2d4eb0..7e5aed598121 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_BT_HCIBTUART) += btuart_cs.o
15obj-$(CONFIG_BT_HCIBTUSB) += btusb.o 15obj-$(CONFIG_BT_HCIBTUSB) += btusb.o
16obj-$(CONFIG_BT_HCIBTSDIO) += btsdio.o 16obj-$(CONFIG_BT_HCIBTSDIO) += btsdio.o
17 17
18obj-$(CONFIG_BT_ATH3K) += ath3k.o
18obj-$(CONFIG_BT_MRVL) += btmrvl.o 19obj-$(CONFIG_BT_MRVL) += btmrvl.o
19obj-$(CONFIG_BT_MRVL_SDIO) += btmrvl_sdio.o 20obj-$(CONFIG_BT_MRVL_SDIO) += btmrvl_sdio.o
20 21
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
new file mode 100644
index 000000000000..128cae4e8629
--- /dev/null
+++ b/drivers/bluetooth/ath3k.c
@@ -0,0 +1,189 @@
1/*
2 * Copyright (c) 2008-2009 Atheros Communications Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/slab.h>
25#include <linux/types.h>
26#include <linux/errno.h>
27#include <linux/device.h>
28#include <linux/firmware.h>
29#include <linux/usb.h>
30#include <net/bluetooth/bluetooth.h>
31
32#define VERSION "1.0"
33
34
35static struct usb_device_id ath3k_table[] = {
36 /* Atheros AR3011 */
37 { USB_DEVICE(0x0CF3, 0x3000) },
38 { } /* Terminating entry */
39};
40
41MODULE_DEVICE_TABLE(usb, ath3k_table);
42
43#define USB_REQ_DFU_DNLOAD 1
44#define BULK_SIZE 4096
45
46struct ath3k_data {
47 struct usb_device *udev;
48 u8 *fw_data;
49 u32 fw_size;
50 u32 fw_sent;
51};
52
53static int ath3k_load_firmware(struct ath3k_data *data,
54 unsigned char *firmware,
55 int count)
56{
57 u8 *send_buf;
58 int err, pipe, len, size, sent = 0;
59
60 BT_DBG("ath3k %p udev %p", data, data->udev);
61
62 pipe = usb_sndctrlpipe(data->udev, 0);
63
64 if ((usb_control_msg(data->udev, pipe,
65 USB_REQ_DFU_DNLOAD,
66 USB_TYPE_VENDOR, 0, 0,
67 firmware, 20, USB_CTRL_SET_TIMEOUT)) < 0) {
68 BT_ERR("Can't change to loading configuration err");
69 return -EBUSY;
70 }
71 sent += 20;
72 count -= 20;
73
74 send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC);
75 if (!send_buf) {
76 BT_ERR("Can't allocate memory chunk for firmware");
77 return -ENOMEM;
78 }
79
80 while (count) {
81 size = min_t(uint, count, BULK_SIZE);
82 pipe = usb_sndbulkpipe(data->udev, 0x02);
83 memcpy(send_buf, firmware + sent, size);
84
85 err = usb_bulk_msg(data->udev, pipe, send_buf, size,
86 &len, 3000);
87
88 if (err || (len != size)) {
89 BT_ERR("Error in firmware loading err = %d,"
90 "len = %d, size = %d", err, len, size);
91 goto error;
92 }
93
94 sent += size;
95 count -= size;
96 }
97
98 kfree(send_buf);
99 return 0;
100
101error:
102 kfree(send_buf);
103 return err;
104}
105
106static int ath3k_probe(struct usb_interface *intf,
107 const struct usb_device_id *id)
108{
109 const struct firmware *firmware;
110 struct usb_device *udev = interface_to_usbdev(intf);
111 struct ath3k_data *data;
112 int size;
113
114 BT_DBG("intf %p id %p", intf, id);
115
116 if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
117 return -ENODEV;
118
119 data = kzalloc(sizeof(*data), GFP_KERNEL);
120 if (!data)
121 return -ENOMEM;
122
123 data->udev = udev;
124
125 if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) {
126 kfree(data);
127 return -EIO;
128 }
129
130 size = max_t(uint, firmware->size, 4096);
131 data->fw_data = kmalloc(size, GFP_KERNEL);
132 if (!data->fw_data) {
133 release_firmware(firmware);
134 kfree(data);
135 return -ENOMEM;
136 }
137
138 memcpy(data->fw_data, firmware->data, firmware->size);
139 data->fw_size = firmware->size;
140 data->fw_sent = 0;
141 release_firmware(firmware);
142
143 usb_set_intfdata(intf, data);
144 if (ath3k_load_firmware(data, data->fw_data, data->fw_size)) {
145 usb_set_intfdata(intf, NULL);
146 kfree(data->fw_data);
147 kfree(data);
148 return -EIO;
149 }
150
151 return 0;
152}
153
154static void ath3k_disconnect(struct usb_interface *intf)
155{
156 struct ath3k_data *data = usb_get_intfdata(intf);
157
158 BT_DBG("ath3k_disconnect intf %p", intf);
159
160 kfree(data->fw_data);
161 kfree(data);
162}
163
164static struct usb_driver ath3k_driver = {
165 .name = "ath3k",
166 .probe = ath3k_probe,
167 .disconnect = ath3k_disconnect,
168 .id_table = ath3k_table,
169};
170
171static int __init ath3k_init(void)
172{
173 BT_INFO("Atheros AR30xx firmware driver ver %s", VERSION);
174 return usb_register(&ath3k_driver);
175}
176
177static void __exit ath3k_exit(void)
178{
179 usb_deregister(&ath3k_driver);
180}
181
182module_init(ath3k_init);
183module_exit(ath3k_exit);
184
185MODULE_AUTHOR("Atheros Communications");
186MODULE_DESCRIPTION("Atheros AR30xx firmware driver");
187MODULE_VERSION(VERSION);
188MODULE_LICENSE("GPL");
189MODULE_FIRMWARE("ath3k-1.fw");
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index eafd4af0746e..b0c84c19f442 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -39,7 +39,7 @@
39 39
40#define VERSION "1.2" 40#define VERSION "1.2"
41 41
42static struct usb_device_id bcm203x_table[] = { 42static const struct usb_device_id bcm203x_table[] = {
43 /* Broadcom Blutonium (BCM2033) */ 43 /* Broadcom Blutonium (BCM2033) */
44 { USB_DEVICE(0x0a5c, 0x2033) }, 44 { USB_DEVICE(0x0a5c, 0x2033) },
45 45
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index 2a00707aba3b..005919ab043c 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -703,7 +703,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
703 703
704 data->hdev = hdev; 704 data->hdev = hdev;
705 705
706 hdev->type = HCI_USB; 706 hdev->bus = HCI_USB;
707 hdev->driver_data = data; 707 hdev->driver_data = data;
708 SET_HCIDEV_DEV(hdev, &intf->dev); 708 SET_HCIDEV_DEV(hdev, &intf->dev);
709 709
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index b0e569ba730d..d9bf87ca9e83 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -503,7 +503,9 @@ static irqreturn_t bluecard_interrupt(int irq, void *dev_inst)
503 unsigned int iobase; 503 unsigned int iobase;
504 unsigned char reg; 504 unsigned char reg;
505 505
506 BUG_ON(!info->hdev); 506 if (!info || !info->hdev)
507 /* our irq handler is shared */
508 return IRQ_NONE;
507 509
508 if (!test_bit(CARD_READY, &(info->hw_state))) 510 if (!test_bit(CARD_READY, &(info->hw_state)))
509 return IRQ_HANDLED; 511 return IRQ_HANDLED;
@@ -734,7 +736,7 @@ static int bluecard_open(bluecard_info_t *info)
734 736
735 info->hdev = hdev; 737 info->hdev = hdev;
736 738
737 hdev->type = HCI_PCCARD; 739 hdev->bus = HCI_PCCARD;
738 hdev->driver_data = info; 740 hdev->driver_data = info;
739 SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 741 SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
740 742
@@ -867,11 +869,9 @@ static int bluecard_probe(struct pcmcia_device *link)
867 869
868 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 870 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
869 link->io.NumPorts1 = 8; 871 link->io.NumPorts1 = 8;
870 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; 872 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
871 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
872 873
873 link->irq.Handler = bluecard_interrupt; 874 link->irq.Handler = bluecard_interrupt;
874 link->irq.Instance = info;
875 875
876 link->conf.Attributes = CONF_ENABLE_IRQ; 876 link->conf.Attributes = CONF_ENABLE_IRQ;
877 link->conf.IntType = INT_MEMORY_AND_IO; 877 link->conf.IntType = INT_MEMORY_AND_IO;
@@ -905,22 +905,16 @@ static int bluecard_config(struct pcmcia_device *link)
905 break; 905 break;
906 } 906 }
907 907
908 if (i != 0) { 908 if (i != 0)
909 cs_error(link, RequestIO, i);
910 goto failed; 909 goto failed;
911 }
912 910
913 i = pcmcia_request_irq(link, &link->irq); 911 i = pcmcia_request_irq(link, &link->irq);
914 if (i != 0) { 912 if (i != 0)
915 cs_error(link, RequestIRQ, i);
916 link->irq.AssignedIRQ = 0; 913 link->irq.AssignedIRQ = 0;
917 }
918 914
919 i = pcmcia_request_configuration(link, &link->conf); 915 i = pcmcia_request_configuration(link, &link->conf);
920 if (i != 0) { 916 if (i != 0)
921 cs_error(link, RequestConfiguration, i);
922 goto failed; 917 goto failed;
923 }
924 918
925 if (bluecard_open(info) != 0) 919 if (bluecard_open(info) != 0)
926 goto failed; 920 goto failed;
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index c115285867c3..d945cd12433a 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -469,7 +469,7 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *
469 return -ENOMEM; 469 return -ENOMEM;
470 } 470 }
471 471
472 hdev->type = HCI_USB; 472 hdev->bus = HCI_USB;
473 hdev->driver_data = data; 473 hdev->driver_data = data;
474 474
475 data->hdev = hdev; 475 data->hdev = hdev;
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index d58e22b9f06a..027cb8bf650f 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -345,7 +345,9 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst)
345 int iir; 345 int iir;
346 irqreturn_t r = IRQ_NONE; 346 irqreturn_t r = IRQ_NONE;
347 347
348 BUG_ON(!info->hdev); 348 if (!info || !info->hdev)
349 /* our irq handler is shared */
350 return IRQ_NONE;
349 351
350 iobase = info->p_dev->io.BasePort1; 352 iobase = info->p_dev->io.BasePort1;
351 353
@@ -580,7 +582,7 @@ static int bt3c_open(bt3c_info_t *info)
580 582
581 info->hdev = hdev; 583 info->hdev = hdev;
582 584
583 hdev->type = HCI_PCCARD; 585 hdev->bus = HCI_PCCARD;
584 hdev->driver_data = info; 586 hdev->driver_data = info;
585 SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 587 SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
586 588
@@ -659,11 +661,9 @@ static int bt3c_probe(struct pcmcia_device *link)
659 661
660 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 662 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
661 link->io.NumPorts1 = 8; 663 link->io.NumPorts1 = 8;
662 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; 664 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
663 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
664 665
665 link->irq.Handler = bt3c_interrupt; 666 link->irq.Handler = bt3c_interrupt;
666 link->irq.Instance = info;
667 667
668 link->conf.Attributes = CONF_ENABLE_IRQ; 668 link->conf.Attributes = CONF_ENABLE_IRQ;
669 link->conf.IntType = INT_MEMORY_AND_IO; 669 link->conf.IntType = INT_MEMORY_AND_IO;
@@ -740,21 +740,16 @@ static int bt3c_config(struct pcmcia_device *link)
740 goto found_port; 740 goto found_port;
741 741
742 BT_ERR("No usable port range found"); 742 BT_ERR("No usable port range found");
743 cs_error(link, RequestIO, -ENODEV);
744 goto failed; 743 goto failed;
745 744
746found_port: 745found_port:
747 i = pcmcia_request_irq(link, &link->irq); 746 i = pcmcia_request_irq(link, &link->irq);
748 if (i != 0) { 747 if (i != 0)
749 cs_error(link, RequestIRQ, i);
750 link->irq.AssignedIRQ = 0; 748 link->irq.AssignedIRQ = 0;
751 }
752 749
753 i = pcmcia_request_configuration(link, &link->conf); 750 i = pcmcia_request_configuration(link, &link->conf);
754 if (i != 0) { 751 if (i != 0)
755 cs_error(link, RequestConfiguration, i);
756 goto failed; 752 goto failed;
757 }
758 753
759 if (bt3c_open(info) != 0) 754 if (bt3c_open(info) != 0)
760 goto failed; 755 goto failed;
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index 4617bd12f63b..b50b41d97a7f 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -19,6 +19,7 @@
19 **/ 19 **/
20 20
21#include <linux/debugfs.h> 21#include <linux/debugfs.h>
22#include <linux/slab.h>
22 23
23#include <net/bluetooth/bluetooth.h> 24#include <net/bluetooth/bluetooth.h>
24#include <net/bluetooth/hci_core.h> 25#include <net/bluetooth/hci_core.h>
@@ -26,10 +27,10 @@
26#include "btmrvl_drv.h" 27#include "btmrvl_drv.h"
27 28
28struct btmrvl_debugfs_data { 29struct btmrvl_debugfs_data {
29 struct dentry *root_dir, *config_dir, *status_dir; 30 struct dentry *config_dir;
31 struct dentry *status_dir;
30 32
31 /* config */ 33 /* config */
32 struct dentry *drvdbg;
33 struct dentry *psmode; 34 struct dentry *psmode;
34 struct dentry *pscmd; 35 struct dentry *pscmd;
35 struct dentry *hsmode; 36 struct dentry *hsmode;
@@ -364,6 +365,9 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
364 struct btmrvl_private *priv = hdev->driver_data; 365 struct btmrvl_private *priv = hdev->driver_data;
365 struct btmrvl_debugfs_data *dbg; 366 struct btmrvl_debugfs_data *dbg;
366 367
368 if (!hdev->debugfs)
369 return;
370
367 dbg = kzalloc(sizeof(*dbg), GFP_KERNEL); 371 dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
368 priv->debugfs_data = dbg; 372 priv->debugfs_data = dbg;
369 373
@@ -372,9 +376,7 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
372 return; 376 return;
373 } 377 }
374 378
375 dbg->root_dir = debugfs_create_dir("btmrvl", NULL); 379 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs);
376
377 dbg->config_dir = debugfs_create_dir("config", dbg->root_dir);
378 380
379 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, 381 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir,
380 hdev->driver_data, &btmrvl_psmode_fops); 382 hdev->driver_data, &btmrvl_psmode_fops);
@@ -389,7 +391,7 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
389 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, 391 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
390 hdev->driver_data, &btmrvl_hscfgcmd_fops); 392 hdev->driver_data, &btmrvl_hscfgcmd_fops);
391 393
392 dbg->status_dir = debugfs_create_dir("status", dbg->root_dir); 394 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs);
393 dbg->curpsmode = debugfs_create_file("curpsmode", 0444, 395 dbg->curpsmode = debugfs_create_file("curpsmode", 0444,
394 dbg->status_dir, 396 dbg->status_dir,
395 hdev->driver_data, 397 hdev->driver_data,
@@ -426,7 +428,5 @@ void btmrvl_debugfs_remove(struct hci_dev *hdev)
426 debugfs_remove(dbg->txdnldready); 428 debugfs_remove(dbg->txdnldready);
427 debugfs_remove(dbg->status_dir); 429 debugfs_remove(dbg->status_dir);
428 430
429 debugfs_remove(dbg->root_dir);
430
431 kfree(dbg); 431 kfree(dbg);
432} 432}
diff --git a/drivers/bluetooth/btmrvl_drv.h b/drivers/bluetooth/btmrvl_drv.h
index 411c7a77082d..204727586ee9 100644
--- a/drivers/bluetooth/btmrvl_drv.h
+++ b/drivers/bluetooth/btmrvl_drv.h
@@ -21,6 +21,7 @@
21 21
22#include <linux/kthread.h> 22#include <linux/kthread.h>
23#include <linux/bitops.h> 23#include <linux/bitops.h>
24#include <linux/slab.h>
24#include <net/bluetooth/bluetooth.h> 25#include <net/bluetooth/bluetooth.h>
25 26
26#define BTM_HEADER_LEN 4 27#define BTM_HEADER_LEN 4
@@ -131,6 +132,7 @@ void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb);
131int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb); 132int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb);
132 133
133int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd); 134int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd);
135int btmrvl_enable_ps(struct btmrvl_private *priv);
134int btmrvl_prepare_command(struct btmrvl_private *priv); 136int btmrvl_prepare_command(struct btmrvl_private *priv);
135 137
136#ifdef CONFIG_DEBUG_FS 138#ifdef CONFIG_DEBUG_FS
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index e605563b4eaa..53a43adf2e21 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -189,6 +189,38 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
189} 189}
190EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd); 190EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);
191 191
192int btmrvl_enable_ps(struct btmrvl_private *priv)
193{
194 struct sk_buff *skb;
195 struct btmrvl_cmd *cmd;
196
197 skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
198 if (skb == NULL) {
199 BT_ERR("No free skb");
200 return -ENOMEM;
201 }
202
203 cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
204 cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF,
205 BT_CMD_AUTO_SLEEP_MODE));
206 cmd->length = 1;
207
208 if (priv->btmrvl_dev.psmode)
209 cmd->data[0] = BT_PS_ENABLE;
210 else
211 cmd->data[0] = BT_PS_DISABLE;
212
213 bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
214
215 skb->dev = (void *) priv->btmrvl_dev.hcidev;
216 skb_queue_head(&priv->adapter->tx_queue, skb);
217
218 BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
219
220 return 0;
221}
222EXPORT_SYMBOL_GPL(btmrvl_enable_ps);
223
192static int btmrvl_enable_hs(struct btmrvl_private *priv) 224static int btmrvl_enable_hs(struct btmrvl_private *priv)
193{ 225{
194 struct sk_buff *skb; 226 struct sk_buff *skb;
@@ -258,28 +290,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
258 290
259 if (priv->btmrvl_dev.pscmd) { 291 if (priv->btmrvl_dev.pscmd) {
260 priv->btmrvl_dev.pscmd = 0; 292 priv->btmrvl_dev.pscmd = 0;
261 293 btmrvl_enable_ps(priv);
262 skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
263 if (skb == NULL) {
264 BT_ERR("No free skb");
265 return -ENOMEM;
266 }
267
268 cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
269 cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_AUTO_SLEEP_MODE));
270 cmd->length = 1;
271
272 if (priv->btmrvl_dev.psmode)
273 cmd->data[0] = BT_PS_ENABLE;
274 else
275 cmd->data[0] = BT_PS_DISABLE;
276
277 bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
278
279 skb->dev = (void *) priv->btmrvl_dev.hcidev;
280 skb_queue_head(&priv->adapter->tx_queue, skb);
281
282 BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
283 } 294 }
284 295
285 if (priv->btmrvl_dev.hscmd) { 296 if (priv->btmrvl_dev.hscmd) {
@@ -552,7 +563,7 @@ struct btmrvl_private *btmrvl_add_card(void *card)
552 563
553 priv->btmrvl_dev.tx_dnld_rdy = true; 564 priv->btmrvl_dev.tx_dnld_rdy = true;
554 565
555 hdev->type = HCI_SDIO; 566 hdev->bus = HCI_SDIO;
556 hdev->open = btmrvl_open; 567 hdev->open = btmrvl_open;
557 hdev->close = btmrvl_close; 568 hdev->close = btmrvl_close;
558 hdev->flush = btmrvl_flush; 569 hdev->flush = btmrvl_flush;
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 5b33b85790f2..0dba76aa2232 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -19,6 +19,7 @@
19 **/ 19 **/
20 20
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include <linux/slab.h>
22 23
23#include <linux/mmc/sdio_ids.h> 24#include <linux/mmc/sdio_ids.h>
24#include <linux/mmc/sdio_func.h> 25#include <linux/mmc/sdio_func.h>
@@ -535,7 +536,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
535 break; 536 break;
536 537
537 default: 538 default:
538 BT_ERR("Unknow packet type:%d", type); 539 BT_ERR("Unknown packet type:%d", type);
539 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, payload, 540 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, payload,
540 blksz * buf_block_len); 541 blksz * buf_block_len);
541 542
@@ -808,6 +809,7 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv,
808 809
809exit: 810exit:
810 sdio_release_host(card->func); 811 sdio_release_host(card->func);
812 kfree(tmpbuf);
811 813
812 return ret; 814 return ret;
813} 815}
@@ -930,6 +932,8 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
930 priv->hw_wakeup_firmware = btmrvl_sdio_wakeup_fw; 932 priv->hw_wakeup_firmware = btmrvl_sdio_wakeup_fw;
931 933
932 btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ); 934 btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
935 priv->btmrvl_dev.psmode = 1;
936 btmrvl_enable_ps(priv);
933 937
934 return 0; 938 return 0;
935 939
@@ -973,7 +977,7 @@ static struct sdio_driver bt_mrvl_sdio = {
973 .remove = btmrvl_sdio_remove, 977 .remove = btmrvl_sdio_remove,
974}; 978};
975 979
976static int btmrvl_sdio_init_module(void) 980static int __init btmrvl_sdio_init_module(void)
977{ 981{
978 if (sdio_register_driver(&bt_mrvl_sdio) != 0) { 982 if (sdio_register_driver(&bt_mrvl_sdio) != 0) {
979 BT_ERR("SDIO Driver Registration Failed"); 983 BT_ERR("SDIO Driver Registration Failed");
@@ -986,7 +990,7 @@ static int btmrvl_sdio_init_module(void)
986 return 0; 990 return 0;
987} 991}
988 992
989static void btmrvl_sdio_exit_module(void) 993static void __exit btmrvl_sdio_exit_module(void)
990{ 994{
991 /* Set the flag as user is removing this module. */ 995 /* Set the flag as user is removing this module. */
992 user_rmmod = 1; 996 user_rmmod = 1;
@@ -1001,3 +1005,5 @@ MODULE_AUTHOR("Marvell International Ltd.");
1001MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION); 1005MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION);
1002MODULE_VERSION(VERSION); 1006MODULE_VERSION(VERSION);
1003MODULE_LICENSE("GPL v2"); 1007MODULE_LICENSE("GPL v2");
1008MODULE_FIRMWARE("sd8688_helper.bin");
1009MODULE_FIRMWARE("sd8688.bin");
diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c
index 7e298275c8f6..76e5127884f0 100644
--- a/drivers/bluetooth/btsdio.c
+++ b/drivers/bluetooth/btsdio.c
@@ -326,7 +326,7 @@ static int btsdio_probe(struct sdio_func *func,
326 return -ENOMEM; 326 return -ENOMEM;
327 } 327 }
328 328
329 hdev->type = HCI_SDIO; 329 hdev->bus = HCI_SDIO;
330 hdev->driver_data = data; 330 hdev->driver_data = data;
331 331
332 data->hdev = hdev; 332 data->hdev = hdev;
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index efd689a062eb..60c0953d7d00 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -295,7 +295,9 @@ static irqreturn_t btuart_interrupt(int irq, void *dev_inst)
295 int iir, lsr; 295 int iir, lsr;
296 irqreturn_t r = IRQ_NONE; 296 irqreturn_t r = IRQ_NONE;
297 297
298 BUG_ON(!info->hdev); 298 if (!info || !info->hdev)
299 /* our irq handler is shared */
300 return IRQ_NONE;
299 301
300 iobase = info->p_dev->io.BasePort1; 302 iobase = info->p_dev->io.BasePort1;
301 303
@@ -498,7 +500,7 @@ static int btuart_open(btuart_info_t *info)
498 500
499 info->hdev = hdev; 501 info->hdev = hdev;
500 502
501 hdev->type = HCI_PCCARD; 503 hdev->bus = HCI_PCCARD;
502 hdev->driver_data = info; 504 hdev->driver_data = info;
503 SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 505 SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
504 506
@@ -588,11 +590,9 @@ static int btuart_probe(struct pcmcia_device *link)
588 590
589 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 591 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
590 link->io.NumPorts1 = 8; 592 link->io.NumPorts1 = 8;
591 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; 593 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
592 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
593 594
594 link->irq.Handler = btuart_interrupt; 595 link->irq.Handler = btuart_interrupt;
595 link->irq.Instance = info;
596 596
597 link->conf.Attributes = CONF_ENABLE_IRQ; 597 link->conf.Attributes = CONF_ENABLE_IRQ;
598 link->conf.IntType = INT_MEMORY_AND_IO; 598 link->conf.IntType = INT_MEMORY_AND_IO;
@@ -669,21 +669,16 @@ static int btuart_config(struct pcmcia_device *link)
669 goto found_port; 669 goto found_port;
670 670
671 BT_ERR("No usable port range found"); 671 BT_ERR("No usable port range found");
672 cs_error(link, RequestIO, -ENODEV);
673 goto failed; 672 goto failed;
674 673
675found_port: 674found_port:
676 i = pcmcia_request_irq(link, &link->irq); 675 i = pcmcia_request_irq(link, &link->irq);
677 if (i != 0) { 676 if (i != 0)
678 cs_error(link, RequestIRQ, i);
679 link->irq.AssignedIRQ = 0; 677 link->irq.AssignedIRQ = 0;
680 }
681 678
682 i = pcmcia_request_configuration(link, &link->conf); 679 i = pcmcia_request_configuration(link, &link->conf);
683 if (i != 0) { 680 if (i != 0)
684 cs_error(link, RequestConfiguration, i);
685 goto failed; 681 goto failed;
686 }
687 682
688 if (btuart_open(info) != 0) 683 if (btuart_open(info) != 0)
689 goto failed; 684 goto failed;
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 44bc8bbabf54..5d9cc53bd643 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -307,6 +307,7 @@ static void btusb_bulk_complete(struct urb *urb)
307 return; 307 return;
308 308
309 usb_anchor_urb(urb, &data->bulk_anchor); 309 usb_anchor_urb(urb, &data->bulk_anchor);
310 usb_mark_last_busy(data->udev);
310 311
311 err = usb_submit_urb(urb, GFP_ATOMIC); 312 err = usb_submit_urb(urb, GFP_ATOMIC);
312 if (err < 0) { 313 if (err < 0) {
@@ -938,7 +939,7 @@ static int btusb_probe(struct usb_interface *intf,
938 return -ENOMEM; 939 return -ENOMEM;
939 } 940 }
940 941
941 hdev->type = HCI_USB; 942 hdev->bus = HCI_USB;
942 hdev->driver_data = data; 943 hdev->driver_data = data;
943 944
944 data->hdev = hdev; 945 data->hdev = hdev;
@@ -1066,7 +1067,7 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
1066 return 0; 1067 return 0;
1067 1068
1068 spin_lock_irq(&data->txlock); 1069 spin_lock_irq(&data->txlock);
1069 if (!(interface_to_usbdev(intf)->auto_pm && data->tx_in_flight)) { 1070 if (!((message.event & PM_EVENT_AUTO) && data->tx_in_flight)) {
1070 set_bit(BTUSB_SUSPENDING, &data->flags); 1071 set_bit(BTUSB_SUSPENDING, &data->flags);
1071 spin_unlock_irq(&data->txlock); 1072 spin_unlock_irq(&data->txlock);
1072 } else { 1073 } else {
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index b881a9cd8741..17788317c51a 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -299,7 +299,9 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst)
299 int iir, lsr; 299 int iir, lsr;
300 irqreturn_t r = IRQ_NONE; 300 irqreturn_t r = IRQ_NONE;
301 301
302 BUG_ON(!info->hdev); 302 if (!info || !info->hdev)
303 /* our irq handler is shared */
304 return IRQ_NONE;
303 305
304 iobase = info->p_dev->io.BasePort1; 306 iobase = info->p_dev->io.BasePort1;
305 307
@@ -483,7 +485,7 @@ static int dtl1_open(dtl1_info_t *info)
483 485
484 info->hdev = hdev; 486 info->hdev = hdev;
485 487
486 hdev->type = HCI_PCCARD; 488 hdev->bus = HCI_PCCARD;
487 hdev->driver_data = info; 489 hdev->driver_data = info;
488 SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 490 SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
489 491
@@ -573,11 +575,9 @@ static int dtl1_probe(struct pcmcia_device *link)
573 575
574 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 576 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
575 link->io.NumPorts1 = 8; 577 link->io.NumPorts1 = 8;
576 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; 578 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
577 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
578 579
579 link->irq.Handler = dtl1_interrupt; 580 link->irq.Handler = dtl1_interrupt;
580 link->irq.Instance = info;
581 581
582 link->conf.Attributes = CONF_ENABLE_IRQ; 582 link->conf.Attributes = CONF_ENABLE_IRQ;
583 link->conf.IntType = INT_MEMORY_AND_IO; 583 link->conf.IntType = INT_MEMORY_AND_IO;
@@ -622,16 +622,12 @@ static int dtl1_config(struct pcmcia_device *link)
622 goto failed; 622 goto failed;
623 623
624 i = pcmcia_request_irq(link, &link->irq); 624 i = pcmcia_request_irq(link, &link->irq);
625 if (i != 0) { 625 if (i != 0)
626 cs_error(link, RequestIRQ, i);
627 link->irq.AssignedIRQ = 0; 626 link->irq.AssignedIRQ = 0;
628 }
629 627
630 i = pcmcia_request_configuration(link, &link->conf); 628 i = pcmcia_request_configuration(link, &link->conf);
631 if (i != 0) { 629 if (i != 0)
632 cs_error(link, RequestConfiguration, i);
633 goto failed; 630 goto failed;
634 }
635 631
636 if (dtl1_open(info) != 0) 632 if (dtl1_open(info) != 0)
637 goto failed; 633 goto failed;
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 4895f0e05322..76a1abb8f214 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -214,7 +214,7 @@ static int hci_uart_send_frame(struct sk_buff *skb)
214 struct hci_uart *hu; 214 struct hci_uart *hu;
215 215
216 if (!hdev) { 216 if (!hdev) {
217 BT_ERR("Frame for uknown device (hdev=NULL)"); 217 BT_ERR("Frame for unknown device (hdev=NULL)");
218 return -ENODEV; 218 return -ENODEV;
219 } 219 }
220 220
@@ -383,7 +383,7 @@ static int hci_uart_register_dev(struct hci_uart *hu)
383 383
384 hu->hdev = hdev; 384 hu->hdev = hdev;
385 385
386 hdev->type = HCI_UART; 386 hdev->bus = HCI_UART;
387 hdev->driver_data = hu; 387 hdev->driver_data = hu;
388 388
389 hdev->open = hci_uart_open; 389 hdev->open = hci_uart_open;
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index d5cde6d86f89..bb0aefdb4267 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -41,8 +41,6 @@
41 41
42#define VERSION "1.3" 42#define VERSION "1.3"
43 43
44static int minor = MISC_DYNAMIC_MINOR;
45
46struct vhci_data { 44struct vhci_data {
47 struct hci_dev *hdev; 45 struct hci_dev *hdev;
48 46
@@ -218,12 +216,6 @@ static unsigned int vhci_poll(struct file *file, poll_table *wait)
218 return POLLOUT | POLLWRNORM; 216 return POLLOUT | POLLWRNORM;
219} 217}
220 218
221static int vhci_ioctl(struct inode *inode, struct file *file,
222 unsigned int cmd, unsigned long arg)
223{
224 return -EINVAL;
225}
226
227static int vhci_open(struct inode *inode, struct file *file) 219static int vhci_open(struct inode *inode, struct file *file)
228{ 220{
229 struct vhci_data *data; 221 struct vhci_data *data;
@@ -244,7 +236,7 @@ static int vhci_open(struct inode *inode, struct file *file)
244 236
245 data->hdev = hdev; 237 data->hdev = hdev;
246 238
247 hdev->type = HCI_VIRTUAL; 239 hdev->bus = HCI_VIRTUAL;
248 hdev->driver_data = data; 240 hdev->driver_data = data;
249 241
250 hdev->open = vhci_open_dev; 242 hdev->open = vhci_open_dev;
@@ -284,10 +276,10 @@ static int vhci_release(struct inode *inode, struct file *file)
284} 276}
285 277
286static const struct file_operations vhci_fops = { 278static const struct file_operations vhci_fops = {
279 .owner = THIS_MODULE,
287 .read = vhci_read, 280 .read = vhci_read,
288 .write = vhci_write, 281 .write = vhci_write,
289 .poll = vhci_poll, 282 .poll = vhci_poll,
290 .ioctl = vhci_ioctl,
291 .open = vhci_open, 283 .open = vhci_open,
292 .release = vhci_release, 284 .release = vhci_release,
293}; 285};
@@ -302,18 +294,12 @@ static int __init vhci_init(void)
302{ 294{
303 BT_INFO("Virtual HCI driver ver %s", VERSION); 295 BT_INFO("Virtual HCI driver ver %s", VERSION);
304 296
305 if (misc_register(&vhci_miscdev) < 0) { 297 return misc_register(&vhci_miscdev);
306 BT_ERR("Can't register misc device with minor %d", minor);
307 return -EIO;
308 }
309
310 return 0;
311} 298}
312 299
313static void __exit vhci_exit(void) 300static void __exit vhci_exit(void)
314{ 301{
315 if (misc_deregister(&vhci_miscdev) < 0) 302 misc_deregister(&vhci_miscdev);
316 BT_ERR("Can't unregister misc device with minor %d", minor);
317} 303}
318 304
319module_init(vhci_init); 305module_init(vhci_init);