STRUCT MTD_PAIRING_SCHEME(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct mtd_pairing_scheme πŸ’…

okay bestie, welcome to the Kernel API Manual page for struct mtd_pairing_scheme β€” the page pairing scheme description that’s giving β€œNAND but make it organized” ✨ no cap.

πŸ’– NAME πŸ’–

struct mtd_pairing_scheme β€” page pairing scheme description. That’s the whole name-and-short-desc moment, cute and exact πŸŽ€

✨ SYNOPSIS ✨

here’s the struct in all its glory, copy-paste energy:

struct mtd_pairing_scheme {
    int ngroups;
    int (*get_info)(struct mtd_info *mtd, int wunit, struct
mtd_pairing_info *info);
    int (*get_wunit)(struct mtd_info *mtd, const struct mtd_pairing_info
*info);
 };

🫢 Members 🫢

okay so these are the members, and yes every single one matters:

  • ngroups β€” how many groups there are. It should be related to the number of bits per cell. That’s the vibe check: groups ↔ bits per cell πŸ’«
  • get_info β€” takes a write-unit (the page number inside an erase block) and turns it into mtd_pairing information (pair + group). It should fill the info parameter based on the wunit index, or return -EINVAL if the wunit parameter is invalid. Translation: give it a wunit, it fills in the pairing tea β˜•
  • get_wunit β€” the reverse glow-up: converts pairing information into a write-unit (page) number. It should return the wunit index pointed by the pairing information described in the info argument. If there’s no wunit corresponding to the passed pairing information, it should return -EINVAL. So if the pairing info has no matching wunit? boom, -EINVAL 🫠

🌸 Description 🌸

See the mtd_pairing_info documentation for a detailed explanation of the pair and group concepts. That’s where the lore lives πŸ“–

The mtd_pairing_scheme structure provides a generic solution to represent NAND page pairing scheme. Instead of exposing two big tables to do the write-unit <-> (pair + group) conversions, we ask the MTD drivers to implement the ->get_info and ->get_wunit functions. iconic design choice, honestly πŸ‘‘

MTD users will then be able to query these information by using the mtd_pairing_info_to_wunit and mtd_wunit_to_pairing_info helpers. bestie, the helpers are literally right there 🫢

ngroups is here to help MTD users iterating over all the pages in a given pair. This value can be retrieved by MTD users using the mtd_pairing_groups helper. yes, there’s a helper for the group count too πŸ’…

Examples are given in the mtd_pairing_info_to_wunit and mtd_wunit_to_pairing_info documentation. go peek, iykyk πŸ‘€

πŸ‘‘ SEE ALSO πŸ‘‘

the whole friend group is here:

  • Kernel file ./include/linux/mtd/mtd.h β€” plus: struct mtd_oob_ops(9), struct mtd_oob_region(9), struct mtd_pairing_info(9), struct mtd_debug_info(9), struct mtd_part(9), struct mtd_master(9), mtd_align_erase_req(9) ✨
πŸŽ€ source path ./include/linux/mtd Β· October 2026 Β· struct mtd_pairing_scheme(9) β€” that’s the whole page, bestie, mwah πŸ’‹ πŸŽ€
πŸ“¦ where this page comes from