Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Fix support for Read Local Supported Codecs V2

Handling of Read Local Supported Codecs was broken during the
HCI serialization design change patches.

Fixes: d0b137062b2d ("Bluetooth: hci_sync: Rework init stages")
Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Chethan T N and committed by
Luiz Augusto von Dentz
828cea2b 93df7d56

+16 -13
+10 -9
net/bluetooth/hci_codec.c
··· 72 72 continue; 73 73 } 74 74 75 - skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_CODEC_CAPS, 76 - sizeof(*cmd), cmd, 77 - HCI_CMD_TIMEOUT); 75 + skb = __hci_cmd_sync_sk(hdev, HCI_OP_READ_LOCAL_CODEC_CAPS, 76 + sizeof(*cmd), cmd, 0, HCI_CMD_TIMEOUT, NULL); 78 77 if (IS_ERR(skb)) { 79 78 bt_dev_err(hdev, "Failed to read codec capabilities (%ld)", 80 79 PTR_ERR(skb)); ··· 126 127 struct hci_op_read_local_codec_caps caps; 127 128 __u8 i; 128 129 129 - skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_CODECS, 0, NULL, 130 - HCI_CMD_TIMEOUT); 130 + skb = __hci_cmd_sync_sk(hdev, HCI_OP_READ_LOCAL_CODECS, 0, NULL, 131 + 0, HCI_CMD_TIMEOUT, NULL); 131 132 132 133 if (IS_ERR(skb)) { 133 134 bt_dev_err(hdev, "Failed to read local supported codecs (%ld)", ··· 157 158 for (i = 0; i < std_codecs->num; i++) { 158 159 caps.id = std_codecs->codec[i]; 159 160 caps.direction = 0x00; 160 - hci_read_codec_capabilities(hdev, LOCAL_CODEC_ACL_MASK, &caps); 161 + hci_read_codec_capabilities(hdev, 162 + LOCAL_CODEC_ACL_MASK | LOCAL_CODEC_SCO_MASK, &caps); 161 163 } 162 164 163 165 skb_pull(skb, flex_array_size(std_codecs, codec, std_codecs->num) ··· 178 178 caps.cid = vnd_codecs->codec[i].cid; 179 179 caps.vid = vnd_codecs->codec[i].vid; 180 180 caps.direction = 0x00; 181 - hci_read_codec_capabilities(hdev, LOCAL_CODEC_ACL_MASK, &caps); 181 + hci_read_codec_capabilities(hdev, 182 + LOCAL_CODEC_ACL_MASK | LOCAL_CODEC_SCO_MASK, &caps); 182 183 } 183 184 184 185 error: ··· 195 194 struct hci_op_read_local_codec_caps caps; 196 195 __u8 i; 197 196 198 - skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_CODECS_V2, 0, NULL, 199 - HCI_CMD_TIMEOUT); 197 + skb = __hci_cmd_sync_sk(hdev, HCI_OP_READ_LOCAL_CODECS_V2, 0, NULL, 198 + 0, HCI_CMD_TIMEOUT, NULL); 200 199 201 200 if (IS_ERR(skb)) { 202 201 bt_dev_err(hdev, "Failed to read local supported codecs (%ld)",
+6 -4
net/bluetooth/hci_sync.c
··· 12 12 #include <net/bluetooth/mgmt.h> 13 13 14 14 #include "hci_request.h" 15 + #include "hci_codec.h" 15 16 #include "hci_debugfs.h" 16 17 #include "smp.h" 17 18 #include "eir.h" ··· 4240 4239 /* Read local codec list if the HCI command is supported */ 4241 4240 static int hci_read_local_codecs_sync(struct hci_dev *hdev) 4242 4241 { 4243 - if (!(hdev->commands[29] & 0x20)) 4244 - return 0; 4242 + if (hdev->commands[45] & 0x04) 4243 + hci_read_supported_codecs_v2(hdev); 4244 + else if (hdev->commands[29] & 0x20) 4245 + hci_read_supported_codecs(hdev); 4245 4246 4246 - return __hci_cmd_sync_status(hdev, HCI_OP_READ_LOCAL_CODECS, 0, NULL, 4247 - HCI_CMD_TIMEOUT); 4247 + return 0; 4248 4248 } 4249 4249 4250 4250 /* Read local pairing options if the HCI command is supported */