drivers/hid/uhid.c
Source file repositories/reference/linux-study-clean/drivers/hid/uhid.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/uhid.c- Extension
.c- Size
- 19434 bytes
- Lines
- 820
- Domain
- Driver Families
- Bucket
- drivers/hid
- 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/atomic.hlinux/compat.hlinux/cred.hlinux/device.hlinux/fs.hlinux/hid.hlinux/input.hlinux/miscdevice.hlinux/module.hlinux/mutex.hlinux/poll.hlinux/sched.hlinux/spinlock.hlinux/uhid.hlinux/wait.h
Detected Declarations
struct uhid_devicestruct uhid_create_req_compatfunction uhid_device_add_workerfunction uhid_queuefunction uhid_queue_eventfunction uhid_hid_startfunction uhid_hid_stopfunction uhid_hid_openfunction uhid_hid_closefunction uhid_hid_parsefunction __uhid_report_queue_and_waitfunction uhid_report_wake_upfunction uhid_hid_get_reportfunction uhid_hid_set_reportfunction uhid_hid_raw_requestfunction uhid_hid_output_rawfunction uhid_hid_output_reportfunction uhid_event_from_userfunction uhid_event_from_userfunction uhid_dev_create2function uhid_dev_createfunction uhid_dev_destroyfunction uhid_dev_inputfunction uhid_dev_input2function uhid_dev_get_report_replyfunction uhid_dev_set_report_replyfunction uhid_char_openfunction uhid_char_releasefunction uhid_char_readfunction uhid_char_writefunction uhid_char_poll
Annotated Snippet
static const struct file_operations uhid_fops = {
.owner = THIS_MODULE,
.open = uhid_char_open,
.release = uhid_char_release,
.read = uhid_char_read,
.write = uhid_char_write,
.poll = uhid_char_poll,
};
static struct miscdevice uhid_misc = {
.fops = &uhid_fops,
.minor = UHID_MINOR,
.name = UHID_NAME,
};
module_misc_device(uhid_misc);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>");
MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem");
MODULE_ALIAS_MISCDEV(UHID_MINOR);
MODULE_ALIAS("devname:" UHID_NAME);
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/compat.h`, `linux/cred.h`, `linux/device.h`, `linux/fs.h`, `linux/hid.h`, `linux/input.h`, `linux/miscdevice.h`.
- Detected declarations: `struct uhid_device`, `struct uhid_create_req_compat`, `function uhid_device_add_worker`, `function uhid_queue`, `function uhid_queue_event`, `function uhid_hid_start`, `function uhid_hid_stop`, `function uhid_hid_open`, `function uhid_hid_close`, `function uhid_hid_parse`.
- Atlas domain: Driver Families / drivers/hid.
- 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.