Bluetooth: hci_qca: Add helper to set device address.
PATCH 1/1 Bluetooth: hci_qca: Add helper to set device address.
This patch add qca_set_device_bdaddr() to set the device address for latest Qualcomm Bluetooth chipset wcn3990 and above.
--- drivers/bluetooth/btqca.c | 21 +++++++++++++++++++++ drivers/bluetooth/btqca.h | 9 ++++++++- drivers/bluetooth/hci_qca.c | 5 ++++- 3 files changed, 33 insertions(+), 2 deletions(-)
drivers/bluetooth/btqca.c +21 -0
@@ -391,6 +391,27 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, }EXPORT_SYMBOL_GPL (qca_uart_setup); +int qca_set_device_bdaddr (struct hci_dev *hdev,const bdaddr_t *bdaddr) +{ +struct sk_buff *skb; +u8 cmd[6 ]; +int err; + +memcpy (cmd, bdaddr,sizeof (bdaddr_t)); + skb =__hci_cmd_sync_ev (hdev,EDL_WRITE_BD_ADDR_OPCODE ,sizeof (cmd), + cmd,HCI_EV_VENDOR ,HCI_INIT_TIMEOUT ); +if (IS_ERR (skb)) { + err =PTR_ERR (skb); +bt_dev_err (hdev,"QCA Change address cmd failed (%d)" , err); +return err; + } + +kfree_skb (skb); + +return 0 ; +} +EXPORT_SYMBOL_GPL (qca_set_device_bdaddr); +MODULE_AUTHOR ("Ben Young Tae Kim <[email protected]>" );MODULE_DESCRIPTION ("Bluetooth support for Qualcomm Atheros family ver " VERSION );MODULE_VERSION (VERSION );
drivers/bluetooth/btqca.h +8 -1
@@ -20,6 +20,7 @@#define EDL_PATCH_CMD_OPCODE (0xFC00)#define EDL_NVM_ACCESS_OPCODE (0xFC0B) +#define EDL_WRITE_BD_ADDR_OPCODE (0xFC14)#define EDL_PATCH_CMD_LEN (1)#define EDL_PATCH_VER_REQ_CMD (0x19)#define EDL_PATCH_TLV_REQ_CMD (0x1E)
@@ -140,7 +141,7 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate,enum qca_btsoc_type soc_type,u32 soc_ver);int qca_read_soc_version (struct hci_dev *hdev,u32 *soc_version); - +int qca_set_device_bdaddr (struct hci_dev *hdev,const bdaddr_t *bdaddr);#else static inline int qca_set_bdaddr_rome (struct hci_dev *hdev,const bdaddr_t *bdaddr)
@@ -159,4 +160,10 @@ static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version) return -EOPNOTSUPP; } +static inline int qca_set_device_bdaddr (struct hci_dev *hdev, +const bdaddr_t *bdaddr) +{ +return -EOPNOTSUPP ; +} +#endif
drivers/bluetooth/hci_qca.c +4 -1
@@ -1241,7 +1241,10 @@ static int qca_setup(struct hci_uart *hu) }/* Setup bdaddr */ - hu->hdev->set_bdaddr = qca_set_bdaddr_rome; +if (qcadev->btsoc_type ==QCA_WCN3990 ) + hu->hdev->set_bdaddr = qca_set_device_bdaddr; +else + hu->hdev->set_bdaddr = qca_set_bdaddr_rome;return ret; }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 15 lines · Balakrishna Godavarthi
This patch add
qca_set_device_bdaddr()to set the device address for latest Qualcomm Bluetooth chipset wcn3990 and above.Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/btqca.c | 21 +++++++++++++++++++++ drivers/bluetooth/btqca.h | 9 ++++++++- drivers/bluetooth/hci_qca.c | 5 ++++- 3 files changed, 33 insertions(+), 2 deletions(-)drivers/bluetooth/btqca.c +0
-0
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, · line 394
Quoted 4 lines
drivers/bluetooth/btqca.c +1
-0@@ -391,6 +391,27 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, }EXPORT_SYMBOL_GPL (qca_uart_setup); +int qca_set_device_bdaddr (struct hci_dev *hdev,const bdaddr_t *bdaddr)
nit: just qca_set_bdaddr() ? That would be consistent with qca_set_bdaddr_rome() and ->set_bdaddr().
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, · line 397
Quoted 3 lines
drivers/bluetooth/btqca.c +3
-0+{ +struct sk_buff *skb; +u8 cmd[6 ];
nit: this doesn't really contain the command (which is EDL_WRITE_BD_ADDR_OPCODE). Name it 'buf', 'ba' or similar?
re-nit: in the memcpy below 'sizeof(bdaddr_t)' is used, do the same in the declaration?
Quoted 58 lines
drivers/bluetooth/btqca.c +17
-0+int err; + +memcpy (cmd, bdaddr,sizeof (bdaddr_t)); + skb =__hci_cmd_sync_ev (hdev,EDL_WRITE_BD_ADDR_OPCODE ,sizeof (cmd), + cmd,HCI_EV_VENDOR ,HCI_INIT_TIMEOUT ); +if (IS_ERR (skb)) { + err =PTR_ERR (skb); +bt_dev_err (hdev,"QCA Change address cmd failed (%d)" , err); +return err; + } + +kfree_skb (skb); + +return 0 ; +} +EXPORT_SYMBOL_GPL (qca_set_device_bdaddr); +MODULE_AUTHOR ("Ben Young Tae Kim <[email protected]>" );MODULE_DESCRIPTION ("Bluetooth support for Qualcomm Atheros family ver " VERSION );MODULE_VERSION (VERSION );drivers/bluetooth/btqca.h +8
-1@@ -20,6 +20,7 @@#define EDL_PATCH_CMD_OPCODE (0xFC00)#define EDL_NVM_ACCESS_OPCODE (0xFC0B) +#define EDL_WRITE_BD_ADDR_OPCODE (0xFC14)#define EDL_PATCH_CMD_LEN (1)#define EDL_PATCH_VER_REQ_CMD (0x19)#define EDL_PATCH_TLV_REQ_CMD (0x1E)@@ -140,7 +141,7 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate,enum qca_btsoc_type soc_type,u32 soc_ver);int qca_read_soc_version (struct hci_dev *hdev,u32 *soc_version); - +int qca_set_device_bdaddr (struct hci_dev *hdev,const bdaddr_t *bdaddr);#else static inline int qca_set_bdaddr_rome (struct hci_dev *hdev,const bdaddr_t *bdaddr)@@ -159,4 +160,10 @@ static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version) return -EOPNOTSUPP; } +static inline int qca_set_device_bdaddr (struct hci_dev *hdev, +const bdaddr_t *bdaddr) +{ +return -EOPNOTSUPP ; +} +#endif drivers/bluetooth/hci_qca.c +0
-0@@ -1241,7 +1241,10 @@ static int qca_setup(struct hci_uart *hu) }
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1250
Quoted 10 lines
drivers/bluetooth/hci_qca.c +4
-1/* Setup bdaddr */ - hu->hdev->set_bdaddr = qca_set_bdaddr_rome; +if (qcadev->btsoc_type ==QCA_WCN3990 ) + hu->hdev->set_bdaddr = qca_set_device_bdaddr; +else + hu->hdev->set_bdaddr = qca_set_bdaddr_rome;return ret; }
Hi Matthias,
Quoted 20 lines · Matthias Kaehlcke
Quoted 19 lines · Balakrishna Godavarthi
This patch add
qca_set_device_bdaddr()to set the device address for latest Qualcomm Bluetooth chipset wcn3990 and above.Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/btqca.c | 21 +++++++++++++++++++++ drivers/bluetooth/btqca.h | 9 ++++++++- drivers/bluetooth/hci_qca.c | 5 ++++- 3 files changed, 33 insertions(+), 2 deletions(-)drivers/bluetooth/btqca.c +0
-0@@ -391,6 +391,27 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, }EXPORT_SYMBOL_GPL (qca_uart_setup);
Quoted 6 lines
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t · line 396
Quoted 2 lines
drivers/bluetooth/btqca.c +1
-0+int qca_set_device_bdaddr (struct hci_dev *hdev,const bdaddr_t *bdaddr)nit: just
qca_set_bdaddr()? That would be consistent withqca_set_bdaddr_rome()and ->set_bdaddr().
[Bala]: will update.
Quoted 7 lines
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, · line 397
Quoted 3 lines
drivers/bluetooth/btqca.c +3
-0+{ +struct sk_buff *skb; +u8 cmd[6 ];nit: this doesn't really contain the command (which is
EDL_WRITE_BD_ADDR_OPCODE). Name it 'buf', 'ba' or similar?
[Bala]: will update with ba.
Quoted 79 lines
re-nit: in the memcpy below '
sizeof(bdaddr_t)' is used, do the same in the declaration?Quoted 63 lines
drivers/bluetooth/btqca.c +17
-0+int err; + +memcpy (cmd, bdaddr,sizeof (bdaddr_t)); + skb =__hci_cmd_sync_ev (hdev,EDL_WRITE_BD_ADDR_OPCODE ,sizeof (cmd), + cmd,HCI_EV_VENDOR ,HCI_INIT_TIMEOUT ); +if (IS_ERR (skb)) { + err =PTR_ERR (skb); +bt_dev_err (hdev,"QCA Change address cmd failed (%d)" , err); +return err; + } + +kfree_skb (skb); + +return 0 ; +} +EXPORT_SYMBOL_GPL (qca_set_device_bdaddr); +MODULE_AUTHOR ("Ben Young Tae Kim <[email protected]>" );MODULE_DESCRIPTION("Bluetooth support for Qualcomm Atheros family ver
" VERSION);
MODULE_VERSION(VERSION);drivers/bluetooth/btqca.h +2
-1@@ -20,6 +20,7 @@#define EDL_PATCH_CMD_OPCODE (0xFC00)#define EDL_NVM_ACCESS_OPCODE (0xFC0B) +#define EDL_WRITE_BD_ADDR_OPCODE (0xFC14)#define EDL_PATCH_CMD_LEN (1)#define EDL_PATCH_VER_REQ_CMD (0x19)#define EDL_PATCH_TLV_REQ_CMD (0x1E)@@ -140,7 +141,7 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate,enum qca_btsoc_type soc_type,u32 soc_ver);int qca_read_soc_version (struct hci_dev *hdev,u32 *soc_version); - +int qca_set_device_bdaddr (struct hci_dev *hdev,const bdaddr_t *bdaddr);#else static inline int qca_set_bdaddr_rome(struct
hci_dev*hdev, constbdaddr_t*bdaddr)drivers/bluetooth/btqca.h +6
-0@@ -159,4 +160,10 @@ static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)return -EOPNOTSUPP ; } +static inline int qca_set_device_bdaddr (struct hci_dev *hdev, +const bdaddr_t *bdaddr) +{ +return -EOPNOTSUPP ; +} +#endif
drivers/bluetooth/hci_qca.c +0
-0@@ -1241,7 +1241,10 @@ static int qca_setup(struct hci_uart *hu) }drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1250
Quoted 10 lines
drivers/bluetooth/hci_qca.c +4
-1/* Setup bdaddr */ - hu->hdev->set_bdaddr = qca_set_bdaddr_rome; +if (qcadev->btsoc_type ==QCA_WCN3990 ) + hu->hdev->set_bdaddr = qca_set_device_bdaddr; +else + hu->hdev->set_bdaddr = qca_set_bdaddr_rome;return ret; }Reviewed-by Matthias Kaehlcke <[email protected]>Tested-by Matthias Kaehlcke <[email protected]>
Signature · 2 lines
Regards Balakrishna.