drivers/bluetooth/bfusb.c
Source file repositories/reference/linux-study-clean/drivers/bluetooth/bfusb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bluetooth/bfusb.c- Extension
.c- Size
- 15274 bytes
- Lines
- 725
- 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/slab.hlinux/types.hlinux/errno.hlinux/skbuff.hlinux/device.hlinux/firmware.hlinux/usb.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.h
Detected Declarations
struct bfusb_datastruct bfusb_data_scbfunction bfusb_unlink_urbsfunction bfusb_send_bulkfunction bfusb_tx_wakeupfunction bfusb_tx_completefunction bfusb_rx_submitfunction bfusb_recv_blockfunction bfusb_rx_completefunction bfusb_openfunction bfusb_flushfunction bfusb_closefunction bfusb_send_framefunction bfusb_load_firmwarefunction bfusb_probefunction bfusb_disconnect
Annotated Snippet
struct bfusb_data {
struct hci_dev *hdev;
unsigned long state;
struct usb_device *udev;
unsigned int bulk_in_ep;
unsigned int bulk_out_ep;
unsigned int bulk_pkt_size;
rwlock_t lock;
struct sk_buff_head transmit_q;
struct sk_buff *reassembly;
atomic_t pending_tx;
struct sk_buff_head pending_q;
struct sk_buff_head completed_q;
};
struct bfusb_data_scb {
struct urb *urb;
};
static void bfusb_tx_complete(struct urb *urb);
static void bfusb_rx_complete(struct urb *urb);
static struct urb *bfusb_get_completed(struct bfusb_data *data)
{
struct sk_buff *skb;
struct urb *urb = NULL;
BT_DBG("bfusb %p", data);
skb = skb_dequeue(&data->completed_q);
if (skb) {
urb = ((struct bfusb_data_scb *) skb->cb)->urb;
kfree_skb(skb);
}
return urb;
}
static void bfusb_unlink_urbs(struct bfusb_data *data)
{
struct sk_buff *skb;
struct urb *urb;
BT_DBG("bfusb %p", data);
while ((skb = skb_dequeue(&data->pending_q))) {
urb = ((struct bfusb_data_scb *) skb->cb)->urb;
usb_kill_urb(urb);
skb_queue_tail(&data->completed_q, skb);
}
while ((urb = bfusb_get_completed(data)))
usb_free_urb(urb);
}
static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
{
struct bfusb_data_scb *scb = (void *) skb->cb;
struct urb *urb = bfusb_get_completed(data);
int err, pipe;
BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len);
if (!urb) {
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb)
return -ENOMEM;
}
pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep);
usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, skb->len,
bfusb_tx_complete, skb);
scb->urb = urb;
skb_queue_tail(&data->pending_q, skb);
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err) {
bt_dev_err(data->hdev, "bulk tx submit failed urb %p err %d",
urb, err);
skb_unlink(skb, &data->pending_q);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/slab.h`, `linux/types.h`, `linux/errno.h`, `linux/skbuff.h`, `linux/device.h`.
- Detected declarations: `struct bfusb_data`, `struct bfusb_data_scb`, `function bfusb_unlink_urbs`, `function bfusb_send_bulk`, `function bfusb_tx_wakeup`, `function bfusb_tx_complete`, `function bfusb_rx_submit`, `function bfusb_recv_block`, `function bfusb_rx_complete`, `function bfusb_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.