STRUCT SPI_NOR_LOCKING_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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