LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btrtl: Correct the length of the HCI command for drop fw
@ 2023-05-30  8:34 max.chou
  2023-06-05 19:40 ` patchwork-bot+bluetooth
  0 siblings, 1 reply; 2+ messages in thread
From: max.chou @ 2023-05-30  8:34 UTC (permalink / raw
  To: marcel, johan.hedberg, luiz.dentz
  Cc: linux-bluetooth, linux-kernel, alex_lu, hildawu, max.chou

From: Max Chou <max.chou@realtek.com>

The original code did not determine the length value of the HCI command
for drop fw even there's no parameter needed. In this commit, use struct
hci_command_hdr to manage opcode and length. It would be more regular and
more readable.

Suggested-by: Alex Lu <alex_lu@realsil.com.cn>
Signed-off-by: Max Chou <max.chou@realtek.com>
---
 drivers/bluetooth/btrtl.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 9a6ae8a2adfc..04399b3c39a0 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -1044,12 +1044,11 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
 	struct btrtl_device_info *btrtl_dev;
 	struct sk_buff *skb;
 	struct hci_rp_read_local_version *resp;
+	struct hci_command_hdr *cmd;
 	char cfg_name[40];
 	u16 hci_rev, lmp_subver;
 	u8 hci_ver, lmp_ver, chip_type = 0;
 	int ret;
-	u16 opcode;
-	u8 cmd[2];
 	u8 reg_val[2];
 
 	btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL);
@@ -1118,15 +1117,14 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
 		btrtl_dev->drop_fw = false;
 
 	if (btrtl_dev->drop_fw) {
-		opcode = hci_opcode_pack(0x3f, 0x66);
-		cmd[0] = opcode & 0xff;
-		cmd[1] = opcode >> 8;
-
-		skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
+		skb = bt_skb_alloc(sizeof(*cmd), GFP_KERNEL);
 		if (!skb)
 			goto err_free;
 
-		skb_put_data(skb, cmd, sizeof(cmd));
+		cmd = skb_put(skb, HCI_COMMAND_HDR_SIZE);
+		cmd->opcode = cpu_to_le16(0xfc66);
+		cmd->plen = 0;
+
 		hci_skb_pkt_type(skb) = HCI_COMMAND_PKT;
 
 		ret = hdev->send(hdev, skb);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Bluetooth: btrtl: Correct the length of the HCI command for drop fw
  2023-05-30  8:34 [PATCH] Bluetooth: btrtl: Correct the length of the HCI command for drop fw max.chou
@ 2023-06-05 19:40 ` patchwork-bot+bluetooth
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2023-06-05 19:40 UTC (permalink / raw
  To: Max Chou
  Cc: marcel, johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel,
	alex_lu, hildawu

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 30 May 2023 16:34:20 +0800 you wrote:
> From: Max Chou <max.chou@realtek.com>
> 
> The original code did not determine the length value of the HCI command
> for drop fw even there's no parameter needed. In this commit, use struct
> hci_command_hdr to manage opcode and length. It would be more regular and
> more readable.
> 
> [...]

Here is the summary with links:
  - Bluetooth: btrtl: Correct the length of the HCI command for drop fw
    https://git.kernel.org/bluetooth/bluetooth-next/c/a332208e733b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-05 19:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30  8:34 [PATCH] Bluetooth: btrtl: Correct the length of the HCI command for drop fw max.chou
2023-06-05 19:40 ` patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).