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.

Dependency Surface

Detected Declarations

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

Implementation Notes