drivers/mtd/mtdsuper.c
Source file repositories/reference/linux-study-clean/drivers/mtd/mtdsuper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/mtdsuper.c- Extension
.c- Size
- 4499 bytes
- Lines
- 180
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mtd/super.hlinux/namei.hlinux/export.hlinux/ctype.hlinux/slab.hlinux/major.hlinux/backing-dev.hlinux/blkdev.hlinux/fs_context.hmtdcore.h
Detected Declarations
function mtd_get_sbfunction mtd_get_sb_by_nrfunction get_tree_mtdfunction kill_mtd_superexport get_tree_mtdexport kill_mtd_super
Annotated Snippet
if (fc->source[3] == ':') {
struct mtd_info *mtd;
/* mount by MTD device name */
pr_debug("MTDSB: mtd:%%s, name \"%s\"\n",
fc->source + 4);
mtd = get_mtd_device_nm(fc->source + 4);
if (!IS_ERR(mtd))
return mtd_get_sb(fc, mtd, fill_super);
errorf(fc, "MTD: MTD device with name \"%s\" not found",
fc->source + 4);
} else if (isdigit(fc->source[3])) {
/* mount by MTD device number name */
unsigned int mtdnr_val;
if (kstrtouint(fc->source + 3, 0, &mtdnr_val) == 0) {
mtdnr = mtdnr_val;
/* It was a valid number */
pr_debug("MTDSB: mtd%%d, mtdnr %u\n", mtdnr_val);
return mtd_get_sb_by_nr(fc, mtdnr, fill_super);
}
}
}
#ifdef CONFIG_BLOCK
/* try the old way - the hack where we allowed users to mount
* /dev/mtdblock$(n) but didn't actually _use_ the blockdev
*/
ret = lookup_bdev(fc->source, &dev);
if (ret) {
errorf(fc, "MTD: Couldn't look up '%s': %d", fc->source, ret);
return ret;
}
pr_debug("MTDSB: lookup_bdev() returned 0\n");
if (MAJOR(dev) == MTD_BLOCK_MAJOR)
return mtd_get_sb_by_nr(fc, MINOR(dev), fill_super);
#endif /* CONFIG_BLOCK */
if (!(fc->sb_flags & SB_SILENT))
errorf(fc, "MTD: Attempt to mount non-MTD device \"%s\"",
fc->source);
return -EINVAL;
}
EXPORT_SYMBOL_GPL(get_tree_mtd);
/*
* destroy an MTD-based superblock
*/
void kill_mtd_super(struct super_block *sb)
{
generic_shutdown_super(sb);
put_mtd_device(sb->s_mtd);
sb->s_mtd = NULL;
}
EXPORT_SYMBOL_GPL(kill_mtd_super);
Annotation
- Immediate include surface: `linux/mtd/super.h`, `linux/namei.h`, `linux/export.h`, `linux/ctype.h`, `linux/slab.h`, `linux/major.h`, `linux/backing-dev.h`, `linux/blkdev.h`.
- Detected declarations: `function mtd_get_sb`, `function mtd_get_sb_by_nr`, `function get_tree_mtd`, `function kill_mtd_super`, `export get_tree_mtd`, `export kill_mtd_super`.
- 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.