950-0699-Bluetooth-hci_sync-Add-fallback-bd-address-prop.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. From dffb648dffeab7246040a30b7d1669387d1e767e 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] 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 | 5 ++++-
  16. 1 file changed, 4 insertions(+), 1 deletion(-)
  17. --- a/net/bluetooth/hci_sync.c
  18. +++ b/net/bluetooth/hci_sync.c
  19. @@ -4630,6 +4630,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. @@ -4658,7 +4659,9 @@ static int hci_dev_setup_sync(struct hci
  28. if (!ret) {
  29. if (test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks) &&
  30. - !bacmp(&hdev->public_addr, BDADDR_ANY))
  31. + !bacmp(&hdev->public_addr, BDADDR_ANY) &&
  32. + (invalid_bdaddr ||
  33. + !fwnode_property_present(fwnode, "fallback-bd-address")))
  34. hci_dev_get_bd_addr_from_property(hdev);
  35. if ((invalid_bdaddr ||