[PATCH 2/3] Bluetooth: btrtl: use board DT compatible string as config postfix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Icenowy Zheng <icenowy@xxxxxxxxxx>

Mimic the behavior of brcmfmac driver, which uses the DT compatible
string of the board as the NVRAM postfix.

Signed-off-by: Icenowy Zheng <icenowy@xxxxxxxxxx>
---
 drivers/bluetooth/hci_h5.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index c5a0409ef84f..d1f90b23a5e0 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -817,6 +817,7 @@ static int h5_serdev_probe(struct serdev_device *serdev)
 {
 	struct device *dev = &serdev->dev;
 	struct h5 *h5;
+	struct device_node *root;
 	const struct h5_device_data *data;
 
 	h5 = devm_kzalloc(dev, sizeof(*h5), GFP_KERNEL);
@@ -847,6 +848,32 @@ static int h5_serdev_probe(struct serdev_device *serdev)
 			return -ENODEV;
 
 		h5->vnd = data->vnd;
+
+		/* Set id to the first string of the machine compatible prop */
+		root = of_find_node_by_path("/");
+		if (root) {
+			int i, len;
+			char *id;
+			const char *tmp;
+
+			of_property_read_string_index(root, "compatible", 0,
+						      &tmp);
+
+			/*
+			 * get rid of '/' in the compatible string to be able
+			 * to find the FW
+			 */
+			len = strlen(tmp) + 1;
+			id = devm_kzalloc(dev, len, GFP_KERNEL);
+			strscpy(id, tmp, len);
+			for (i = 0; i < id[i]; i++) {
+				if (id[i] == '/')
+					id[i] = '-';
+			}
+			h5->id = id;
+
+			of_node_put(root);
+		}
 	}
 
 	if (data->driver_info & H5_INFO_WAKEUP_DISABLE)
-- 
2.35.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux