drivers/hid/hid-roccat.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-roccat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-roccat.c- Extension
.c- Size
- 10787 bytes
- Lines
- 464
- 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/cdev.hlinux/poll.hlinux/sched/signal.hlinux/hid-roccat.hlinux/module.h
Detected Declarations
struct roccat_reportstruct roccat_devicestruct roccat_readerfunction roccat_readfunction roccat_pollfunction roccat_openfunction roccat_releasefunction roccat_report_eventfunction list_for_each_entryfunction roccat_connectfunction roccat_disconnectfunction roccat_ioctlfunction roccat_initfunction roccat_exitmodule init roccat_initexport roccat_report_eventexport roccat_connectexport roccat_disconnect
Annotated Snippet
static const struct file_operations roccat_ops = {
.owner = THIS_MODULE,
.read = roccat_read,
.poll = roccat_poll,
.open = roccat_open,
.release = roccat_release,
.llseek = noop_llseek,
.unlocked_ioctl = roccat_ioctl,
};
static int __init roccat_init(void)
{
int retval;
dev_t dev_id;
retval = alloc_chrdev_region(&dev_id, ROCCAT_FIRST_MINOR,
ROCCAT_MAX_DEVICES, "roccat");
if (retval < 0) {
pr_warn("can't get major number\n");
goto error;
}
roccat_major = MAJOR(dev_id);
cdev_init(&roccat_cdev, &roccat_ops);
retval = cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES);
if (retval < 0) {
pr_warn("cannot add cdev\n");
goto cleanup_alloc_chrdev_region;
}
return 0;
cleanup_alloc_chrdev_region:
unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES);
error:
return retval;
}
static void __exit roccat_exit(void)
{
dev_t dev_id = MKDEV(roccat_major, 0);
cdev_del(&roccat_cdev);
unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES);
}
module_init(roccat_init);
module_exit(roccat_exit);
MODULE_AUTHOR("Stefan Achatz");
MODULE_DESCRIPTION("USB Roccat char device");
MODULE_LICENSE("GPL v2");
Annotation
- Immediate include surface: `linux/cdev.h`, `linux/poll.h`, `linux/sched/signal.h`, `linux/hid-roccat.h`, `linux/module.h`.
- Detected declarations: `struct roccat_report`, `struct roccat_device`, `struct roccat_reader`, `function roccat_read`, `function roccat_poll`, `function roccat_open`, `function roccat_release`, `function roccat_report_event`, `function list_for_each_entry`, `function roccat_connect`.
- 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.