STRUCT NVMEM_CONFIG(9)
π struct nvmem_config(9) π
okay so welcome to the Kernel API Manual, bestie π this is the page for struct nvmem_config and honestly? it's giving "how to build an NVMEM device from scratch" and I'm obsessed.
β¨ NAME β¨
struct nvmem_config β the configuration struct for an NVMEM device π¦
πΈ SYNOPSIS πΈ
struct nvmem_config {
struct device *dev;
const char *name;
int id;
struct module *owner;
const struct nvmem_cell_info *cells;
int ncells;
bool add_legacy_fixed_of_cells;
void (*fixup_dt_cell_info)(struct nvmem_device *nvmem, struct nvmem_cell_info *cell);
const struct nvmem_keepout *keepout;
unsigned int nkeepout;
enum nvmem_type type;
bool read_only;
bool root_only;
bool ignore_wp;
struct nvmem_layout *layout;
struct device_node *of_node;
nvmem_reg_read_t reg_read;
nvmem_reg_write_t reg_write;
int size;
int word_size;
int stride;
void *priv;
bool compat;
struct device *base_dev;
};
like, that's the whole blueprint, no cap π₯
π MEMBERS π
bestie there are 24 of these and yes we're doing all of them, grab a snack π
devβ the parent device. your main character's parent, basically.nameβ an optional name. optional but iconic β¨idβ an optional device ID, used up in the full name. heads up: this gets ignored ifnameisNULLπownerβ pointer to the exporter module. it's for refcounting, iykyk.cellsβ optional array of pre-defined NVMEM cells π§ncellsβ the number of elements incells. count 'em, periodt.add_legacy_fixed_of_cellsβ read fixed NVMEM cells from the old OF syntax. retro vibes ngl.fixup_dt_cell_infoβ gets called before a cell is added. use it to modify thenvmem_cell_info. lowkey a lil hook π«Άkeepoutβ optional array of keepout ranges, sorted ascending bystart. don't forget the sort, bestie, it matters πnkeepoutβ the number of elements in thekeepoutarray.typeβ the type of the nvmem storage.read_onlyβ device is read-only. look but don't touch πroot_onlyβ device is accessibly to root only π (yes the original says "accessibly", we love a typo moment, keeping it fr fr)ignore_wpβ the Write Protect pin is managed by the provider.layoutβ the fixed layout associated with this nvmem device.of_nodeβ if given, this will be used instead of the parent'sof_node. it overrides, no questions asked.reg_readβ callback to read data; return zero if successful βreg_writeβ callback to write data; return zero if successful βsizeβ device size.word_sizeβ minimum read/write access granularity.strideβ minimum read/write access stride.privβ user context passed to the read/write callbacks. your personal little bag of stuff πcompatβ the compat field, sitting right there in the struct πbase_devβ the base device pointer. also just vibing in the struct π¦
π¦ NOTE π¦
A default "nvmem<id>" name will be assigned to the device if no name is specified in its configuration. In such case <id> is generated with ida_alloc and the provided id field is ignored π (so don't bother setting it, it's not listening).
Specifying name and setting id to -1 implies a unique device whose name is provided as-is (kept unaltered). literally untouched, kept exactly how you wrote it, main character energy π
π SEE ALSO π
- Kernel file
./include/linux/nvmem-provider.h struct nvmem_keepout(9)struct nvmem_cell_info(9)struct nvmem_layout(9)of_nvmem_layout_get_container(9)
and that's the page, bestie π it lives at ./include/linux and it's dated October 2026 β go off, struct, slay, periodt πΈβ¨π₯
π¦ 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