drivers/block/z2ram.c
Source file repositories/reference/linux-study-clean/drivers/block/z2ram.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/block/z2ram.c- Extension
.c- Size
- 9352 bytes
- Lines
- 412
- Domain
- Driver Families
- Bucket
- drivers/block
- 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.
- 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/major.hlinux/vmalloc.hlinux/init.hlinux/module.hlinux/blk-mq.hlinux/bitops.hlinux/mutex.hlinux/slab.hlinux/pgtable.hasm/setup.hasm/amigahw.hlinux/zorro.h
Detected Declarations
function z2_queue_rqfunction get_z2ramfunction get_chipramfunction z2_openfunction z2_releasefunction z2ram_register_diskfunction z2_initfunction z2_exitmodule init z2_init
Annotated Snippet
static const struct blk_mq_ops z2_mq_ops = {
.queue_rq = z2_queue_rq,
};
static int z2ram_register_disk(int minor)
{
struct gendisk *disk;
int err;
disk = blk_mq_alloc_disk(&tag_set, NULL, NULL);
if (IS_ERR(disk))
return PTR_ERR(disk);
disk->major = Z2RAM_MAJOR;
disk->first_minor = minor;
disk->minors = 1;
disk->flags |= GENHD_FL_NO_PART;
disk->fops = &z2_fops;
if (minor)
sprintf(disk->disk_name, "z2ram%d", minor);
else
sprintf(disk->disk_name, "z2ram");
z2ram_gendisk[minor] = disk;
err = add_disk(disk);
if (err)
put_disk(disk);
return err;
}
static int __init z2_init(void)
{
int ret, i;
if (!MACH_IS_AMIGA)
return -ENODEV;
if (register_blkdev(Z2RAM_MAJOR, DEVICE_NAME))
return -EBUSY;
tag_set.ops = &z2_mq_ops;
tag_set.nr_hw_queues = 1;
tag_set.nr_maps = 1;
tag_set.queue_depth = 16;
tag_set.numa_node = NUMA_NO_NODE;
ret = blk_mq_alloc_tag_set(&tag_set);
if (ret)
goto out_unregister_blkdev;
for (i = 0; i < Z2MINOR_COUNT; i++) {
ret = z2ram_register_disk(i);
if (ret && i == 0)
goto out_free_tagset;
}
return 0;
out_free_tagset:
blk_mq_free_tag_set(&tag_set);
out_unregister_blkdev:
unregister_blkdev(Z2RAM_MAJOR, DEVICE_NAME);
return ret;
}
static void __exit z2_exit(void)
{
int i, j;
unregister_blkdev(Z2RAM_MAJOR, DEVICE_NAME);
for (i = 0; i < Z2MINOR_COUNT; i++) {
del_gendisk(z2ram_gendisk[i]);
put_disk(z2ram_gendisk[i]);
}
blk_mq_free_tag_set(&tag_set);
if (current_device != -1) {
i = 0;
for (j = 0; j < z2_count; j++) {
set_bit(i++, zorro_unused_z2ram);
}
for (j = 0; j < chip_count; j++) {
if (z2ram_map[i]) {
amiga_chip_free((void *)z2ram_map[i++]);
}
}
if (z2ram_map != NULL) {
Annotation
- Immediate include surface: `linux/major.h`, `linux/vmalloc.h`, `linux/init.h`, `linux/module.h`, `linux/blk-mq.h`, `linux/bitops.h`, `linux/mutex.h`, `linux/slab.h`.
- Detected declarations: `function z2_queue_rq`, `function get_z2ram`, `function get_chipram`, `function z2_open`, `function z2_release`, `function z2ram_register_disk`, `function z2_init`, `function z2_exit`, `module init z2_init`.
- Atlas domain: Driver Families / drivers/block.
- Implementation status: pattern implementation candidate.
- 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.