STRUCT NAND_ECC_CTRL(9)
π NAME π
okay so bestie, welcome to struct nand_ecc_ctrl(9) from the Kernel API Manual β this is literally the Control structure for ECC. itβs the struct where all the ECC control vibes live, and weβre gonna go through every single member together, no skipping, no cap π
β¨ SYNOPSIS β¨
hereβs the whole struct, bestie β every field and function pointer exactly as it appears π
struct nand_ecc_ctrl {
enum nand_ecc_engine_type engine_type;
enum nand_ecc_placement placement;
enum nand_ecc_algo algo;
int steps;
int size;
int bytes;
int total;
int strength;
int prepad;
int postpad;
unsigned int options;
u8 *calc_buf;
u8 *code_buf;
void (*hwctl)(struct nand_chip *chip, int mode);
int (*calculate)(struct nand_chip *chip, const uint8_t *dat, uint8_t *ecc_code);
int (*correct)(struct nand_chip *chip, uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc);
int (*read_page_raw)(struct nand_chip *chip, uint8_t *buf, int oob_required, int page);
int (*write_page_raw)(struct nand_chip *chip, const uint8_t *buf, int oob_required, int page);
int (*read_page)(struct nand_chip *chip, uint8_t *buf, int oob_required, int page);
int (*read_subpage)(struct nand_chip *chip, uint32_t offs, uint32_t len, uint8_t *buf, int page);
int (*write_subpage)(struct nand_chip *chip, uint32_t offset, uint32_t data_len, const uint8_t *data_buf, int oob_required, int page);
int (*write_page)(struct nand_chip *chip, const uint8_t *buf, int oob_required, int page);
int (*write_oob_raw)(struct nand_chip *chip, int page);
int (*read_oob_raw)(struct nand_chip *chip, int page);
int (*read_oob)(struct nand_chip *chip, int page);
int (*write_oob)(struct nand_chip *chip, int page);
};
π Members π
engine_typeβ ECC engine type. the whole βwhat kind of ECC engine is thisβ situation π«placementβ OOB bytes placement. where the out-of-band bytes are doing their thing β¨algoβ ECC algorithm. the algorithm in question, periodt πΈstepsβ number of ECC steps per page. count βem πsizeβ data bytes per ECC step. the data chunk size per step πbytesβ ECC bytes per step. how many ECC bytes each step gets πtotalβ total number of ECC bytes per page. the whole pageβs ECC byte count, fr fr π¦strengthβ max number of correctible bits per ECC step. yes, βcorrectible,β weβre keeping it exactly like that πprepadβ padding information for syndrome based ECC generators. prepad stays prepad πpostpadβ padding information for syndrome based ECC generators. postpad, same energy, different side β¨optionsβ ECC specific options (seeNAND_ECC_XXXflags defined above). flags defined above, iykyk π₯calc_bufβ buffer for calculated ECC, size isoobsize. calculated ECC goes here πcode_bufβ buffer for ECC read from flash, size isoobsize. ECC read from flash goes here πhwctlβ function to control hardware ECC generator. Must only be provided if an hardware ECC is available. so do not just casually wire it up, bestie πcalculateβ function for ECC calculation or readback from ECC hardware. calculation or readback, both iconic π«Άcorrectβ function for ECC correction, matching to ECC generator (sw/hw). Should return a positive number representing the number of corrected bitflips,-EBADMSGif the number of bitflips exceed ECC strength, or any other error code if the error is not directly related to correction. If-EBADMSGis returned the input buffers should be left untouched. okay this one is important β read it twice, bestie πread_page_rawβ function to read a raw page without ECC. This function should hide the specific layout used by the ECC controller and always return contiguous in-band and out-of-band data even if theyβre not stored contiguously on the NAND chip (e.g.NAND_ECC_PLACEMENT_INTERLEAVEDinterleaves in-band and out-of-band data). layout hiding, contiguous return, no surprises β¨write_page_rawβ function to write a raw page without ECC. This function should hide the specific layout used by the ECC controller and consider the passed data as contiguous in-band and out-of-band data. ECC controller is responsible for doing the appropriate transformations to adapt to its specific layout (e.g.NAND_ECC_PLACEMENT_INTERLEAVEDinterleaves in-band and out-of-band data). so the controller handles the transformation glow-up πread_pageβ function to read a page according to the ECC generator requirements; returns maximum number of bitflips corrected in any single ECC step,-EIOhw error. read page, return the max corrected bitflips in any single step, or-EIOon hw error πread_subpageβ function to read parts of the page covered by ECC; returns same asread_page. subpage read, same return vibe asread_pageπ¦write_subpageβ function to write parts of the page covered by ECC. subpage write, ECC-covered parts only πΈwrite_pageβ function to write a page according to the ECC generator requirements. write page, ECC generator requirements, periodt πwrite_oob_rawβ function to write chip OOB data without ECC. raw OOB write, no ECC πread_oob_rawβ function to read chip OOB data without ECC. raw OOB read, no ECC β¨read_oobβ function to read chip OOB data. chip OOB data read, thatβs the whole thing π«write_oobβ function to write chip OOB data. chip OOB data write, slay π
π SEE ALSO π
Kernel file ./include/linux/mtd/rawnand.h β and the whole friend group is here: struct nand_parameters(9), struct nand_id(9), struct nand_ecc_step_info(9), struct nand_ecc_caps(9), struct nand_sdr_timings(9), struct nand_nvddr_timings(9), enum nand_interface_type(9), struct nand_interface_config(9), nand_interface_is_sdr(9), nand_interface_is_nvddr(9), nand_get_sdr_timings(9), nand_get_nvddr_timings(9), struct nand_op_cmd_instr(9), struct nand_op_addr_instr(9), struct nand_op_data_instr(9), struct nand_op_waitrdy_instr(9), enum nand_op_instr_type(9), struct nand_op_instr(9), struct nand_subop(9), struct nand_op_parser_addr_constraints(9), struct nand_op_parser_data_constraints(9), struct nand_op_parser_pattern_elem(9), struct nand_op_parser_pattern(9), struct nand_op_parser(9), struct nand_operation(9), struct nand_controller_ops(9), struct nand_controller(9), struct nand_legacy(9), struct nand_chip_ops(9), struct nand_manufacturer(9), struct nand_secure_region(9), struct nand_chip(9), nand_get_interface_config(9), struct nand_flash_dev(9), nand_opcode_8bits(9), nand_get_data_buf(9). go click through the whole squad, bestie π«Ά
okay thatβs the whole page, and yes it ate π this one lives under ./include/linux/mtd, dated October 2026, and itβs all about struct nand_ecc_ctrl(9) β byeee ππ¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms