Skip to contentSkip to conversation

Bluetooth: btrtl: Add firmware version print

PATCH In review Alex Lu 2 participants 2 messages Aug 30, 2019 Bluetooth drivers

lore
Share & tools
lore

Alex Lu

author
#0 lore raw

PATCH 2/2 Bluetooth: btrtl: Add firmware version print

From: Alex Lu <[email protected]>

This patch is used to print fw version for debug convenience

---
 drivers/bluetooth/btrtl.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/bluetooth/btrtl.c +16 -0
index b7487ab99eed..7219eb98d02d 100644
@@ -151,6 +151,8 @@ static const struct id_table ic_id_table[] = {
 	  .cfg_name = "rtl_bt/rtl8822b_config" },
 	};
 
+static struct sk_buff *btrtl_read_local_version(struct hci_dev *hdev);
+
 static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev,
 					     u8 hci_ver, u8 hci_bus)
 {
@@ -368,6 +370,8 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 	int frag_len = RTL_FRAG_LEN;
 	int ret = 0;
 	int i;
+	struct sk_buff *skb;
+	struct hci_rp_read_local_version *rp;
 
 	dl_cmd = kmalloc(sizeof(struct rtl_download_cmd), GFP_KERNEL);
 	if (!dl_cmd)
@@ -406,6 +410,18 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 		data += RTL_FRAG_LEN;
 	}
 
+	skb = btrtl_read_local_version(hdev);
+	if (IS_ERR(skb)) {
+		ret = PTR_ERR(skb);
+		rtl_dev_err(hdev, "read local version failed");
+		goto out;
+	}
+
+	rp = (struct hci_rp_read_local_version *)skb->data;
+	rtl_dev_info(hdev, "rtl: fw version 0x%04x%04x",
+		     __le16_to_cpu(rp->hci_rev), __le16_to_cpu(rp->lmp_subver));
+	kfree_skb(skb);
+
 out:
 	kfree(dl_cmd);
 	return ret;
Signature · 1 line
2.21.0
maintainer
#1 lore raw

Hi Alex,

Quoted 35 lines

This patch is used to print fw version for debug convenience

---
drivers/bluetooth/btrtl.c | 16 ++++++++++++++++

1 file changed, 16 insertions(+)
drivers/bluetooth/btrtl.c +6 -0
index b7487ab99eed..7219eb98d02d 100644
@@ -151,6 +151,8 @@ static const struct id_table ic_id_table[] = {
 	  .cfg_name = "rtl_bt/rtl8822b_config" },
 	};
 
+static struct sk_buff *btrtl_read_local_version(struct hci_dev *hdev);
+
 static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev,
 					     u8 hci_ver, u8 hci_bus)
 {
@@ -368,6 +370,8 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 	int frag_len = RTL_FRAG_LEN;
 	int ret = 0;
 	int i;
+	struct sk_buff *skb;
+	struct hci_rp_read_local_version *rp;
 
 	dl_cmd = kmalloc(sizeof(struct rtl_download_cmd), GFP_KERNEL);
 	if (!dl_cmd)
@@ -406,6 +410,18 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 		data += RTL_FRAG_LEN;
 	}
 
+	skb = btrtl_read_local_version(hdev);
+	if (IS_ERR(skb)) {

drivers/bluetooth/btrtl.c static int rtl_download_firmware(struct hci_dev *hdev, · line 424

Quoted 10 lines
drivers/bluetooth/btrtl.c +10 -0
+		ret = PTR_ERR(skb);
+		rtl_dev_err(hdev, "read local version failed");
+		goto out;
+	}
+
+	rp = (struct hci_rp_read_local_version *)skb->data;
+	rtl_dev_info(hdev, "rtl: fw version 0x%04x%04x",
+		     __le16_to_cpu(rp->hci_rev), __le16_to_cpu(rp->lmp_subver));
+	kfree_skb(skb);
+

if you really want to do this, then please re-order the code so that no forward declaration is needed.

Regards

Marcel