drivers/bluetooth/hci_vhci.c
Source file repositories/reference/linux-study-clean/drivers/bluetooth/hci_vhci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bluetooth/hci_vhci.c- Extension
.c- Size
- 15453 bytes
- Lines
- 736
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/unaligned.hlinux/atomic.hlinux/kernel.hlinux/init.hlinux/slab.hlinux/types.hlinux/errno.hlinux/sched.hlinux/poll.hlinux/skbuff.hlinux/miscdevice.hlinux/debugfs.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.h
Detected Declarations
struct vhci_datastruct devcoredump_test_datafunction vhci_open_devfunction vhci_close_devfunction vhci_flushfunction vhci_send_framefunction vhci_get_data_path_idfunction vhci_get_codec_config_datafunction vhci_wakeupfunction force_suspend_readfunction vhci_suspend_workfunction force_suspend_writefunction force_wakeup_readfunction force_wakeup_writefunction msft_opcode_setfunction msft_opcode_getfunction aosp_capable_readfunction aosp_capable_writefunction vhci_setupfunction vhci_coredumpfunction force_devcd_timeoutfunction force_devcd_writefunction vhci_debugfs_initfunction __vhci_create_devicefunction vhci_create_devicefunction vhci_get_userfunction vhci_put_userfunction vhci_readfunction vhci_writefunction vhci_pollfunction vhci_open_timeoutfunction vhci_openfunction vhci_debugfs_removefunction vhci_release
Annotated Snippet
static const struct file_operations force_suspend_fops = {
.open = simple_open,
.read = force_suspend_read,
.write = force_suspend_write,
.llseek = default_llseek,
};
static ssize_t force_wakeup_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct vhci_data *data = file->private_data;
char buf[3];
buf[0] = data->wakeup ? 'Y' : 'N';
buf[1] = '\n';
buf[2] = '\0';
return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
}
static ssize_t force_wakeup_write(struct file *file,
const char __user *user_buf, size_t count,
loff_t *ppos)
{
struct vhci_data *data = file->private_data;
bool enable;
int err;
err = kstrtobool_from_user(user_buf, count, &enable);
if (err)
return err;
if (data->wakeup == enable)
return -EALREADY;
data->wakeup = enable;
return count;
}
static const struct file_operations force_wakeup_fops = {
.open = simple_open,
.read = force_wakeup_read,
.write = force_wakeup_write,
.llseek = default_llseek,
};
static int msft_opcode_set(void *data, u64 val)
{
struct vhci_data *vhci = data;
if (val > 0xffff || hci_opcode_ogf(val) != 0x3f)
return -EINVAL;
if (vhci->msft_opcode)
return -EALREADY;
vhci->msft_opcode = val;
return 0;
}
static int msft_opcode_get(void *data, u64 *val)
{
struct vhci_data *vhci = data;
*val = vhci->msft_opcode;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(msft_opcode_fops, msft_opcode_get, msft_opcode_set,
"%llu\n");
static ssize_t aosp_capable_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct vhci_data *vhci = file->private_data;
char buf[3];
buf[0] = vhci->aosp_capable ? 'Y' : 'N';
buf[1] = '\n';
buf[2] = '\0';
return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
}
static ssize_t aosp_capable_write(struct file *file,
const char __user *user_buf, size_t count,
loff_t *ppos)
{
struct vhci_data *vhci = file->private_data;
Annotation
- Immediate include surface: `linux/module.h`, `linux/unaligned.h`, `linux/atomic.h`, `linux/kernel.h`, `linux/init.h`, `linux/slab.h`, `linux/types.h`, `linux/errno.h`.
- Detected declarations: `struct vhci_data`, `struct devcoredump_test_data`, `function vhci_open_dev`, `function vhci_close_dev`, `function vhci_flush`, `function vhci_send_frame`, `function vhci_get_data_path_id`, `function vhci_get_codec_config_data`, `function vhci_wakeup`, `function force_suspend_read`.
- Atlas domain: Driver Families / drivers/bluetooth.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.