Bluetooth: hci_sync: Add fallback-bd-address prop

The kernel Bluetooth framework understands that devices may not
be programmed with valid Bluetooth addresses. It also has the ability
to override a Bluetooth address with the value of the local-bd-address
DT property, but it ignores the validity of the existing address when
doing so.

Add a new boolean property, fallback-bd-address, which indicates that
the given local-bd-address property should only be used if the device
does not already have a valid BDADDR.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
This commit is contained in:
Phil Elwell
2023-04-25 11:49:41 +01:00
committed by Dom Cobley
parent b6b2fa04ae
commit 7f3fc3fc9f

View File

@@ -4957,6 +4957,7 @@ static const struct {
*/ */
static int hci_dev_setup_sync(struct hci_dev *hdev) static int hci_dev_setup_sync(struct hci_dev *hdev)
{ {
struct fwnode_handle *fwnode = dev_fwnode(hdev->dev.parent);
int ret = 0; int ret = 0;
bool invalid_bdaddr; bool invalid_bdaddr;
size_t i; size_t i;
@@ -4985,7 +4986,8 @@ static int hci_dev_setup_sync(struct hci_dev *hdev)
hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY); hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY);
if (!ret) { if (!ret) {
if (hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY) && if (hci_test_quirk(hdev, HCI_QUIRK_USE_BDADDR_PROPERTY) &&
!bacmp(&hdev->public_addr, BDADDR_ANY)) !bacmp(&hdev->public_addr, BDADDR_ANY) &&
(invalid_bdaddr || !fwnode_property_present(fwnode, "fallback-bd-address")))
hci_dev_get_bd_addr_from_property(hdev); hci_dev_get_bd_addr_from_property(hdev);
if (invalid_bdaddr && bacmp(&hdev->public_addr, BDADDR_ANY) && if (invalid_bdaddr && bacmp(&hdev->public_addr, BDADDR_ANY) &&