net/bluetooth/hci_codec.c
Source file repositories/reference/linux-study-clean/net/bluetooth/hci_codec.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/hci_codec.c- Extension
.c- Size
- 5983 bytes
- Lines
- 254
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/bluetooth/bluetooth.hnet/bluetooth/hci_core.hhci_codec.h
Detected Declarations
function hci_codec_list_addfunction hci_codec_list_clearfunction list_for_each_entry_safefunction hci_read_codec_capabilitiesfunction hci_read_supported_codecsfunction hci_read_supported_codecs_v2
Annotated Snippet
if (transport & BIT(i)) {
struct hci_rp_read_local_codec_caps *rp;
struct hci_codec_caps *caps;
struct sk_buff *skb;
__u8 j;
__u32 len;
cmd->transport = i;
/* If Read_Codec_Capabilities command is not supported
* then just add codec to the list without caps
*/
if (!(hdev->commands[45] & 0x08)) {
hci_dev_lock(hdev);
hci_codec_list_add(&hdev->local_codecs, cmd,
NULL, NULL, 0);
hci_dev_unlock(hdev);
continue;
}
skb = __hci_cmd_sync_sk(hdev, HCI_OP_READ_LOCAL_CODEC_CAPS,
sizeof(*cmd), cmd, 0, HCI_CMD_TIMEOUT, NULL);
if (IS_ERR(skb)) {
bt_dev_err(hdev, "Failed to read codec capabilities (%ld)",
PTR_ERR(skb));
continue;
}
if (skb->len < sizeof(*rp))
goto error;
rp = (void *)skb->data;
if (rp->status)
goto error;
if (!rp->num_caps) {
len = 0;
/* this codec doesn't have capabilities */
goto skip_caps_parse;
}
skb_pull(skb, sizeof(*rp));
for (j = 0, len = 0; j < rp->num_caps; j++) {
caps = (void *)skb->data;
if (skb->len < sizeof(*caps))
goto error;
if (skb->len < sizeof(caps->len) + caps->len)
goto error;
len += sizeof(caps->len) + caps->len;
skb_pull(skb, sizeof(caps->len) + caps->len);
}
skip_caps_parse:
hci_dev_lock(hdev);
hci_codec_list_add(&hdev->local_codecs, cmd, rp,
(__u8 *)rp + sizeof(*rp), len);
hci_dev_unlock(hdev);
error:
kfree_skb(skb);
}
}
}
void hci_read_supported_codecs(struct hci_dev *hdev)
{
struct sk_buff *skb;
struct hci_rp_read_local_supported_codecs *rp;
struct hci_std_codecs *std_codecs;
struct hci_vnd_codecs *vnd_codecs;
struct hci_op_read_local_codec_caps caps;
__u8 i;
skb = __hci_cmd_sync_sk(hdev, HCI_OP_READ_LOCAL_CODECS, 0, NULL,
0, HCI_CMD_TIMEOUT, NULL);
if (IS_ERR(skb)) {
bt_dev_err(hdev, "Failed to read local supported codecs (%ld)",
PTR_ERR(skb));
return;
}
if (skb->len < sizeof(*rp))
goto error;
rp = (void *)skb->data;
if (rp->status)
goto error;
Annotation
- Immediate include surface: `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`, `hci_codec.h`.
- Detected declarations: `function hci_codec_list_add`, `function hci_codec_list_clear`, `function list_for_each_entry_safe`, `function hci_read_codec_capabilities`, `function hci_read_supported_codecs`, `function hci_read_supported_codecs_v2`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.