STRUCT NVMEM_CONFIG(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ 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 if name is NULL πŸ’€
  • owner β€” pointer to the exporter module. it's for refcounting, iykyk.
  • cells β€” optional array of pre-defined NVMEM cells 🧚
  • ncells β€” the number of elements in cells. 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 the nvmem_cell_info. lowkey a lil hook 🫢
  • keepout β€” optional array of keepout ranges, sorted ascending by start. don't forget the sort, bestie, it matters πŸ™ˆ
  • nkeepout β€” the number of elements in the keepout array.
  • 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's of_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 🌈


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