Bluetooth: Add support for changing the public device address
Subsystems (2)
Marcel Holtmann
maintainerPATCH 2/3 Bluetooth: Add support for changing the public device address
This adds support for changing the public device address. This feature is required by controllers that do not provide a public address and have HCI_QUIRK_INVALID_BDADDR set.
Even if a controller has a public device address, this is useful when an embedded system wants to use its own value. As long as the driver provides the set_bdaddr callback, this allows changing the device address before powering on the controller.
Signed-off-by Marcel Holtmann <[email protected]>
--- include/net/bluetooth/mgmt.h | 6 +++++ net/bluetooth/hci_core.c | 14 ++++++----- net/bluetooth/mgmt.c | 57 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 7 deletions(-)
include/net/bluetooth/mgmt.h +6 -0
@@ -489,6 +489,12 @@ struct mgmt_cp_set_external_config { } __packed;#define MGMT_SET_EXTERNAL_CONFIG_SIZE 1 +#define MGMT_OP_SET_PUBLIC_ADDRESS 0x0039 +struct mgmt_cp_set_public_address { +bdaddr_t bdaddr; +} __packed; +#define MGMT_SET_PUBLIC_ADDRESS_SIZE 6 +#define MGMT_EV_CMD_COMPLETE 0x0001struct mgmt_ev_cmd_complete {__le16 opcode;
net/bluetooth/hci_core.c +8 -6
@@ -2302,12 +2302,14 @@ static int hci_dev_do_open(struct hci_dev *hdev) ret =__hci_unconf_init (hdev); } -/* If public address change is configured, ensure that the -* address gets programmed. If the driver does not support -* changing the public address, fail the power on procedure. -*/ -if (!ret &&bacmp (&hdev->public_addr,BDADDR_ANY )) { -if (hdev->set_bdaddr) +if (test_bit (HCI_CONFIG , &hdev->dev_flags)) { +/* If public address change is configured, ensure that +* the address gets programmed. If the driver does not +* support changing the public address, fail the power +* on procedure. +*/ +if (bacmp (&hdev->public_addr,BDADDR_ANY ) && + hdev->set_bdaddr) ret = hdev->set_bdaddr (hdev, &hdev->public_addr);else ret = -EADDRNOTAVAIL ;
net/bluetooth/mgmt.c +56 -1
81 lines not on this page · raw message
Signature · 1 line
1.9.3