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.
- 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/init.hlinux/fs.hlinux/kernel.hlinux/mm.hlinux/major.hlinux/string.hlinux/errno.hlinux/interrupt.hlinux/blkdev.hlinux/completion.hlinux/compat.hlinux/chio.hlinux/mutex.hlinux/idr.hlinux/slab.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_driver.hscsi/scsi_ioctl.hscsi/scsi_host.hscsi/scsi_device.hscsi/scsi_eh.hscsi/scsi_dbg.h
Detected Declarations
struct changer_element_status32function ch_find_errnofunction ch_do_scsifunction ch_elem_to_typecodefunction ch_read_element_statusfunction ch_init_elemfunction ch_readconfigfunction ch_positionfunction ch_movefunction ch_exchangefunction ch_check_voltagfunction ch_set_voltagfunction ch_gstatusfunction ch_destroyfunction ch_releasefunction ch_openfunction ch_checkrangefunction ch_ioctlfunction ch_probefunction ch_removefunction init_ch_modulefunction exit_ch_modulemodule init init_ch_module
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
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/fs.h`, `linux/kernel.h`, `linux/mm.h`, `linux/major.h`, `linux/string.h`, `linux/errno.h`.
- Detected declarations: `struct changer_element_status32`, `function ch_find_errno`, `function ch_do_scsi`, `function ch_elem_to_typecode`, `function ch_read_element_status`, `function ch_init_elem`, `function ch_readconfig`, `function ch_position`, `function ch_move`, `function ch_exchange`.
- Atlas domain: Driver Families / drivers/scsi.
- 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.