Skip to contentSkip to conversation

Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes

PATCH In review [email protected] 2 participants 2 messages Sep 2, 2019 – Sep 4, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes

From: Max Chou <[email protected]>

Fix the issue that when the FW size is 32K+, it will fail for the download process because of the incorrect index.

---
 drivers/bluetooth/btrtl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/bluetooth/btrtl.c +7 -1
index 0354e93e7a7c..215896af0259 100644
@@ -389,6 +389,7 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 	int frag_len = RTL_FRAG_LEN;
 	int ret = 0;
 	int i;
+	int j;
 	struct sk_buff *skb;
 	struct hci_rp_read_local_version *rp;
 
@@ -401,7 +402,12 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 
 		BT_DBG("download fw (%d/%d)", i, frag_num);
 
-		dl_cmd->index = i;
+		if (i > 0x7f)
+			j = (i & 0x7f) + 1;
+		else
+			j = i;
+
+		dl_cmd->index = j;
 		if (i == (frag_num - 1)) {
 			dl_cmd->index |= 0x80; /* data end */
 			frag_len = fw_len % RTL_FRAG_LEN;
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Hi Max,

Quoted 21 lines

Fix the issue that when the FW size is 32K+, it will fail for the download process because of the incorrect index.

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

1 file changed, 7 insertions(+), 1 deletion(-)
drivers/bluetooth/btrtl.c +1 -0
index 0354e93e7a7c..215896af0259 100644
@@ -389,6 +389,7 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 	int frag_len = RTL_FRAG_LEN;
 	int ret = 0;
 	int i;
+	int j;
 	struct sk_buff *skb;
 	struct hci_rp_read_local_version *rp;
 

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

Quoted 10 lines
drivers/bluetooth/btrtl.c +6 -1
@@ -401,7 +402,12 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 
 		BT_DBG("download fw (%d/%d)", i, frag_num);
 
-		dl_cmd->index = i;
+		if (i > 0x7f)
+			j = (i & 0x7f) + 1;
+		else
+			j = i;
+
+		dl_cmd->index = j;

so this seems rather complicated with the extra variable.

		if (i > 0x7f)
			dl_cmd->index = (i & 0x7f) + 1;
		else
			dl_cmd->index = i;

And I would prefer to have a small comment above on why this is done this way.

Regards

Marcel