aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:08:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:08:52 -0400
commit73287a43cc79ca06629a88d1a199cd283f42456a (patch)
treeacf4456e260115bea77ee31a29f10ce17f0db45c /drivers/bluetooth
parent251df49db3327c64bf917bfdba94491fde2b4ee0 (diff)
parent20074f357da4a637430aec2879c9d864c5d2c23c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: "Highlights (1721 non-merge commits, this has to be a record of some sort): 1) Add 'random' mode to team driver, from Jiri Pirko and Eric Dumazet. 2) Make it so that any driver that supports configuration of multiple MAC addresses can provide the forwarding database add and del calls by providing a default implementation and hooking that up if the driver doesn't have an explicit set of handlers. From Vlad Yasevich. 3) Support GSO segmentation over tunnels and other encapsulating devices such as VXLAN, from Pravin B Shelar. 4) Support L2 GRE tunnels in the flow dissector, from Michael Dalton. 5) Implement Tail Loss Probe (TLP) detection in TCP, from Nandita Dukkipati. 6) In the PHY layer, allow supporting wake-on-lan in situations where the PHY registers have to be written for it to be configured. Use it to support wake-on-lan in mv643xx_eth. From Michael Stapelberg. 7) Significantly improve firewire IPV6 support, from YOSHIFUJI Hideaki. 8) Allow multiple packets to be sent in a single transmission using network coding in batman-adv, from Martin Hundebøll. 9) Add support for T5 cxgb4 chips, from Santosh Rastapur. 10) Generalize the VXLAN forwarding tables so that there is more flexibility in configurating various aspects of the endpoints. From David Stevens. 11) Support RSS and TSO in hardware over GRE tunnels in bxn2x driver, from Dmitry Kravkov. 12) Zero copy support in nfnelink_queue, from Eric Dumazet and Pablo Neira Ayuso. 13) Start adding networking selftests. 14) In situations of overload on the same AF_PACKET fanout socket, or per-cpu packet receive queue, minimize drop by distributing the load to other cpus/fanouts. From Willem de Bruijn and Eric Dumazet. 15) Add support for new payload offset BPF instruction, from Daniel Borkmann. 16) Convert several drivers over to mdoule_platform_driver(), from Sachin Kamat. 17) Provide a minimal BPF JIT image disassembler userspace tool, from Daniel Borkmann. 18) Rewrite F-RTO implementation in TCP to match the final specification of it in RFC4138 and RFC5682. From Yuchung Cheng. 19) Provide netlink socket diag of netlink sockets ("Yo dawg, I hear you like netlink, so I implemented netlink dumping of netlink sockets.") From Andrey Vagin. 20) Remove ugly passing of rtnetlink attributes into rtnl_doit functions, from Thomas Graf. 21) Allow userspace to be able to see if a configuration change occurs in the middle of an address or device list dump, from Nicolas Dichtel. 22) Support RFC3168 ECN protection for ipv6 fragments, from Hannes Frederic Sowa. 23) Increase accuracy of packet length used by packet scheduler, from Jason Wang. 24) Beginning set of changes to make ipv4/ipv6 fragment handling more scalable and less susceptible to overload and locking contention, from Jesper Dangaard Brouer. 25) Get rid of using non-type-safe NLMSG_* macros and use nlmsg_*() instead. From Hong Zhiguo. 26) Optimize route usage in IPVS by avoiding reference counting where possible, from Julian Anastasov. 27) Convert IPVS schedulers to RCU, also from Julian Anastasov. 28) Support cpu fanouts in xt_NFQUEUE netfilter target, from Holger Eitzenberger. 29) Network namespace support for nf_log, ebt_log, xt_LOG, ipt_ULOG, nfnetlink_log, and nfnetlink_queue. From Gao feng. 30) Implement RFC3168 ECN protection, from Hannes Frederic Sowa. 31) Support several new r8169 chips, from Hayes Wang. 32) Support tokenized interface identifiers in ipv6, from Daniel Borkmann. 33) Use usbnet_link_change() helper in USB net driver, from Ming Lei. 34) Add 802.1ad vlan offload support, from Patrick McHardy. 35) Support mmap() based netlink communication, also from Patrick McHardy. 36) Support HW timestamping in mlx4 driver, from Amir Vadai. 37) Rationalize AF_PACKET packet timestamping when transmitting, from Willem de Bruijn and Daniel Borkmann. 38) Bring parity to what's provided by /proc/net/packet socket dumping and the info provided by netlink socket dumping of AF_PACKET sockets. From Nicolas Dichtel. 39) Fix peeking beyond zero sized SKBs in AF_UNIX, from Benjamin Poirier" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1722 commits) filter: fix va_list build error af_unix: fix a fatal race with bit fields bnx2x: Prevent memory leak when cnic is absent bnx2x: correct reading of speed capabilities net: sctp: attribute printl with __printf for gcc fmt checks netlink: kconfig: move mmap i/o into netlink kconfig netpoll: convert mutex into a semaphore netlink: Fix skb ref counting. net_sched: act_ipt forward compat with xtables mlx4_en: fix a build error on 32bit arches Revert "bnx2x: allow nvram test to run when device is down" bridge: avoid OOPS if root port not found drivers: net: cpsw: fix kernel warn on cpsw irq enable sh_eth: use random MAC address if no valid one supplied 3c509.c: call SET_NETDEV_DEV for all device types (ISA/ISAPnP/EISA) tg3: fix to append hardware time stamping flags unix/stream: fix peeking with an offset larger than data in queue unix/dgram: fix peeking with an offset larger than data in queue unix/dgram: peek beyond 0-sized skbs openvswitch: Remove unneeded ovs_netdev_get_ifindex() ...
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/ath3k.c2
-rw-r--r--drivers/bluetooth/btmrvl_debugfs.c266
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c49
-rw-r--r--drivers/bluetooth/btusb.c418
-rw-r--r--drivers/bluetooth/hci_h4.c3
-rw-r--r--drivers/bluetooth/hci_ldisc.c15
6 files changed, 465 insertions, 288 deletions
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 6aab00ef4379..11f467c00d0a 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -90,6 +90,7 @@ static struct usb_device_id ath3k_table[] = {
90 { USB_DEVICE(0x13d3, 0x3393) }, 90 { USB_DEVICE(0x13d3, 0x3393) },
91 { USB_DEVICE(0x0489, 0xe04e) }, 91 { USB_DEVICE(0x0489, 0xe04e) },
92 { USB_DEVICE(0x0489, 0xe056) }, 92 { USB_DEVICE(0x0489, 0xe056) },
93 { USB_DEVICE(0x0489, 0xe04d) },
93 94
94 /* Atheros AR5BBU12 with sflash firmware */ 95 /* Atheros AR5BBU12 with sflash firmware */
95 { USB_DEVICE(0x0489, 0xE02C) }, 96 { USB_DEVICE(0x0489, 0xE02C) },
@@ -126,6 +127,7 @@ static struct usb_device_id ath3k_blist_tbl[] = {
126 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 }, 127 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
127 { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 }, 128 { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
128 { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 }, 129 { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
130 { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 },
129 131
130 /* Atheros AR5BBU22 with sflash firmware */ 132 /* Atheros AR5BBU22 with sflash firmware */
131 { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 }, 133 { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index 428dbb7574bd..db2c3c305df8 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -29,20 +29,6 @@
29struct btmrvl_debugfs_data { 29struct btmrvl_debugfs_data {
30 struct dentry *config_dir; 30 struct dentry *config_dir;
31 struct dentry *status_dir; 31 struct dentry *status_dir;
32
33 /* config */
34 struct dentry *psmode;
35 struct dentry *pscmd;
36 struct dentry *hsmode;
37 struct dentry *hscmd;
38 struct dentry *gpiogap;
39 struct dentry *hscfgcmd;
40
41 /* status */
42 struct dentry *curpsmode;
43 struct dentry *hsstate;
44 struct dentry *psstate;
45 struct dentry *txdnldready;
46}; 32};
47 33
48static ssize_t btmrvl_hscfgcmd_write(struct file *file, 34static ssize_t btmrvl_hscfgcmd_write(struct file *file,
@@ -91,47 +77,6 @@ static const struct file_operations btmrvl_hscfgcmd_fops = {
91 .llseek = default_llseek, 77 .llseek = default_llseek,
92}; 78};
93 79
94static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
95 size_t count, loff_t *ppos)
96{
97 struct btmrvl_private *priv = file->private_data;
98 char buf[16];
99 long result, ret;
100
101 memset(buf, 0, sizeof(buf));
102
103 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
104 return -EFAULT;
105
106 ret = strict_strtol(buf, 10, &result);
107 if (ret)
108 return ret;
109
110 priv->btmrvl_dev.psmode = result;
111
112 return count;
113}
114
115static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf,
116 size_t count, loff_t *ppos)
117{
118 struct btmrvl_private *priv = file->private_data;
119 char buf[16];
120 int ret;
121
122 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
123 priv->btmrvl_dev.psmode);
124
125 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
126}
127
128static const struct file_operations btmrvl_psmode_fops = {
129 .read = btmrvl_psmode_read,
130 .write = btmrvl_psmode_write,
131 .open = simple_open,
132 .llseek = default_llseek,
133};
134
135static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, 80static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
136 size_t count, loff_t *ppos) 81 size_t count, loff_t *ppos)
137{ 82{
@@ -178,47 +123,6 @@ static const struct file_operations btmrvl_pscmd_fops = {
178 .llseek = default_llseek, 123 .llseek = default_llseek,
179}; 124};
180 125
181static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf,
182 size_t count, loff_t *ppos)
183{
184 struct btmrvl_private *priv = file->private_data;
185 char buf[16];
186 long result, ret;
187
188 memset(buf, 0, sizeof(buf));
189
190 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
191 return -EFAULT;
192
193 ret = strict_strtol(buf, 16, &result);
194 if (ret)
195 return ret;
196
197 priv->btmrvl_dev.gpio_gap = result;
198
199 return count;
200}
201
202static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf,
203 size_t count, loff_t *ppos)
204{
205 struct btmrvl_private *priv = file->private_data;
206 char buf[16];
207 int ret;
208
209 ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n",
210 priv->btmrvl_dev.gpio_gap);
211
212 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
213}
214
215static const struct file_operations btmrvl_gpiogap_fops = {
216 .read = btmrvl_gpiogap_read,
217 .write = btmrvl_gpiogap_write,
218 .open = simple_open,
219 .llseek = default_llseek,
220};
221
222static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, 126static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
223 size_t count, loff_t *ppos) 127 size_t count, loff_t *ppos)
224{ 128{
@@ -263,119 +167,6 @@ static const struct file_operations btmrvl_hscmd_fops = {
263 .llseek = default_llseek, 167 .llseek = default_llseek,
264}; 168};
265 169
266static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
267 size_t count, loff_t *ppos)
268{
269 struct btmrvl_private *priv = file->private_data;
270 char buf[16];
271 long result, ret;
272
273 memset(buf, 0, sizeof(buf));
274
275 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
276 return -EFAULT;
277
278 ret = strict_strtol(buf, 10, &result);
279 if (ret)
280 return ret;
281
282 priv->btmrvl_dev.hsmode = result;
283
284 return count;
285}
286
287static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf,
288 size_t count, loff_t *ppos)
289{
290 struct btmrvl_private *priv = file->private_data;
291 char buf[16];
292 int ret;
293
294 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hsmode);
295
296 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
297}
298
299static const struct file_operations btmrvl_hsmode_fops = {
300 .read = btmrvl_hsmode_read,
301 .write = btmrvl_hsmode_write,
302 .open = simple_open,
303 .llseek = default_llseek,
304};
305
306static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
307 size_t count, loff_t *ppos)
308{
309 struct btmrvl_private *priv = file->private_data;
310 char buf[16];
311 int ret;
312
313 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->psmode);
314
315 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
316}
317
318static const struct file_operations btmrvl_curpsmode_fops = {
319 .read = btmrvl_curpsmode_read,
320 .open = simple_open,
321 .llseek = default_llseek,
322};
323
324static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
325 size_t count, loff_t *ppos)
326{
327 struct btmrvl_private *priv = file->private_data;
328 char buf[16];
329 int ret;
330
331 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->ps_state);
332
333 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
334}
335
336static const struct file_operations btmrvl_psstate_fops = {
337 .read = btmrvl_psstate_read,
338 .open = simple_open,
339 .llseek = default_llseek,
340};
341
342static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
343 size_t count, loff_t *ppos)
344{
345 struct btmrvl_private *priv = file->private_data;
346 char buf[16];
347 int ret;
348
349 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->hs_state);
350
351 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
352}
353
354static const struct file_operations btmrvl_hsstate_fops = {
355 .read = btmrvl_hsstate_read,
356 .open = simple_open,
357 .llseek = default_llseek,
358};
359
360static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
361 size_t count, loff_t *ppos)
362{
363 struct btmrvl_private *priv = file->private_data;
364 char buf[16];
365 int ret;
366
367 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
368 priv->btmrvl_dev.tx_dnld_rdy);
369
370 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
371}
372
373static const struct file_operations btmrvl_txdnldready_fops = {
374 .read = btmrvl_txdnldready_read,
375 .open = simple_open,
376 .llseek = default_llseek,
377};
378
379void btmrvl_debugfs_init(struct hci_dev *hdev) 170void btmrvl_debugfs_init(struct hci_dev *hdev)
380{ 171{
381 struct btmrvl_private *priv = hci_get_drvdata(hdev); 172 struct btmrvl_private *priv = hci_get_drvdata(hdev);
@@ -394,30 +185,28 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
394 185
395 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs); 186 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs);
396 187
397 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, 188 debugfs_create_u8("psmode", 0644, dbg->config_dir,
398 priv, &btmrvl_psmode_fops); 189 &priv->btmrvl_dev.psmode);
399 dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir, 190 debugfs_create_file("pscmd", 0644, dbg->config_dir,
400 priv, &btmrvl_pscmd_fops); 191 priv, &btmrvl_pscmd_fops);
401 dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir, 192 debugfs_create_x16("gpiogap", 0644, dbg->config_dir,
402 priv, &btmrvl_gpiogap_fops); 193 &priv->btmrvl_dev.gpio_gap);
403 dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir, 194 debugfs_create_u8("hsmode", 0644, dbg->config_dir,
404 priv, &btmrvl_hsmode_fops); 195 &priv->btmrvl_dev.hsmode);
405 dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir, 196 debugfs_create_file("hscmd", 0644, dbg->config_dir,
406 priv, &btmrvl_hscmd_fops); 197 priv, &btmrvl_hscmd_fops);
407 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, 198 debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
408 priv, &btmrvl_hscfgcmd_fops); 199 priv, &btmrvl_hscfgcmd_fops);
409 200
410 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs); 201 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs);
411 dbg->curpsmode = debugfs_create_file("curpsmode", 0444, 202 debugfs_create_u8("curpsmode", 0444, dbg->status_dir,
412 dbg->status_dir, priv, 203 &priv->adapter->psmode);
413 &btmrvl_curpsmode_fops); 204 debugfs_create_u8("psstate", 0444, dbg->status_dir,
414 dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir, 205 &priv->adapter->ps_state);
415 priv, &btmrvl_psstate_fops); 206 debugfs_create_u8("hsstate", 0444, dbg->status_dir,
416 dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir, 207 &priv->adapter->hs_state);
417 priv, &btmrvl_hsstate_fops); 208 debugfs_create_u8("txdnldready", 0444, dbg->status_dir,
418 dbg->txdnldready = debugfs_create_file("txdnldready", 0444, 209 &priv->btmrvl_dev.tx_dnld_rdy);
419 dbg->status_dir, priv,
420 &btmrvl_txdnldready_fops);
421} 210}
422 211
423void btmrvl_debugfs_remove(struct hci_dev *hdev) 212void btmrvl_debugfs_remove(struct hci_dev *hdev)
@@ -428,19 +217,8 @@ void btmrvl_debugfs_remove(struct hci_dev *hdev)
428 if (!dbg) 217 if (!dbg)
429 return; 218 return;
430 219
431 debugfs_remove(dbg->psmode); 220 debugfs_remove_recursive(dbg->config_dir);
432 debugfs_remove(dbg->pscmd); 221 debugfs_remove_recursive(dbg->status_dir);
433 debugfs_remove(dbg->gpiogap);
434 debugfs_remove(dbg->hsmode);
435 debugfs_remove(dbg->hscmd);
436 debugfs_remove(dbg->hscfgcmd);
437 debugfs_remove(dbg->config_dir);
438
439 debugfs_remove(dbg->curpsmode);
440 debugfs_remove(dbg->psstate);
441 debugfs_remove(dbg->hsstate);
442 debugfs_remove(dbg->txdnldready);
443 debugfs_remove(dbg->status_dir);
444 222
445 kfree(dbg); 223 kfree(dbg);
446} 224}
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 9959d4cb23dc..c63488c54f4a 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -83,8 +83,8 @@ static const struct btmrvl_sdio_card_reg btmrvl_reg_87xx = {
83}; 83};
84 84
85static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = { 85static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = {
86 .helper = "sd8688_helper.bin", 86 .helper = "mrvl/sd8688_helper.bin",
87 .firmware = "sd8688.bin", 87 .firmware = "mrvl/sd8688.bin",
88 .reg = &btmrvl_reg_8688, 88 .reg = &btmrvl_reg_8688,
89 .sd_blksz_fw_dl = 64, 89 .sd_blksz_fw_dl = 64,
90}; 90};
@@ -228,24 +228,24 @@ failed:
228static int btmrvl_sdio_verify_fw_download(struct btmrvl_sdio_card *card, 228static int btmrvl_sdio_verify_fw_download(struct btmrvl_sdio_card *card,
229 int pollnum) 229 int pollnum)
230{ 230{
231 int ret = -ETIMEDOUT;
232 u16 firmwarestat; 231 u16 firmwarestat;
233 unsigned int tries; 232 int tries, ret;
234 233
235 /* Wait for firmware to become ready */ 234 /* Wait for firmware to become ready */
236 for (tries = 0; tries < pollnum; tries++) { 235 for (tries = 0; tries < pollnum; tries++) {
237 if (btmrvl_sdio_read_fw_status(card, &firmwarestat) < 0) 236 sdio_claim_host(card->func);
237 ret = btmrvl_sdio_read_fw_status(card, &firmwarestat);
238 sdio_release_host(card->func);
239 if (ret < 0)
238 continue; 240 continue;
239 241
240 if (firmwarestat == FIRMWARE_READY) { 242 if (firmwarestat == FIRMWARE_READY)
241 ret = 0; 243 return 0;
242 break; 244
243 } else { 245 msleep(10);
244 msleep(10);
245 }
246 } 246 }
247 247
248 return ret; 248 return -ETIMEDOUT;
249} 249}
250 250
251static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card) 251static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
@@ -874,7 +874,7 @@ exit:
874 874
875static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card) 875static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card)
876{ 876{
877 int ret = 0; 877 int ret;
878 u8 fws0; 878 u8 fws0;
879 int pollnum = MAX_POLL_TRIES; 879 int pollnum = MAX_POLL_TRIES;
880 880
@@ -882,13 +882,14 @@ static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card)
882 BT_ERR("card or function is NULL!"); 882 BT_ERR("card or function is NULL!");
883 return -EINVAL; 883 return -EINVAL;
884 } 884 }
885 sdio_claim_host(card->func);
886 885
887 if (!btmrvl_sdio_verify_fw_download(card, 1)) { 886 if (!btmrvl_sdio_verify_fw_download(card, 1)) {
888 BT_DBG("Firmware already downloaded!"); 887 BT_DBG("Firmware already downloaded!");
889 goto done; 888 return 0;
890 } 889 }
891 890
891 sdio_claim_host(card->func);
892
892 /* Check if other function driver is downloading the firmware */ 893 /* Check if other function driver is downloading the firmware */
893 fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret); 894 fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret);
894 if (ret) { 895 if (ret) {
@@ -918,15 +919,21 @@ static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card)
918 } 919 }
919 } 920 }
920 921
922 sdio_release_host(card->func);
923
924 /*
925 * winner or not, with this test the FW synchronizes when the
926 * module can continue its initialization
927 */
921 if (btmrvl_sdio_verify_fw_download(card, pollnum)) { 928 if (btmrvl_sdio_verify_fw_download(card, pollnum)) {
922 BT_ERR("FW failed to be active in time!"); 929 BT_ERR("FW failed to be active in time!");
923 ret = -ETIMEDOUT; 930 return -ETIMEDOUT;
924 goto done;
925 } 931 }
926 932
933 return 0;
934
927done: 935done:
928 sdio_release_host(card->func); 936 sdio_release_host(card->func);
929
930 return ret; 937 return ret;
931} 938}
932 939
@@ -989,8 +996,6 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
989 goto unreg_dev; 996 goto unreg_dev;
990 } 997 }
991 998
992 msleep(100);
993
994 btmrvl_sdio_enable_host_int(card); 999 btmrvl_sdio_enable_host_int(card);
995 1000
996 priv = btmrvl_add_card(card); 1001 priv = btmrvl_add_card(card);
@@ -1185,7 +1190,7 @@ MODULE_AUTHOR("Marvell International Ltd.");
1185MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION); 1190MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION);
1186MODULE_VERSION(VERSION); 1191MODULE_VERSION(VERSION);
1187MODULE_LICENSE("GPL v2"); 1192MODULE_LICENSE("GPL v2");
1188MODULE_FIRMWARE("sd8688_helper.bin"); 1193MODULE_FIRMWARE("mrvl/sd8688_helper.bin");
1189MODULE_FIRMWARE("sd8688.bin"); 1194MODULE_FIRMWARE("mrvl/sd8688.bin");
1190MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin"); 1195MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");
1191MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin"); 1196MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin");
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 2cc5f774a29c..7a7e5f8ecadc 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/firmware.h>
26 27
27#include <net/bluetooth/bluetooth.h> 28#include <net/bluetooth/bluetooth.h>
28#include <net/bluetooth/hci_core.h> 29#include <net/bluetooth/hci_core.h>
@@ -47,6 +48,7 @@ static struct usb_driver btusb_driver;
47#define BTUSB_BROKEN_ISOC 0x20 48#define BTUSB_BROKEN_ISOC 0x20
48#define BTUSB_WRONG_SCO_MTU 0x40 49#define BTUSB_WRONG_SCO_MTU 0x40
49#define BTUSB_ATH3012 0x80 50#define BTUSB_ATH3012 0x80
51#define BTUSB_INTEL 0x100
50 52
51static struct usb_device_id btusb_table[] = { 53static struct usb_device_id btusb_table[] = {
52 /* Generic Bluetooth USB device */ 54 /* Generic Bluetooth USB device */
@@ -148,6 +150,7 @@ static struct usb_device_id blacklist_table[] = {
148 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 }, 150 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
149 { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 }, 151 { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
150 { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 }, 152 { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
153 { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 },
151 154
152 /* Atheros AR5BBU12 with sflash firmware */ 155 /* Atheros AR5BBU12 with sflash firmware */
153 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, 156 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
@@ -206,6 +209,9 @@ static struct usb_device_id blacklist_table[] = {
206 /* Frontline ComProbe Bluetooth Sniffer */ 209 /* Frontline ComProbe Bluetooth Sniffer */
207 { USB_DEVICE(0x16d3, 0x0002), .driver_info = BTUSB_SNIFFER }, 210 { USB_DEVICE(0x16d3, 0x0002), .driver_info = BTUSB_SNIFFER },
208 211
212 /* Intel Bluetooth device */
213 { USB_DEVICE(0x8087, 0x07dc), .driver_info = BTUSB_INTEL },
214
209 { } /* Terminating entry */ 215 { } /* Terminating entry */
210}; 216};
211 217
@@ -926,6 +932,391 @@ static void btusb_waker(struct work_struct *work)
926 usb_autopm_put_interface(data->intf); 932 usb_autopm_put_interface(data->intf);
927} 933}
928 934
935static int btusb_setup_bcm92035(struct hci_dev *hdev)
936{
937 struct sk_buff *skb;
938 u8 val = 0x00;
939
940 BT_DBG("%s", hdev->name);
941
942 skb = __hci_cmd_sync(hdev, 0xfc3b, 1, &val, HCI_INIT_TIMEOUT);
943 if (IS_ERR(skb))
944 BT_ERR("BCM92035 command failed (%ld)", -PTR_ERR(skb));
945 else
946 kfree_skb(skb);
947
948 return 0;
949}
950
951struct intel_version {
952 u8 status;
953 u8 hw_platform;
954 u8 hw_variant;
955 u8 hw_revision;
956 u8 fw_variant;
957 u8 fw_revision;
958 u8 fw_build_num;
959 u8 fw_build_ww;
960 u8 fw_build_yy;
961 u8 fw_patch_num;
962} __packed;
963
964static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev,
965 struct intel_version *ver)
966{
967 const struct firmware *fw;
968 char fwname[64];
969 int ret;
970
971 snprintf(fwname, sizeof(fwname),
972 "intel/ibt-hw-%x.%x.%x-fw-%x.%x.%x.%x.%x.bseq",
973 ver->hw_platform, ver->hw_variant, ver->hw_revision,
974 ver->fw_variant, ver->fw_revision, ver->fw_build_num,
975 ver->fw_build_ww, ver->fw_build_yy);
976
977 ret = request_firmware(&fw, fwname, &hdev->dev);
978 if (ret < 0) {
979 if (ret == -EINVAL) {
980 BT_ERR("%s Intel firmware file request failed (%d)",
981 hdev->name, ret);
982 return NULL;
983 }
984
985 BT_ERR("%s failed to open Intel firmware file: %s(%d)",
986 hdev->name, fwname, ret);
987
988 /* If the correct firmware patch file is not found, use the
989 * default firmware patch file instead
990 */
991 snprintf(fwname, sizeof(fwname), "intel/ibt-hw-%x.%x.bseq",
992 ver->hw_platform, ver->hw_variant);
993 if (request_firmware(&fw, fwname, &hdev->dev) < 0) {
994 BT_ERR("%s failed to open default Intel fw file: %s",
995 hdev->name, fwname);
996 return NULL;
997 }
998 }
999
1000 BT_INFO("%s: Intel Bluetooth firmware file: %s", hdev->name, fwname);
1001
1002 return fw;
1003}
1004
1005static int btusb_setup_intel_patching(struct hci_dev *hdev,
1006 const struct firmware *fw,
1007 const u8 **fw_ptr, int *disable_patch)
1008{
1009 struct sk_buff *skb;
1010 struct hci_command_hdr *cmd;
1011 const u8 *cmd_param;
1012 struct hci_event_hdr *evt = NULL;
1013 const u8 *evt_param = NULL;
1014 int remain = fw->size - (*fw_ptr - fw->data);
1015
1016 /* The first byte indicates the types of the patch command or event.
1017 * 0x01 means HCI command and 0x02 is HCI event. If the first bytes
1018 * in the current firmware buffer doesn't start with 0x01 or
1019 * the size of remain buffer is smaller than HCI command header,
1020 * the firmware file is corrupted and it should stop the patching
1021 * process.
1022 */
1023 if (remain > HCI_COMMAND_HDR_SIZE && *fw_ptr[0] != 0x01) {
1024 BT_ERR("%s Intel fw corrupted: invalid cmd read", hdev->name);
1025 return -EINVAL;
1026 }
1027 (*fw_ptr)++;
1028 remain--;
1029
1030 cmd = (struct hci_command_hdr *)(*fw_ptr);
1031 *fw_ptr += sizeof(*cmd);
1032 remain -= sizeof(*cmd);
1033
1034 /* Ensure that the remain firmware data is long enough than the length
1035 * of command parameter. If not, the firmware file is corrupted.
1036 */
1037 if (remain < cmd->plen) {
1038 BT_ERR("%s Intel fw corrupted: invalid cmd len", hdev->name);
1039 return -EFAULT;
1040 }
1041
1042 /* If there is a command that loads a patch in the firmware
1043 * file, then enable the patch upon success, otherwise just
1044 * disable the manufacturer mode, for example patch activation
1045 * is not required when the default firmware patch file is used
1046 * because there are no patch data to load.
1047 */
1048 if (*disable_patch && le16_to_cpu(cmd->opcode) == 0xfc8e)
1049 *disable_patch = 0;
1050
1051 cmd_param = *fw_ptr;
1052 *fw_ptr += cmd->plen;
1053 remain -= cmd->plen;
1054
1055 /* This reads the expected events when the above command is sent to the
1056 * device. Some vendor commands expects more than one events, for
1057 * example command status event followed by vendor specific event.
1058 * For this case, it only keeps the last expected event. so the command
1059 * can be sent with __hci_cmd_sync_ev() which returns the sk_buff of
1060 * last expected event.
1061 */
1062 while (remain > HCI_EVENT_HDR_SIZE && *fw_ptr[0] == 0x02) {
1063 (*fw_ptr)++;
1064 remain--;
1065
1066 evt = (struct hci_event_hdr *)(*fw_ptr);
1067 *fw_ptr += sizeof(*evt);
1068 remain -= sizeof(*evt);
1069
1070 if (remain < evt->plen) {
1071 BT_ERR("%s Intel fw corrupted: invalid evt len",
1072 hdev->name);
1073 return -EFAULT;
1074 }
1075
1076 evt_param = *fw_ptr;
1077 *fw_ptr += evt->plen;
1078 remain -= evt->plen;
1079 }
1080
1081 /* Every HCI commands in the firmware file has its correspond event.
1082 * If event is not found or remain is smaller than zero, the firmware
1083 * file is corrupted.
1084 */
1085 if (!evt || !evt_param || remain < 0) {
1086 BT_ERR("%s Intel fw corrupted: invalid evt read", hdev->name);
1087 return -EFAULT;
1088 }
1089
1090 skb = __hci_cmd_sync_ev(hdev, le16_to_cpu(cmd->opcode), cmd->plen,
1091 cmd_param, evt->evt, HCI_INIT_TIMEOUT);
1092 if (IS_ERR(skb)) {
1093 BT_ERR("%s sending Intel patch command (0x%4.4x) failed (%ld)",
1094 hdev->name, cmd->opcode, PTR_ERR(skb));
1095 return -PTR_ERR(skb);
1096 }
1097
1098 /* It ensures that the returned event matches the event data read from
1099 * the firmware file. At fist, it checks the length and then
1100 * the contents of the event.
1101 */
1102 if (skb->len != evt->plen) {
1103 BT_ERR("%s mismatch event length (opcode 0x%4.4x)", hdev->name,
1104 le16_to_cpu(cmd->opcode));
1105 kfree_skb(skb);
1106 return -EFAULT;
1107 }
1108
1109 if (memcmp(skb->data, evt_param, evt->plen)) {
1110 BT_ERR("%s mismatch event parameter (opcode 0x%4.4x)",
1111 hdev->name, le16_to_cpu(cmd->opcode));
1112 kfree_skb(skb);
1113 return -EFAULT;
1114 }
1115 kfree_skb(skb);
1116
1117 return 0;
1118}
1119
1120static int btusb_setup_intel(struct hci_dev *hdev)
1121{
1122 struct sk_buff *skb;
1123 const struct firmware *fw;
1124 const u8 *fw_ptr;
1125 int disable_patch;
1126 struct intel_version *ver;
1127
1128 const u8 mfg_enable[] = { 0x01, 0x00 };
1129 const u8 mfg_disable[] = { 0x00, 0x00 };
1130 const u8 mfg_reset_deactivate[] = { 0x00, 0x01 };
1131 const u8 mfg_reset_activate[] = { 0x00, 0x02 };
1132
1133 BT_DBG("%s", hdev->name);
1134
1135 /* The controller has a bug with the first HCI command sent to it
1136 * returning number of completed commands as zero. This would stall the
1137 * command processing in the Bluetooth core.
1138 *
1139 * As a workaround, send HCI Reset command first which will reset the
1140 * number of completed commands and allow normal command processing
1141 * from now on.
1142 */
1143 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
1144 if (IS_ERR(skb)) {
1145 BT_ERR("%s sending initial HCI reset command failed (%ld)",
1146 hdev->name, PTR_ERR(skb));
1147 return -PTR_ERR(skb);
1148 }
1149 kfree_skb(skb);
1150
1151 /* Read Intel specific controller version first to allow selection of
1152 * which firmware file to load.
1153 *
1154 * The returned information are hardware variant and revision plus
1155 * firmware variant, revision and build number.
1156 */
1157 skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_INIT_TIMEOUT);
1158 if (IS_ERR(skb)) {
1159 BT_ERR("%s reading Intel fw version command failed (%ld)",
1160 hdev->name, PTR_ERR(skb));
1161 return -PTR_ERR(skb);
1162 }
1163
1164 if (skb->len != sizeof(*ver)) {
1165 BT_ERR("%s Intel version event length mismatch", hdev->name);
1166 kfree_skb(skb);
1167 return -EIO;
1168 }
1169
1170 ver = (struct intel_version *)skb->data;
1171 if (ver->status) {
1172 BT_ERR("%s Intel fw version event failed (%02x)", hdev->name,
1173 ver->status);
1174 kfree_skb(skb);
1175 return -bt_to_errno(ver->status);
1176 }
1177
1178 BT_INFO("%s: read Intel version: %02x%02x%02x%02x%02x%02x%02x%02x%02x",
1179 hdev->name, ver->hw_platform, ver->hw_variant,
1180 ver->hw_revision, ver->fw_variant, ver->fw_revision,
1181 ver->fw_build_num, ver->fw_build_ww, ver->fw_build_yy,
1182 ver->fw_patch_num);
1183
1184 /* fw_patch_num indicates the version of patch the device currently
1185 * have. If there is no patch data in the device, it is always 0x00.
1186 * So, if it is other than 0x00, no need to patch the deivce again.
1187 */
1188 if (ver->fw_patch_num) {
1189 BT_INFO("%s: Intel device is already patched. patch num: %02x",
1190 hdev->name, ver->fw_patch_num);
1191 kfree_skb(skb);
1192 return 0;
1193 }
1194
1195 /* Opens the firmware patch file based on the firmware version read
1196 * from the controller. If it fails to open the matching firmware
1197 * patch file, it tries to open the default firmware patch file.
1198 * If no patch file is found, allow the device to operate without
1199 * a patch.
1200 */
1201 fw = btusb_setup_intel_get_fw(hdev, ver);
1202 if (!fw) {
1203 kfree_skb(skb);
1204 return 0;
1205 }
1206 fw_ptr = fw->data;
1207
1208 /* This Intel specific command enables the manufacturer mode of the
1209 * controller.
1210 *
1211 * Only while this mode is enabled, the driver can download the
1212 * firmware patch data and configuration parameters.
1213 */
1214 skb = __hci_cmd_sync(hdev, 0xfc11, 2, mfg_enable, HCI_INIT_TIMEOUT);
1215 if (IS_ERR(skb)) {
1216 BT_ERR("%s entering Intel manufacturer mode failed (%ld)",
1217 hdev->name, PTR_ERR(skb));
1218 release_firmware(fw);
1219 return -PTR_ERR(skb);
1220 }
1221
1222 if (skb->data[0]) {
1223 u8 evt_status = skb->data[0];
1224 BT_ERR("%s enable Intel manufacturer mode event failed (%02x)",
1225 hdev->name, evt_status);
1226 kfree_skb(skb);
1227 release_firmware(fw);
1228 return -bt_to_errno(evt_status);
1229 }
1230 kfree_skb(skb);
1231
1232 disable_patch = 1;
1233
1234 /* The firmware data file consists of list of Intel specific HCI
1235 * commands and its expected events. The first byte indicates the
1236 * type of the message, either HCI command or HCI event.
1237 *
1238 * It reads the command and its expected event from the firmware file,
1239 * and send to the controller. Once __hci_cmd_sync_ev() returns,
1240 * the returned event is compared with the event read from the firmware
1241 * file and it will continue until all the messages are downloaded to
1242 * the controller.
1243 *
1244 * Once the firmware patching is completed successfully,
1245 * the manufacturer mode is disabled with reset and activating the
1246 * downloaded patch.
1247 *
1248 * If the firmware patching fails, the manufacturer mode is
1249 * disabled with reset and deactivating the patch.
1250 *
1251 * If the default patch file is used, no reset is done when disabling
1252 * the manufacturer.
1253 */
1254 while (fw->size > fw_ptr - fw->data) {
1255 int ret;
1256
1257 ret = btusb_setup_intel_patching(hdev, fw, &fw_ptr,
1258 &disable_patch);
1259 if (ret < 0)
1260 goto exit_mfg_deactivate;
1261 }
1262
1263 release_firmware(fw);
1264
1265 if (disable_patch)
1266 goto exit_mfg_disable;
1267
1268 /* Patching completed successfully and disable the manufacturer mode
1269 * with reset and activate the downloaded firmware patches.
1270 */
1271 skb = __hci_cmd_sync(hdev, 0xfc11, sizeof(mfg_reset_activate),
1272 mfg_reset_activate, HCI_INIT_TIMEOUT);
1273 if (IS_ERR(skb)) {
1274 BT_ERR("%s exiting Intel manufacturer mode failed (%ld)",
1275 hdev->name, PTR_ERR(skb));
1276 return -PTR_ERR(skb);
1277 }
1278 kfree_skb(skb);
1279
1280 BT_INFO("%s: Intel Bluetooth firmware patch completed and activated",
1281 hdev->name);
1282
1283 return 0;
1284
1285exit_mfg_disable:
1286 /* Disable the manufacturer mode without reset */
1287 skb = __hci_cmd_sync(hdev, 0xfc11, sizeof(mfg_disable), mfg_disable,
1288 HCI_INIT_TIMEOUT);
1289 if (IS_ERR(skb)) {
1290 BT_ERR("%s exiting Intel manufacturer mode failed (%ld)",
1291 hdev->name, PTR_ERR(skb));
1292 return -PTR_ERR(skb);
1293 }
1294 kfree_skb(skb);
1295
1296 BT_INFO("%s: Intel Bluetooth firmware patch completed", hdev->name);
1297 return 0;
1298
1299exit_mfg_deactivate:
1300 release_firmware(fw);
1301
1302 /* Patching failed. Disable the manufacturer mode with reset and
1303 * deactivate the downloaded firmware patches.
1304 */
1305 skb = __hci_cmd_sync(hdev, 0xfc11, sizeof(mfg_reset_deactivate),
1306 mfg_reset_deactivate, HCI_INIT_TIMEOUT);
1307 if (IS_ERR(skb)) {
1308 BT_ERR("%s exiting Intel manufacturer mode failed (%ld)",
1309 hdev->name, PTR_ERR(skb));
1310 return -PTR_ERR(skb);
1311 }
1312 kfree_skb(skb);
1313
1314 BT_INFO("%s: Intel Bluetooth firmware patch completed and deactivated",
1315 hdev->name);
1316
1317 return 0;
1318}
1319
929static int btusb_probe(struct usb_interface *intf, 1320static int btusb_probe(struct usb_interface *intf,
930 const struct usb_device_id *id) 1321 const struct usb_device_id *id)
931{ 1322{
@@ -1022,11 +1413,17 @@ static int btusb_probe(struct usb_interface *intf,
1022 1413
1023 SET_HCIDEV_DEV(hdev, &intf->dev); 1414 SET_HCIDEV_DEV(hdev, &intf->dev);
1024 1415
1025 hdev->open = btusb_open; 1416 hdev->open = btusb_open;
1026 hdev->close = btusb_close; 1417 hdev->close = btusb_close;
1027 hdev->flush = btusb_flush; 1418 hdev->flush = btusb_flush;
1028 hdev->send = btusb_send_frame; 1419 hdev->send = btusb_send_frame;
1029 hdev->notify = btusb_notify; 1420 hdev->notify = btusb_notify;
1421
1422 if (id->driver_info & BTUSB_BCM92035)
1423 hdev->setup = btusb_setup_bcm92035;
1424
1425 if (id->driver_info & BTUSB_INTEL)
1426 hdev->setup = btusb_setup_intel;
1030 1427
1031 /* Interface numbers are hardcoded in the specification */ 1428 /* Interface numbers are hardcoded in the specification */
1032 data->isoc = usb_ifnum_to_if(data->udev, 1); 1429 data->isoc = usb_ifnum_to_if(data->udev, 1);
@@ -1065,17 +1462,6 @@ static int btusb_probe(struct usb_interface *intf,
1065 data->isoc = NULL; 1462 data->isoc = NULL;
1066 } 1463 }
1067 1464
1068 if (id->driver_info & BTUSB_BCM92035) {
1069 unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 };
1070 struct sk_buff *skb;
1071
1072 skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
1073 if (skb) {
1074 memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
1075 skb_queue_tail(&hdev->driver_init, skb);
1076 }
1077 }
1078
1079 if (data->isoc) { 1465 if (data->isoc) {
1080 err = usb_driver_claim_interface(&btusb_driver, 1466 err = usb_driver_claim_interface(&btusb_driver,
1081 data->isoc, data); 1467 data->isoc, data);
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index c60623f206d4..8ae9f1ea2bb5 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -153,6 +153,9 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
153{ 153{
154 int ret; 154 int ret;
155 155
156 if (!test_bit(HCI_UART_REGISTERED, &hu->flags))
157 return -EUNATCH;
158
156 ret = hci_recv_stream_fragment(hu->hdev, data, count); 159 ret = hci_recv_stream_fragment(hu->hdev, data, count);
157 if (ret < 0) { 160 if (ret < 0) {
158 BT_ERR("Frame Reassembly Failed"); 161 BT_ERR("Frame Reassembly Failed");
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index ed0fade46aed..bc68a440d432 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -260,12 +260,12 @@ static int hci_uart_send_frame(struct sk_buff *skb)
260 260
261/* ------ LDISC part ------ */ 261/* ------ LDISC part ------ */
262/* hci_uart_tty_open 262/* hci_uart_tty_open
263 * 263 *
264 * Called when line discipline changed to HCI_UART. 264 * Called when line discipline changed to HCI_UART.
265 * 265 *
266 * Arguments: 266 * Arguments:
267 * tty pointer to tty info structure 267 * tty pointer to tty info structure
268 * Return Value: 268 * Return Value:
269 * 0 if success, otherwise error code 269 * 0 if success, otherwise error code
270 */ 270 */
271static int hci_uart_tty_open(struct tty_struct *tty) 271static int hci_uart_tty_open(struct tty_struct *tty)
@@ -365,15 +365,15 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
365} 365}
366 366
367/* hci_uart_tty_receive() 367/* hci_uart_tty_receive()
368 * 368 *
369 * Called by tty low level driver when receive data is 369 * Called by tty low level driver when receive data is
370 * available. 370 * available.
371 * 371 *
372 * Arguments: tty pointer to tty isntance data 372 * Arguments: tty pointer to tty isntance data
373 * data pointer to received data 373 * data pointer to received data
374 * flags pointer to flags for data 374 * flags pointer to flags for data
375 * count count of received data in bytes 375 * count count of received data in bytes
376 * 376 *
377 * Return Value: None 377 * Return Value: None
378 */ 378 */
379static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count) 379static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
@@ -388,7 +388,10 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *f
388 388
389 spin_lock(&hu->rx_lock); 389 spin_lock(&hu->rx_lock);
390 hu->proto->recv(hu, (void *) data, count); 390 hu->proto->recv(hu, (void *) data, count);
391 hu->hdev->stat.byte_rx += count; 391
392 if (hu->hdev)
393 hu->hdev->stat.byte_rx += count;
394
392 spin_unlock(&hu->rx_lock); 395 spin_unlock(&hu->rx_lock);
393 396
394 tty_unthrottle(tty); 397 tty_unthrottle(tty);