drivers/bluetooth/hci_h5.c
Source file repositories/reference/linux-study-clean/drivers/bluetooth/hci_h5.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bluetooth/hci_h5.c- Extension
.c- Size
- 27199 bytes
- Lines
- 1178
- 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/acpi.hlinux/bitrev.hlinux/crc-ccitt.hlinux/errno.hlinux/gpio/consumer.hlinux/kernel.hlinux/mod_devicetable.hlinux/of.hlinux/pm_runtime.hlinux/serdev.hlinux/skbuff.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hbtrtl.hhci_uart.h
Detected Declarations
struct h5struct h5_vndstruct h5_device_datastruct h5_btrtl_reprobeenum h5_driver_infofunction h5_link_controlfunction h5_cfg_fieldfunction h5_timed_eventfunction h5_peer_resetfunction h5_openfunction h5_closefunction h5_setupfunction h5_pkt_cullfunction h5_handle_internal_rxfunction h5_complete_rx_pktfunction h5_rx_crcfunction h5_rx_payloadfunction h5_rx_3wire_hdrfunction h5_rx_pkt_startfunction h5_rx_delimiterfunction h5_unslip_one_bytefunction h5_reset_rxfunction h5_recvfunction h5_enqueuefunction h5_slip_delimfunction h5_slip_one_bytefunction valid_packet_typefunction h5_flushfunction h5_serdev_probefunction h5_serdev_removefunction h5_serdev_suspendfunction h5_serdev_resumefunction h5_btrtl_setupfunction h5_btrtl_openfunction h5_btrtl_closefunction h5_btrtl_suspendfunction h5_btrtl_reprobe_workerfunction h5_btrtl_resumefunction h5_initfunction h5_deinit
Annotated Snippet
struct h5 {
/* Must be the first member, hci_serdev.c expects this. */
struct hci_uart serdev_hu;
struct sk_buff_head unack; /* Unack'ed packets queue */
struct sk_buff_head rel; /* Reliable packets queue */
struct sk_buff_head unrel; /* Unreliable packets queue */
unsigned long flags;
struct sk_buff *rx_skb; /* Receive buffer */
size_t rx_pending; /* Expecting more bytes */
u8 rx_ack; /* Last ack number received */
int (*rx_func)(struct hci_uart *hu, u8 c);
struct timer_list timer; /* Retransmission timer */
struct hci_uart *hu; /* Parent HCI UART */
u8 tx_seq; /* Next seq number to send */
u8 tx_ack; /* Next ack number to send */
u8 tx_win; /* Sliding window size */
enum {
H5_UNINITIALIZED,
H5_INITIALIZED,
H5_ACTIVE,
} state;
enum {
H5_AWAKE,
H5_SLEEPING,
H5_WAKING_UP,
} sleep;
const struct h5_vnd *vnd;
const char *id;
struct gpio_desc *enable_gpio;
struct gpio_desc *device_wake_gpio;
};
enum h5_driver_info {
H5_INFO_WAKEUP_DISABLE = BIT(0),
};
struct h5_vnd {
int (*setup)(struct h5 *h5);
void (*open)(struct h5 *h5);
void (*close)(struct h5 *h5);
int (*suspend)(struct h5 *h5);
int (*resume)(struct h5 *h5);
const struct acpi_gpio_mapping *acpi_gpio_map;
int sizeof_priv;
};
struct h5_device_data {
uint32_t driver_info;
struct h5_vnd *vnd;
};
static void h5_reset_rx(struct h5 *h5);
static void h5_link_control(struct hci_uart *hu, const void *data, size_t len)
{
struct h5 *h5 = hu->priv;
struct sk_buff *nskb;
nskb = alloc_skb(3, GFP_ATOMIC);
if (!nskb)
return;
hci_skb_pkt_type(nskb) = HCI_3WIRE_LINK_PKT;
skb_put_data(nskb, data, len);
skb_queue_tail(&h5->unrel, nskb);
}
static u8 h5_cfg_field(struct h5 *h5)
{
/* Sliding window size (first 3 bits) and CRC request (fifth bit). */
return (h5->tx_win & 0x07) | 0x10;
}
static void h5_timed_event(struct timer_list *t)
{
const unsigned char sync_req[] = { 0x01, 0x7e };
unsigned char conf_req[3] = { 0x03, 0xfc };
struct h5 *h5 = timer_container_of(h5, t, timer);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitrev.h`, `linux/crc-ccitt.h`, `linux/errno.h`, `linux/gpio/consumer.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/of.h`.
- Detected declarations: `struct h5`, `struct h5_vnd`, `struct h5_device_data`, `struct h5_btrtl_reprobe`, `enum h5_driver_info`, `function h5_link_control`, `function h5_cfg_field`, `function h5_timed_event`, `function h5_peer_reset`, `function h5_open`.
- 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.