950-0441-Bluetooth-hci_sync-Add-fallback-bd-address-prop.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From b6134fc75ddd8f2f6493edbb6260f0a12acb9057 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <[email protected]>
  3. Date: Tue, 25 Apr 2023 11:49:41 +0100
  4. Subject: [PATCH 0441/1085] Bluetooth: hci_sync: Add fallback-bd-address prop
  5. The kernel Bluetooth framework understands that devices may not
  6. be programmed with valid Bluetooth addresses. It also has the ability
  7. to override a Bluetooth address with the value of the local-bd-address
  8. DT property, but it ignores the validity of the existing address when
  9. doing so.
  10. Add a new boolean property, fallback-bd-address, which indicates that
  11. the given local-bd-address property should only be used if the device
  12. does not already have a valid BDADDR.
  13. Signed-off-by: Phil Elwell <[email protected]>
  14. ---
  15. net/bluetooth/hci_sync.c | 4 +++-
  16. 1 file changed, 3 insertions(+), 1 deletion(-)
  17. --- a/net/bluetooth/hci_sync.c
  18. +++ b/net/bluetooth/hci_sync.c
  19. @@ -4873,6 +4873,7 @@ static const struct {
  20. */
  21. static int hci_dev_setup_sync(struct hci_dev *hdev)
  22. {
  23. + struct fwnode_handle *fwnode = dev_fwnode(hdev->dev.parent);
  24. int ret = 0;
  25. bool invalid_bdaddr;
  26. size_t i;
  27. @@ -4901,7 +4902,8 @@ static int hci_dev_setup_sync(struct hci
  28. test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
  29. if (!ret) {
  30. if (test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks) &&
  31. - !bacmp(&hdev->public_addr, BDADDR_ANY))
  32. + !bacmp(&hdev->public_addr, BDADDR_ANY) &&
  33. + (invalid_bdaddr || !fwnode_property_present(fwnode, "fallback-bd-address")))
  34. hci_dev_get_bd_addr_from_property(hdev);
  35. if (invalid_bdaddr && bacmp(&hdev->public_addr, BDADDR_ANY) &&