Bluetooth: btqcomsmd: retrieve BD address from DT property
authorLoic Poulain <loic.poulain@linaro.org>
Fri, 8 Sep 2017 13:57:55 +0000 (15:57 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 6 Oct 2017 18:35:47 +0000 (20:35 +0200)
Retrieve BD address from the local-bd-address property.
This address must be unique and is usually added in the DT
by the bootloader which has access to the provisioned data.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/btqcomsmd.c

index bd810d01538abbd7839575fde15153b062e6fe85..663bed63b87159e6c069d084f9654e9e2f872c28 100644 (file)
@@ -15,6 +15,8 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/rpmsg.h>
+#include <linux/of.h>
+
 #include <linux/soc/qcom/wcnss_ctrl.h>
 #include <linux/platform_device.h>
 
@@ -156,6 +158,15 @@ static int btqcomsmd_probe(struct platform_device *pdev)
        if (IS_ERR(btq->cmd_channel))
                return PTR_ERR(btq->cmd_channel);
 
+       /* The local-bd-address property is usually injected by the
+        * bootloader which has access to the allocated BD address.
+        */
+       if (!of_property_read_u8_array(pdev->dev.of_node, "local-bd-address",
+                                      (u8 *)&btq->bdaddr, sizeof(bdaddr_t))) {
+               dev_info(&pdev->dev, "BD address %pMR retrieved from device-tree",
+                        &btq->bdaddr);
+       }
+
        hdev = hci_alloc_dev();
        if (!hdev)
                return -ENOMEM;