drivers/scsi/ch.c

Source file repositories/reference/linux-study-clean/drivers/scsi/ch.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/ch.c
Extension
.c
Size
25534 bytes
Lines
1038
Domain
Driver Families
Bucket
drivers/scsi
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 changer_fops = {
	.owner		= THIS_MODULE,
	.open		= ch_open,
	.release	= ch_release,
	.unlocked_ioctl	= ch_ioctl,
	.compat_ioctl	= compat_ptr_ioctl,
	.llseek		= noop_llseek,
};

static int __init init_ch_module(void)
{
	int rc;

	printk(KERN_INFO "SCSI Media Changer driver v" VERSION " \n");
	rc = class_register(&ch_sysfs_class);
	if (rc)
		return rc;
	rc = register_chrdev(SCSI_CHANGER_MAJOR,"ch",&changer_fops);
	if (rc < 0) {
		printk("Unable to get major %d for SCSI-Changer\n",
		       SCSI_CHANGER_MAJOR);
		goto fail1;
	}
	rc = scsi_register_driver(&ch_template);
	if (rc < 0)
		goto fail2;
	return 0;

 fail2:
	unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
 fail1:
	class_unregister(&ch_sysfs_class);
	return rc;
}

static void __exit exit_ch_module(void)
{
	scsi_unregister_driver(&ch_template);
	unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
	class_unregister(&ch_sysfs_class);
	idr_destroy(&ch_index_idr);
}

module_init(init_ch_module);
module_exit(exit_ch_module);

Annotation

Implementation Notes