Skip to content

Commit fcd8c62

Browse files
committed
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
Johan Hedberg says: ==================== pull request: bluetooth-next 2019-09-06 Here's the main bluetooth-next pull request for the 5.4 kernel. - Cleanups & fixes to btrtl driver - Fixes for Realtek devices in btusb, e.g. for suspend handling - Firmware loading support for BCM4345C5 - hidp_send_message() return value handling fixes - Added support for utilizing Fast Advertising Interval - Various other minor cleanups & fixes Please let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents e9ac25b + 8bb3537 commit fcd8c62

File tree

13 files changed

+197
-110
lines changed

13 files changed

+197
-110
lines changed

Documentation/devicetree/bindings/net/broadcom-bluetooth.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Required properties:
1313
* "brcm,bcm20702a1"
1414
* "brcm,bcm4330-bt"
1515
* "brcm,bcm43438-bt"
16+
* "brcm,bcm4345c5"
1617

1718
Optional properties:
1819

drivers/bluetooth/btbcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define BDADDR_BCM43430A0 (&(bdaddr_t) {{0xac, 0x1f, 0x12, 0xa0, 0x43, 0x43}})
2424
#define BDADDR_BCM4324B3 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb3, 0x24, 0x43}})
2525
#define BDADDR_BCM4330B1 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb1, 0x30, 0x43}})
26+
#define BDADDR_BCM4345C5 (&(bdaddr_t) {{0xac, 0x1f, 0x00, 0xc5, 0x45, 0x43}})
2627
#define BDADDR_BCM43341B (&(bdaddr_t) {{0xac, 0x1f, 0x00, 0x1b, 0x34, 0x43}})
2728

2829
int btbcm_check_bdaddr(struct hci_dev *hdev)
@@ -73,6 +74,7 @@ int btbcm_check_bdaddr(struct hci_dev *hdev)
7374
!bacmp(&bda->bdaddr, BDADDR_BCM2076B1) ||
7475
!bacmp(&bda->bdaddr, BDADDR_BCM4324B3) ||
7576
!bacmp(&bda->bdaddr, BDADDR_BCM4330B1) ||
77+
!bacmp(&bda->bdaddr, BDADDR_BCM4345C5) ||
7678
!bacmp(&bda->bdaddr, BDADDR_BCM43430A0) ||
7779
!bacmp(&bda->bdaddr, BDADDR_BCM43341B)) {
7880
bt_dev_info(hdev, "BCM: Using default device address (%pMR)",
@@ -332,6 +334,7 @@ static const struct bcm_subver_table bcm_uart_subver_table[] = {
332334
{ 0x2122, "BCM4343A0" }, /* 001.001.034 */
333335
{ 0x2209, "BCM43430A1" }, /* 001.002.009 */
334336
{ 0x6119, "BCM4345C0" }, /* 003.001.025 */
337+
{ 0x6606, "BCM4345C5" }, /* 003.006.006 */
335338
{ 0x230f, "BCM4356A2" }, /* 001.003.015 */
336339
{ 0x220e, "BCM20702A1" }, /* 001.002.014 */
337340
{ 0x4217, "BCM4329B1" }, /* 002.002.023 */

drivers/bluetooth/btqca.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)
106106

107107
bt_dev_dbg(hdev, "QCA pre shutdown cmd");
108108

109-
skb = __hci_cmd_sync(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
110-
NULL, HCI_INIT_TIMEOUT);
109+
skb = __hci_cmd_sync_ev(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
110+
NULL, HCI_EV_CMD_COMPLETE, HCI_INIT_TIMEOUT);
111+
111112
if (IS_ERR(skb)) {
112113
err = PTR_ERR(skb);
113114
bt_dev_err(hdev, "QCA preshutdown_cmd failed (%d)", err);

drivers/bluetooth/btrtl.c

Lines changed: 74 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,27 @@ static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev,
178178
return &ic_id_table[i];
179179
}
180180

181+
static struct sk_buff *btrtl_read_local_version(struct hci_dev *hdev)
182+
{
183+
struct sk_buff *skb;
184+
185+
skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL,
186+
HCI_INIT_TIMEOUT);
187+
if (IS_ERR(skb)) {
188+
rtl_dev_err(hdev, "HCI_OP_READ_LOCAL_VERSION failed (%ld)",
189+
PTR_ERR(skb));
190+
return skb;
191+
}
192+
193+
if (skb->len != sizeof(struct hci_rp_read_local_version)) {
194+
rtl_dev_err(hdev, "HCI_OP_READ_LOCAL_VERSION event length mismatch");
195+
kfree_skb(skb);
196+
return ERR_PTR(-EIO);
197+
}
198+
199+
return skb;
200+
}
201+
181202
static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version)
182203
{
183204
struct rtl_rom_version_evt *rom_version;
@@ -186,19 +207,19 @@ static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version)
186207
/* Read RTL ROM version command */
187208
skb = __hci_cmd_sync(hdev, 0xfc6d, 0, NULL, HCI_INIT_TIMEOUT);
188209
if (IS_ERR(skb)) {
189-
rtl_dev_err(hdev, "Read ROM version failed (%ld)\n",
210+
rtl_dev_err(hdev, "Read ROM version failed (%ld)",
190211
PTR_ERR(skb));
191212
return PTR_ERR(skb);
192213
}
193214

194215
if (skb->len != sizeof(*rom_version)) {
195-
rtl_dev_err(hdev, "RTL version event length mismatch\n");
216+
rtl_dev_err(hdev, "version event length mismatch");
196217
kfree_skb(skb);
197218
return -EIO;
198219
}
199220

200221
rom_version = (struct rtl_rom_version_evt *)skb->data;
201-
rtl_dev_info(hdev, "rom_version status=%x version=%x\n",
222+
rtl_dev_info(hdev, "rom_version status=%x version=%x",
202223
rom_version->status, rom_version->version);
203224

204225
*version = rom_version->version;
@@ -242,7 +263,7 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev,
242263

243264
fwptr = btrtl_dev->fw_data + btrtl_dev->fw_len - sizeof(extension_sig);
244265
if (memcmp(fwptr, extension_sig, sizeof(extension_sig)) != 0) {
245-
rtl_dev_err(hdev, "extension section signature mismatch\n");
266+
rtl_dev_err(hdev, "extension section signature mismatch");
246267
return -EINVAL;
247268
}
248269

@@ -263,7 +284,7 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev,
263284
break;
264285

265286
if (length == 0) {
266-
rtl_dev_err(hdev, "found instruction with length 0\n");
287+
rtl_dev_err(hdev, "found instruction with length 0");
267288
return -EINVAL;
268289
}
269290

@@ -276,7 +297,7 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev,
276297
}
277298

278299
if (project_id < 0) {
279-
rtl_dev_err(hdev, "failed to find version instruction\n");
300+
rtl_dev_err(hdev, "failed to find version instruction");
280301
return -EINVAL;
281302
}
282303

@@ -287,21 +308,21 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev,
287308
}
288309

289310
if (i >= ARRAY_SIZE(project_id_to_lmp_subver)) {
290-
rtl_dev_err(hdev, "unknown project id %d\n", project_id);
311+
rtl_dev_err(hdev, "unknown project id %d", project_id);
291312
return -EINVAL;
292313
}
293314

294315
if (btrtl_dev->ic_info->lmp_subver !=
295316
project_id_to_lmp_subver[i].lmp_subver) {
296-
rtl_dev_err(hdev, "firmware is for %x but this is a %x\n",
317+
rtl_dev_err(hdev, "firmware is for %x but this is a %x",
297318
project_id_to_lmp_subver[i].lmp_subver,
298319
btrtl_dev->ic_info->lmp_subver);
299320
return -EINVAL;
300321
}
301322

302323
epatch_info = (struct rtl_epatch_header *)btrtl_dev->fw_data;
303324
if (memcmp(epatch_info->signature, RTL_EPATCH_SIGNATURE, 8) != 0) {
304-
rtl_dev_err(hdev, "bad EPATCH signature\n");
325+
rtl_dev_err(hdev, "bad EPATCH signature");
305326
return -EINVAL;
306327
}
307328

@@ -368,6 +389,8 @@ static int rtl_download_firmware(struct hci_dev *hdev,
368389
int frag_len = RTL_FRAG_LEN;
369390
int ret = 0;
370391
int i;
392+
struct sk_buff *skb;
393+
struct hci_rp_read_local_version *rp;
371394

372395
dl_cmd = kmalloc(sizeof(struct rtl_download_cmd), GFP_KERNEL);
373396
if (!dl_cmd)
@@ -378,7 +401,11 @@ static int rtl_download_firmware(struct hci_dev *hdev,
378401

379402
BT_DBG("download fw (%d/%d)", i, frag_num);
380403

381-
dl_cmd->index = i;
404+
if (i > 0x7f)
405+
dl_cmd->index = (i & 0x7f) + 1;
406+
else
407+
dl_cmd->index = i;
408+
382409
if (i == (frag_num - 1)) {
383410
dl_cmd->index |= 0x80; /* data end */
384411
frag_len = fw_len % RTL_FRAG_LEN;
@@ -389,14 +416,14 @@ static int rtl_download_firmware(struct hci_dev *hdev,
389416
skb = __hci_cmd_sync(hdev, 0xfc20, frag_len + 1, dl_cmd,
390417
HCI_INIT_TIMEOUT);
391418
if (IS_ERR(skb)) {
392-
rtl_dev_err(hdev, "download fw command failed (%ld)\n",
419+
rtl_dev_err(hdev, "download fw command failed (%ld)",
393420
PTR_ERR(skb));
394421
ret = -PTR_ERR(skb);
395422
goto out;
396423
}
397424

398425
if (skb->len != sizeof(struct rtl_download_response)) {
399-
rtl_dev_err(hdev, "download fw event length mismatch\n");
426+
rtl_dev_err(hdev, "download fw event length mismatch");
400427
kfree_skb(skb);
401428
ret = -EIO;
402429
goto out;
@@ -406,6 +433,18 @@ static int rtl_download_firmware(struct hci_dev *hdev,
406433
data += RTL_FRAG_LEN;
407434
}
408435

436+
skb = btrtl_read_local_version(hdev);
437+
if (IS_ERR(skb)) {
438+
ret = PTR_ERR(skb);
439+
rtl_dev_err(hdev, "read local version failed");
440+
goto out;
441+
}
442+
443+
rp = (struct hci_rp_read_local_version *)skb->data;
444+
rtl_dev_info(hdev, "fw version 0x%04x%04x",
445+
__le16_to_cpu(rp->hci_rev), __le16_to_cpu(rp->lmp_subver));
446+
kfree_skb(skb);
447+
409448
out:
410449
kfree(dl_cmd);
411450
return ret;
@@ -416,7 +455,7 @@ static int rtl_load_file(struct hci_dev *hdev, const char *name, u8 **buff)
416455
const struct firmware *fw;
417456
int ret;
418457

419-
rtl_dev_info(hdev, "rtl: loading %s\n", name);
458+
rtl_dev_info(hdev, "loading %s", name);
420459
ret = request_firmware(&fw, name, &hdev->dev);
421460
if (ret < 0)
422461
return ret;
@@ -440,7 +479,7 @@ static int btrtl_setup_rtl8723a(struct hci_dev *hdev,
440479
* (which is only for RTL8723B and newer).
441480
*/
442481
if (!memcmp(btrtl_dev->fw_data, RTL_EPATCH_SIGNATURE, 8)) {
443-
rtl_dev_err(hdev, "unexpected EPATCH signature!\n");
482+
rtl_dev_err(hdev, "unexpected EPATCH signature!");
444483
return -EINVAL;
445484
}
446485

@@ -475,7 +514,7 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev,
475514
fw_data = tbuff;
476515
}
477516

478-
rtl_dev_info(hdev, "cfg_sz %d, total sz %d\n", btrtl_dev->cfg_len, ret);
517+
rtl_dev_info(hdev, "cfg_sz %d, total sz %d", btrtl_dev->cfg_len, ret);
479518

480519
ret = rtl_download_firmware(hdev, fw_data, ret);
481520

@@ -484,27 +523,6 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev,
484523
return ret;
485524
}
486525

487-
static struct sk_buff *btrtl_read_local_version(struct hci_dev *hdev)
488-
{
489-
struct sk_buff *skb;
490-
491-
skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL,
492-
HCI_INIT_TIMEOUT);
493-
if (IS_ERR(skb)) {
494-
rtl_dev_err(hdev, "HCI_OP_READ_LOCAL_VERSION failed (%ld)\n",
495-
PTR_ERR(skb));
496-
return skb;
497-
}
498-
499-
if (skb->len != sizeof(struct hci_rp_read_local_version)) {
500-
rtl_dev_err(hdev, "HCI_OP_READ_LOCAL_VERSION event length mismatch\n");
501-
kfree_skb(skb);
502-
return ERR_PTR(-EIO);
503-
}
504-
505-
return skb;
506-
}
507-
508526
void btrtl_free(struct btrtl_device_info *btrtl_dev)
509527
{
510528
kfree(btrtl_dev->fw_data);
@@ -537,7 +555,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
537555
}
538556

539557
resp = (struct hci_rp_read_local_version *)skb->data;
540-
rtl_dev_info(hdev, "rtl: examining hci_ver=%02x hci_rev=%04x lmp_ver=%02x lmp_subver=%04x\n",
558+
rtl_dev_info(hdev, "examining hci_ver=%02x hci_rev=%04x lmp_ver=%02x lmp_subver=%04x",
541559
resp->hci_ver, resp->hci_rev,
542560
resp->lmp_ver, resp->lmp_subver);
543561

@@ -550,7 +568,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
550568
hdev->bus);
551569

552570
if (!btrtl_dev->ic_info) {
553-
rtl_dev_info(hdev, "rtl: unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x",
571+
rtl_dev_info(hdev, "unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x",
554572
lmp_subver, hci_rev, hci_ver);
555573
return btrtl_dev;
556574
}
@@ -564,7 +582,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
564582
btrtl_dev->fw_len = rtl_load_file(hdev, btrtl_dev->ic_info->fw_name,
565583
&btrtl_dev->fw_data);
566584
if (btrtl_dev->fw_len < 0) {
567-
rtl_dev_err(hdev, "firmware file %s not found\n",
585+
rtl_dev_err(hdev, "firmware file %s not found",
568586
btrtl_dev->ic_info->fw_name);
569587
ret = btrtl_dev->fw_len;
570588
goto err_free;
@@ -582,7 +600,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
582600
&btrtl_dev->cfg_data);
583601
if (btrtl_dev->ic_info->config_needed &&
584602
btrtl_dev->cfg_len <= 0) {
585-
rtl_dev_err(hdev, "mandatory config file %s not found\n",
603+
rtl_dev_err(hdev, "mandatory config file %s not found",
586604
btrtl_dev->ic_info->cfg_name);
587605
ret = btrtl_dev->cfg_len;
588606
goto err_free;
@@ -608,7 +626,7 @@ int btrtl_download_firmware(struct hci_dev *hdev,
608626
* to a different value.
609627
*/
610628
if (!btrtl_dev->ic_info) {
611-
rtl_dev_info(hdev, "rtl: assuming no firmware upload needed\n");
629+
rtl_dev_info(hdev, "assuming no firmware upload needed");
612630
return 0;
613631
}
614632

@@ -622,7 +640,7 @@ int btrtl_download_firmware(struct hci_dev *hdev,
622640
case RTL_ROM_LMP_8822B:
623641
return btrtl_setup_rtl8723b(hdev, btrtl_dev);
624642
default:
625-
rtl_dev_info(hdev, "rtl: assuming no firmware upload needed\n");
643+
rtl_dev_info(hdev, "assuming no firmware upload needed");
626644
return 0;
627645
}
628646
}
@@ -641,6 +659,11 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
641659

642660
btrtl_free(btrtl_dev);
643661

662+
/* Enable controller to do both LE scan and BR/EDR inquiry
663+
* simultaneously.
664+
*/
665+
set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
666+
644667
return ret;
645668
}
646669
EXPORT_SYMBOL_GPL(btrtl_setup_realtek);
@@ -714,18 +737,18 @@ int btrtl_get_uart_settings(struct hci_dev *hdev,
714737

715738
total_data_len = btrtl_dev->cfg_len - sizeof(*config);
716739
if (total_data_len <= 0) {
717-
rtl_dev_warn(hdev, "no config loaded\n");
740+
rtl_dev_warn(hdev, "no config loaded");
718741
return -EINVAL;
719742
}
720743

721744
config = (struct rtl_vendor_config *)btrtl_dev->cfg_data;
722745
if (le32_to_cpu(config->signature) != RTL_CONFIG_MAGIC) {
723-
rtl_dev_err(hdev, "invalid config magic\n");
746+
rtl_dev_err(hdev, "invalid config magic");
724747
return -EINVAL;
725748
}
726749

727750
if (total_data_len < le16_to_cpu(config->total_len)) {
728-
rtl_dev_err(hdev, "config is too short\n");
751+
rtl_dev_err(hdev, "config is too short");
729752
return -EINVAL;
730753
}
731754

@@ -735,7 +758,7 @@ int btrtl_get_uart_settings(struct hci_dev *hdev,
735758
switch (le16_to_cpu(entry->offset)) {
736759
case 0xc:
737760
if (entry->len < sizeof(*device_baudrate)) {
738-
rtl_dev_err(hdev, "invalid UART config entry\n");
761+
rtl_dev_err(hdev, "invalid UART config entry");
739762
return -EINVAL;
740763
}
741764

@@ -752,7 +775,7 @@ int btrtl_get_uart_settings(struct hci_dev *hdev,
752775
break;
753776

754777
default:
755-
rtl_dev_dbg(hdev, "skipping config entry 0x%x (len %u)\n",
778+
rtl_dev_dbg(hdev, "skipping config entry 0x%x (len %u)",
756779
le16_to_cpu(entry->offset), entry->len);
757780
break;
758781
};
@@ -761,13 +784,13 @@ int btrtl_get_uart_settings(struct hci_dev *hdev,
761784
}
762785

763786
if (!found) {
764-
rtl_dev_err(hdev, "no UART config entry found\n");
787+
rtl_dev_err(hdev, "no UART config entry found");
765788
return -ENOENT;
766789
}
767790

768-
rtl_dev_dbg(hdev, "device baudrate = 0x%08x\n", *device_baudrate);
769-
rtl_dev_dbg(hdev, "controller baudrate = %u\n", *controller_baudrate);
770-
rtl_dev_dbg(hdev, "flow control %d\n", *flow_control);
791+
rtl_dev_dbg(hdev, "device baudrate = 0x%08x", *device_baudrate);
792+
rtl_dev_dbg(hdev, "controller baudrate = %u", *controller_baudrate);
793+
rtl_dev_dbg(hdev, "flow control %d", *flow_control);
771794

772795
return 0;
773796
}

0 commit comments

Comments
 (0)