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.

Dependency Surface

Detected Declarations

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

Implementation Notes