drivers/bluetooth/hci_ll.c
Source file repositories/reference/linux-study-clean/drivers/bluetooth/hci_ll.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bluetooth/hci_ll.c- Extension
.c- Size
- 20102 bytes
- Lines
- 835
- Domain
- Driver Families
- Bucket
- drivers/bluetooth
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/kernel.hlinux/init.hlinux/sched.hlinux/types.hlinux/fcntl.hlinux/firmware.hlinux/interrupt.hlinux/ptrace.hlinux/poll.hlinux/slab.hlinux/errno.hlinux/string.hlinux/signal.hlinux/ioctl.hlinux/of.hlinux/serdev.hlinux/skbuff.hlinux/ti_wilink_st.hlinux/clk.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hlinux/gpio/consumer.hlinux/nvmem-consumer.hhci_uart.h
Detected Declarations
struct ll_devicestruct ll_structenum hcill_states_efunction send_hcill_cmdfunction ll_openfunction ll_flushfunction ll_closefunction __ll_do_awakefunction ll_device_want_to_wakeupfunction ll_device_want_to_sleepfunction ll_device_woke_upfunction ll_enqueuefunction ll_recv_framefunction ll_recvfunction read_local_versionfunction send_command_from_firmwarefunction download_firmwarefunction ll_set_bdaddrfunction ll_setupfunction hci_ti_probefunction hci_ti_removefunction ll_initfunction ll_deinit
Annotated Snippet
struct ll_device {
struct hci_uart hu;
struct serdev_device *serdev;
struct gpio_desc *enable_gpio;
struct clk *ext_clk;
bdaddr_t bdaddr;
bool broken_enhanced_setup;
};
struct ll_struct {
struct sk_buff *rx_skb;
struct sk_buff_head txq;
spinlock_t hcill_lock; /* HCILL state lock */
unsigned long hcill_state; /* HCILL power state */
struct sk_buff_head tx_wait_q; /* HCILL wait queue */
};
/*
* Builds and sends an HCILL command packet.
* These are very simple packets with only 1 cmd byte
*/
static int send_hcill_cmd(u8 cmd, struct hci_uart *hu)
{
int err = 0;
struct sk_buff *skb = NULL;
struct ll_struct *ll = hu->priv;
BT_DBG("hu %p cmd 0x%x", hu, cmd);
/* allocate packet */
skb = bt_skb_alloc(1, GFP_ATOMIC);
if (!skb) {
BT_ERR("cannot allocate memory for HCILL packet");
err = -ENOMEM;
goto out;
}
/* prepare packet */
skb_put_u8(skb, cmd);
/* send packet */
skb_queue_tail(&ll->txq, skb);
out:
return err;
}
/* Initialize protocol */
static int ll_open(struct hci_uart *hu)
{
struct ll_struct *ll;
BT_DBG("hu %p", hu);
ll = kzalloc_obj(*ll);
if (!ll)
return -ENOMEM;
skb_queue_head_init(&ll->txq);
skb_queue_head_init(&ll->tx_wait_q);
spin_lock_init(&ll->hcill_lock);
ll->hcill_state = HCILL_AWAKE;
hu->priv = ll;
if (hu->serdev) {
struct ll_device *lldev = serdev_device_get_drvdata(hu->serdev);
if (!IS_ERR(lldev->ext_clk))
clk_prepare_enable(lldev->ext_clk);
}
return 0;
}
/* Flush protocol data */
static int ll_flush(struct hci_uart *hu)
{
struct ll_struct *ll = hu->priv;
BT_DBG("hu %p", hu);
skb_queue_purge(&ll->tx_wait_q);
skb_queue_purge(&ll->txq);
return 0;
}
/* Close protocol */
static int ll_close(struct hci_uart *hu)
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/sched.h`, `linux/types.h`, `linux/fcntl.h`, `linux/firmware.h`, `linux/interrupt.h`.
- Detected declarations: `struct ll_device`, `struct ll_struct`, `enum hcill_states_e`, `function send_hcill_cmd`, `function ll_open`, `function ll_flush`, `function ll_close`, `function __ll_do_awake`, `function ll_device_want_to_wakeup`, `function ll_device_want_to_sleep`.
- Atlas domain: Driver Families / drivers/bluetooth.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.