Skip to content

Commit dd33664

Browse files
jhovoldVudentz
authored andcommitted
Bluetooth: qca: generalise device address check
The default device address apparently comes from the NVM configuration file and can differ quite a bit between controllers. Store the default address when parsing the configuration file and use it to determine whether the controller has been provisioned with an address. This makes sure that devices without a unique address start as unconfigured unless a valid address has been provided in the devicetree. Fixes: 32868e1 ("Bluetooth: qca: fix invalid device address check") Cc: [email protected] # 6.5 Cc: Doug Anderson <[email protected]> Cc: Janaki Ramaiah Thota <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Tested-by: Douglas Anderson <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent a112d3c commit dd33664

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

drivers/bluetooth/btqca.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515

1616
#define VERSION "0.1"
1717

18-
#define QCA_BDADDR_DEFAULT (&(bdaddr_t) {{ 0xad, 0x5a, 0x00, 0x00, 0x00, 0x00 }})
19-
#define QCA_BDADDR_WCN3991 (&(bdaddr_t) {{ 0xad, 0x5a, 0x00, 0x00, 0x98, 0x39 }})
20-
2118
int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver,
2219
enum qca_btsoc_type soc_type)
2320
{
@@ -387,6 +384,14 @@ static int qca_tlv_check_data(struct hci_dev *hdev,
387384

388385
/* Update NVM tags as needed */
389386
switch (tag_id) {
387+
case EDL_TAG_ID_BD_ADDR:
388+
if (tag_len != sizeof(bdaddr_t))
389+
return -EINVAL;
390+
391+
memcpy(&config->bdaddr, tlv_nvm->data, sizeof(bdaddr_t));
392+
393+
break;
394+
390395
case EDL_TAG_ID_HCI:
391396
if (tag_len < 3)
392397
return -EINVAL;
@@ -661,7 +666,7 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
661666
}
662667
EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome);
663668

664-
static int qca_check_bdaddr(struct hci_dev *hdev)
669+
static int qca_check_bdaddr(struct hci_dev *hdev, const struct qca_fw_config *config)
665670
{
666671
struct hci_rp_read_bd_addr *bda;
667672
struct sk_buff *skb;
@@ -685,10 +690,8 @@ static int qca_check_bdaddr(struct hci_dev *hdev)
685690
}
686691

687692
bda = (struct hci_rp_read_bd_addr *)skb->data;
688-
if (!bacmp(&bda->bdaddr, QCA_BDADDR_DEFAULT) ||
689-
!bacmp(&bda->bdaddr, QCA_BDADDR_WCN3991)) {
693+
if (!bacmp(&bda->bdaddr, &config->bdaddr))
690694
set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
691-
}
692695

693696
kfree_skb(skb);
694697

@@ -716,7 +719,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
716719
enum qca_btsoc_type soc_type, struct qca_btsoc_version ver,
717720
const char *firmware_name)
718721
{
719-
struct qca_fw_config config;
722+
struct qca_fw_config config = {};
720723
int err;
721724
u8 rom_ver = 0;
722725
u32 soc_ver;
@@ -901,7 +904,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
901904
break;
902905
}
903906

904-
err = qca_check_bdaddr(hdev);
907+
err = qca_check_bdaddr(hdev, &config);
905908
if (err)
906909
return err;
907910

drivers/bluetooth/btqca.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define EDL_PATCH_CONFIG_RES_EVT (0x00)
3030
#define QCA_DISABLE_LOGGING_SUB_OP (0x14)
3131

32+
#define EDL_TAG_ID_BD_ADDR 2
3233
#define EDL_TAG_ID_HCI (17)
3334
#define EDL_TAG_ID_DEEP_SLEEP (27)
3435

@@ -94,6 +95,7 @@ struct qca_fw_config {
9495
uint8_t user_baud_rate;
9596
enum qca_tlv_dnld_mode dnld_mode;
9697
enum qca_tlv_dnld_mode dnld_type;
98+
bdaddr_t bdaddr;
9799
};
98100

99101
struct edl_event_hdr {

0 commit comments

Comments
 (0)