drivers/bluetooth/btusb.c
Source file repositories/reference/linux-study-clean/drivers/bluetooth/btusb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bluetooth/btusb.c- Extension
.c- Size
- 136256 bytes
- Lines
- 4730
- Domain
- Driver Families
- Bucket
- drivers/bluetooth
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
linux/dmi.hlinux/module.hlinux/usb.hlinux/usb/quirks.hlinux/firmware.hlinux/iopoll.hlinux/of_device.hlinux/of_irq.hlinux/suspend.hlinux/gpio/consumer.hlinux/debugfs.hlinux/unaligned.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hnet/bluetooth/hci_drv.hbtintel.hbtbcm.hbtrtl.hbtmtk.h
Detected Declarations
struct qca_dump_infostruct btusb_datastruct rtk_dev_coredump_hdrstruct qca_dump_hdrstruct qca_versionstruct qca_rampatch_versionstruct qca_device_infostruct qca_custom_firmwarestruct btusb_hci_drv_rp_supported_altsettingsstruct btusb_hci_drv_cmd_switch_altsettingfunction btusb_resetfunction btusb_intel_resetfunction btusb_rtl_alloc_devcoredumpfunction btusb_rtl_resetfunction outfunction btusb_rtl_hw_errorfunction btusb_qca_resetfunction outfunction btusb_classify_qca_pkt_typefunction btusb_free_fragsfunction btusb_recv_eventfunction btusb_recv_intrfunction btusb_recv_aclfunction btusb_recv_bulkfunction btusb_validate_sco_handlefunction btusb_recv_isocfunction btusb_intr_completefunction btusb_submit_intr_urbfunction microframesfunction btusb_bulk_completefunction btusb_submit_bulk_urbfunction btusb_isoc_completefunction __fill_isoc_descriptor_msbcfunction __fill_isoc_descriptorfunction btusb_submit_isoc_urbfunction btusb_diag_completefunction btusb_submit_diag_urbfunction btusb_tx_completefunction btusb_isoc_tx_completefunction btusb_openfunction btusb_stop_trafficfunction btusb_closefunction btusb_flushfunction submit_tx_urbfunction submit_or_queue_tx_urbfunction btusb_send_framefunction btusb_notifyfunction __set_isoc_interface
Annotated Snippet
static const struct file_operations force_poll_sync_fops = {
.owner = THIS_MODULE,
.open = simple_open,
.read = force_poll_sync_read,
.write = force_poll_sync_write,
.llseek = default_llseek,
};
#define BTUSB_HCI_DRV_OP_SUPPORTED_ALTSETTINGS \
hci_opcode_pack(HCI_DRV_OGF_DRIVER_SPECIFIC, 0x0000)
#define BTUSB_HCI_DRV_SUPPORTED_ALTSETTINGS_SIZE 0
struct btusb_hci_drv_rp_supported_altsettings {
__u8 num;
__u8 altsettings[];
} __packed;
#define BTUSB_HCI_DRV_OP_SWITCH_ALTSETTING \
hci_opcode_pack(HCI_DRV_OGF_DRIVER_SPECIFIC, 0x0001)
#define BTUSB_HCI_DRV_SWITCH_ALTSETTING_SIZE 1
struct btusb_hci_drv_cmd_switch_altsetting {
__u8 altsetting;
} __packed;
static const struct {
u16 opcode;
const char *desc;
} btusb_hci_drv_supported_commands[] = {
/* Common commands */
{ HCI_DRV_OP_READ_INFO, "Read Info" },
/* Driver specific commands */
{ BTUSB_HCI_DRV_OP_SUPPORTED_ALTSETTINGS, "Supported Altsettings" },
{ BTUSB_HCI_DRV_OP_SWITCH_ALTSETTING, "Switch Altsetting" },
};
static int btusb_hci_drv_read_info(struct hci_dev *hdev, void *data,
u16 data_len)
{
struct hci_drv_rp_read_info *rp;
size_t rp_size;
int err, i;
u16 opcode, num_supported_commands =
ARRAY_SIZE(btusb_hci_drv_supported_commands);
rp_size = sizeof(*rp) + num_supported_commands * 2;
rp = kmalloc(rp_size, GFP_KERNEL);
if (!rp)
return -ENOMEM;
strscpy_pad(rp->driver_name, btusb_driver.name);
rp->num_supported_commands = cpu_to_le16(num_supported_commands);
for (i = 0; i < num_supported_commands; i++) {
opcode = btusb_hci_drv_supported_commands[i].opcode;
bt_dev_info(hdev,
"Supported HCI Drv command (0x%02x|0x%04x): %s",
hci_opcode_ogf(opcode),
hci_opcode_ocf(opcode),
btusb_hci_drv_supported_commands[i].desc);
rp->supported_commands[i] = cpu_to_le16(opcode);
}
err = hci_drv_cmd_complete(hdev, HCI_DRV_OP_READ_INFO,
HCI_DRV_STATUS_SUCCESS, rp, rp_size);
kfree(rp);
return err;
}
static int btusb_hci_drv_supported_altsettings(struct hci_dev *hdev, void *data,
u16 data_len)
{
struct btusb_data *drvdata = hci_get_drvdata(hdev);
struct btusb_hci_drv_rp_supported_altsettings *rp;
size_t rp_size;
int err;
u8 i;
/* There are at most 7 alt (0 - 6) */
rp = kmalloc(sizeof(*rp) + 7, GFP_KERNEL);
if (!rp)
return -ENOMEM;
rp->num = 0;
if (!drvdata->isoc)
goto done;
for (i = 0; i <= 6; i++) {
if (btusb_find_altsetting(drvdata, i))
rp->altsettings[rp->num++] = i;
Annotation
- Immediate include surface: `linux/dmi.h`, `linux/module.h`, `linux/usb.h`, `linux/usb/quirks.h`, `linux/firmware.h`, `linux/iopoll.h`, `linux/of_device.h`, `linux/of_irq.h`.
- Detected declarations: `struct qca_dump_info`, `struct btusb_data`, `struct rtk_dev_coredump_hdr`, `struct qca_dump_hdr`, `struct qca_version`, `struct qca_rampatch_version`, `struct qca_device_info`, `struct qca_custom_firmware`, `struct btusb_hci_drv_rp_supported_altsettings`, `struct btusb_hci_drv_cmd_switch_altsetting`.
- Atlas domain: Driver Families / drivers/bluetooth.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.