drivers/mtd/nand/raw/nandsim.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/nandsim.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/nandsim.c- Extension
.c- Size
- 68585 bytes
- Lines
- 2460
- Domain
- Driver Families
- Bucket
- drivers/mtd
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/init.hlinux/types.hlinux/module.hlinux/moduleparam.hlinux/vmalloc.hlinux/math64.hlinux/slab.hlinux/errno.hlinux/string.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/mtd/partitions.hlinux/delay.hlinux/list.hlinux/random.hlinux/sched.hlinux/sched/mm.hlinux/fs.hlinux/pagemap.hlinux/seq_file.hlinux/debugfs.h
Detected Declarations
struct nandsimstruct weak_blockstruct weak_pagestruct grave_pagefunction ns_showfunction ns_debugfs_createfunction ns_debugfs_removefunction ns_alloc_devicefunction ns_free_devicefunction ns_initfunction ns_freefunction ns_parse_badblocksfunction ns_parse_weakblocksfunction ns_erase_errorfunction list_for_each_entryfunction ns_parse_weakpagesfunction ns_write_errorfunction list_for_each_entryfunction ns_parse_gravepagesfunction ns_read_errorfunction list_for_each_entryfunction ns_setup_wear_reportingfunction ns_update_wearfunction ns_check_commandfunction ns_get_state_by_commandfunction ns_accept_addr_bytefunction ns_switch_to_ready_statefunction statesfunction ns_put_pagesfunction ns_get_pagesfunction ns_read_filefunction ns_write_filefunction ns_do_read_errorfunction ns_do_bit_flipsfunction ns_read_pagefunction ns_erase_sectorfunction ns_prog_pagefunction ns_do_state_actionfunction ns_switch_statefunction ns_do_state_actionfunction ns_nand_read_bytefunction ns_nand_write_bytefunction ns_nand_write_buffunction ns_nand_read_buffunction ns_exec_opfunction ns_attach_chipfunction ns_init_modulefunction ns_cleanup_module
Annotated Snippet
module_init(ns_init_module);
/*
* Module clean-up function
*/
static void __exit ns_cleanup_module(void)
{
struct nand_chip *chip = mtd_to_nand(nsmtd);
struct nandsim *ns = nand_get_controller_data(chip);
struct list_head *pos, *n;
ns_debugfs_remove(ns);
WARN_ON(mtd_device_unregister(nsmtd));
ns_free(ns);
kfree(erase_block_wear);
nand_cleanup(chip);
list_for_each_safe(pos, n, &grave_pages) {
list_del(pos);
kfree(list_entry(pos, struct grave_page, list));
}
list_for_each_safe(pos, n, &weak_pages) {
list_del(pos);
kfree(list_entry(pos, struct weak_page, list));
}
list_for_each_safe(pos, n, &weak_blocks) {
list_del(pos);
kfree(list_entry(pos, struct weak_block, list));
}
kfree(ns);
}
module_exit(ns_cleanup_module);
MODULE_LICENSE ("GPL");
MODULE_AUTHOR ("Artem B. Bityuckiy");
MODULE_DESCRIPTION ("The NAND flash simulator");
Annotation
- Immediate include surface: `linux/init.h`, `linux/types.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/vmalloc.h`, `linux/math64.h`, `linux/slab.h`, `linux/errno.h`.
- Detected declarations: `struct nandsim`, `struct weak_block`, `struct weak_page`, `struct grave_page`, `function ns_show`, `function ns_debugfs_create`, `function ns_debugfs_remove`, `function ns_alloc_device`, `function ns_free_device`, `function ns_init`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: integration implementation candidate.
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.