STRUCT SPI_NOR_LOCKING_OPS(9)
π struct spi_nor_locking_ops(9) β SPI NOR locking methods
okay so bestie, welcome to the Kernel API Manual page for struct spi_nor_locking_ops, and buckle up because this one is short but lowkey important π It's the little struct that holds the locking methods for SPI NOR flash, and if you're poking at flash regions you're gonna want to know her.
β¨ NAME β¨
struct spi_nor_locking_ops β the SPI NOR locking methods, aka the trio of function pointers that handle locking, unlocking and "hey is this locked?" for a region of your SPI NOR π
β¨ SYNOPSIS β¨
here's the whole struct, and yes we're keeping it character for character because she's iconic:
struct spi_nor_locking_ops {
int (*lock)(struct spi_nor *nor, loff_t ofs, u64 len);
int (*unlock)(struct spi_nor *nor, loff_t ofs, u64 len);
int (*is_locked)(struct spi_nor *nor, loff_t ofs, u64 len);
};
three pointers, three vibes, one struct. slay π
β¨ Members β¨
lockβ locks a region of the SPI NOR. and listen, it never locks more than what is requested, ie. it may lock less π so don't assume "I asked for exactly this much" means you got exactly that much, because you might literally get less. no cap.unlockβ unlocks a region of the SPI NOR. and this one's the opposite energy: it may unlock more than what is requested π so yeah, she's generous. maybe too generous. be aware.is_lockedβ checks if a region of the SPI NOR is completely locked, and returns false otherwise. β οΈ but here's the tea: this feedback may be misleading, because users may get an"unlocked"status even though a subpart of the region is effectively locked π like, the whole region isn't locked, so it says unlocked, but part of it absolutely is locked. read that twice, bestie, because it's giving trustworthy-but-not-really.
π«Ά the accuracy caveat on is_locked is real and it's in the original β don't let the "unlocked" answer fool you into thinking nothing in that region is locked, because a subpart can totally be locked.
β¨ Description β¨
if you're in doubt during development, check out the debugfs output, which tries to be more user friendly πΈ (yes, more user friendly than this struct's is_locked answer, which we just established can be a little misleading β so the debugfs route is the glow-up β¨).
β¨ SEE ALSO β¨
Kernel file ./drivers/mtd/spi-nor/core.h plus the whole friend group π:
struct spi_nor_erase_type(9)struct spi_nor_erase_command(9)struct spi_nor_erase_region(9)struct spi_nor_erase_map(9)struct spi_nor_otp_organization(9)struct spi_nor_otp_ops(9)struct spi_nor_otp(9)struct spi_nor_flash_parameter(9)struct spi_nor_fixups(9)struct spi_nor_id(9)struct flash_info(9)struct spi_nor_manufacturer(9)struct sfdp(9)spi_nor_needs_sfdp(9)
and that's the whole page, bestie π¦ sign-off time: this one lives in ./drivers/mtd/spi-nor, it's the October 2026 edition, and the page itself is struct spi_nor_locking_ops(9) β go forth and lock responsibly, don't trust is_locked blindly, and ily for reading the whole thing β¨π
π¦ 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