STRUCT NVRAM_OPS(9)
πΎ struct nvram_ops(9) β the kernel API manual, but make it make sense
okay so bestie, this is a page from the Kernel API Manual (that's the manual name, iykyk π ) and it's all about one little struct. buckle up.
β¨ NAME β¨
struct nvram_ops β NVRAM functionality made available to drivers π«Ά
like, it's the official handshake between NVRAM hardware and the drivers that wanna talk to it. iconic behavior honestly.
πΈ SYNOPSIS πΈ
struct nvram_ops {
ssize_t (*get_size)(void);
unsigned char (*read_byte)(int);
void (*write_byte)(unsigned char, int);
ssize_t (*read)(char *, size_t, loff_t *);
ssize_t (*write)(char *, size_t, loff_t *);
#if defined(CONFIG_X86) || defined(CONFIG_M68K);
long (*initialize)(void);
long (*set_checksum)(void);
#endif;
};
no cap, that #if block is doing a lot of heavy lifting β those last two members show up only on CONFIG_X86 or CONFIG_M68K. everybody else? they're not invited.
π Members π
get_sizeβ returns the fixed number of bytes in the NVRAM. that's it. that's the vibe check.read_byteβ loads a single byte from NVRAM. one (1) byte. tiny but mighty π¦write_byteβ stores a single byte to NVRAM. also one byte. also iconic.readβ validates the checksum (if there even is one) and then loads a range of bytes from NVRAM. it's giving responsible main character energy.writeβ stores a range of bytes to NVRAM and then updates the checksum (again, only if there is one). periodt.
π Description π
so here's the tea β β architectures that provide an nvram_ops struct do not have to implement all of these methods. it's not a contract, it's a menu. lowkey generous of them.
if the NVRAM hardware can only be accessed one byte at a time, then it may be sufficient to provide just .read_byte and .write_byte. that's your whole setup. cute, minimal, done.
but if your NVRAM has a checksum (and yes, it's actually going to be checked), then the .read and .write methods are the ones to use β they implement that checksum thing efficiently. work smarter not harder bestie π
portable drivers may use the wrapper functions defined here. the nvram_read and nvram_write functions call the .read and .write methods when those are available, and fall back on the .read_byte and .write_byte methods otherwise. so likeβ¦ it figures it out for you. bestie behavior fr fr π₯
π¦ SEE ALSO π¦
- Kernel file
./include/linux/nvram.hβ go look, it's right there π
ok that's the whole page π«Ά no members were skipped, no flags were harmed, and every single detail is still in there. you're welcome.
β signed off with love from the ./include/linux girlies, dated October 2026, bringing you struct nvram_ops(9) β¨ππ
π¦ 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