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