include/linux/mtd/mtd.h
Source file repositories/reference/linux-study-clean/include/linux/mtd/mtd.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/mtd/mtd.h- Extension
.h- Size
- 22834 bytes
- Lines
- 725
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/types.hlinux/uio.hlinux/list.hlinux/notifier.hlinux/device.hlinux/of.hlinux/nvmem-provider.hmtd/mtd-abi.hasm/div64.h
Detected Declarations
struct mtd_infostruct erase_infostruct mtd_erase_region_infostruct mtd_req_statsstruct mtd_oob_opsstruct mtd_oob_regionstruct mtd_ooblayout_opsstruct mtd_pairing_infostruct mtd_pairing_schemestruct modulestruct mtd_debug_infostruct mtd_partstruct mtd_masterstruct mtd_infostruct mtd_partitionstruct mtd_part_parser_datastruct mtd_notifierfunction mtd_get_master_ofsfunction mtd_is_partitionfunction mtd_has_partitionsfunction mtd_set_ooblayoutfunction mtd_set_pairing_schemefunction mtd_set_of_nodefunction mtd_oobavailfunction mtd_max_bad_blocksfunction mtd_syncfunction mtd_suspendfunction mtd_resumefunction mtd_div_by_ebfunction mtd_mod_by_ebfunction mtd_align_erase_reqfunction mtd_div_by_wsfunction mtd_mod_by_wsfunction mtd_wunit_per_ebfunction mtd_offset_to_wunitfunction mtd_wunit_to_offsetfunction mtd_has_oobfunction mtd_type_is_nandfunction mtd_can_have_bbfunction mtd_is_bitflipfunction mtd_is_eccerrfunction mtd_is_bitflip_or_eccerrfunction mtd_check_expert_analysis_mode
Annotated Snippet
struct erase_info {
uint64_t addr;
uint64_t len;
uint64_t fail_addr;
};
struct mtd_erase_region_info {
uint64_t offset; /* At which this region starts, from the beginning of the MTD */
uint32_t erasesize; /* For this region */
uint32_t numblocks; /* Number of blocks of erasesize in this region */
unsigned long *lockmap; /* If keeping bitmap of locks */
};
struct mtd_req_stats {
unsigned int uncorrectable_errors;
unsigned int corrected_bitflips;
unsigned int max_bitflips;
};
/**
* struct mtd_oob_ops - oob operation operands
* @mode: operation mode
*
* @len: number of data bytes to write/read
*
* @retlen: number of data bytes written/read
*
* @ooblen: number of oob bytes to write/read
* @oobretlen: number of oob bytes written/read
* @ooboffs: offset of oob data in the oob area (only relevant when
* mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW)
* @datbuf: data buffer - if NULL only oob data are read/written
* @oobbuf: oob data buffer
*
* Note, some MTD drivers do not allow you to write more than one OOB area at
* one go. If you try to do that on such an MTD device, -EINVAL will be
* returned. If you want to make your implementation portable on all kind of MTD
* devices you should split the write request into several sub-requests when the
* request crosses a page boundary.
*/
struct mtd_oob_ops {
unsigned int mode;
size_t len;
size_t retlen;
size_t ooblen;
size_t oobretlen;
uint32_t ooboffs;
uint8_t *datbuf;
uint8_t *oobbuf;
struct mtd_req_stats *stats;
};
/**
* struct mtd_oob_region - oob region definition
* @offset: region offset
* @length: region length
*
* This structure describes a region of the OOB area, and is used
* to retrieve ECC or free bytes sections.
* Each section is defined by an offset within the OOB area and a
* length.
*/
struct mtd_oob_region {
u32 offset;
u32 length;
};
/*
* struct mtd_ooblayout_ops - NAND OOB layout operations
* @ecc: function returning an ECC region in the OOB area.
* Should return -ERANGE if %section exceeds the total number of
* ECC sections.
* @free: function returning a free region in the OOB area.
* Should return -ERANGE if %section exceeds the total number of
* free sections.
*/
struct mtd_ooblayout_ops {
int (*ecc)(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobecc);
int (*free)(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobfree);
};
/**
* struct mtd_pairing_info - page pairing information
*
* @pair: pair id
* @group: group id
*
* The term "pair" is used here, even though TLC NANDs might group pages by 3
Annotation
- Immediate include surface: `linux/types.h`, `linux/uio.h`, `linux/list.h`, `linux/notifier.h`, `linux/device.h`, `linux/of.h`, `linux/nvmem-provider.h`, `mtd/mtd-abi.h`.
- Detected declarations: `struct mtd_info`, `struct erase_info`, `struct mtd_erase_region_info`, `struct mtd_req_stats`, `struct mtd_oob_ops`, `struct mtd_oob_region`, `struct mtd_ooblayout_ops`, `struct mtd_pairing_info`, `struct mtd_pairing_scheme`, `struct module`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.