STRUCT SPI_NOR_CONTROLLER_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct spi_nor_controller_ops(9) πŸ’…

okay so bestie, welcome to the Kernel API Manual β€” we're looking at struct spi_nor_controller_ops today and honestly? it's giving backstage-pass energy. 🎟️✨


🌸 NAME 🌸

struct spi_nor_controller_ops β€” the SPI NOR controller driver specific operations. literally the little hook table your controller driver fills in so the generic SPI NOR code knows how to actually talk to your hardware. no cap. πŸ¦‹


✨ SYNOPSIS ✨

struct spi_nor_controller_ops {
    int (*prepare)(struct spi_nor *nor);
    void (*unprepare)(struct spi_nor *nor);
    int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, size_t len);
    int (*write_reg)(struct spi_nor *nor, u8 opcode, const u8 *buf, size_t len);
    ssize_t (*read)(struct spi_nor *nor, loff_t from, size_t len, u8 *buf);
    ssize_t (*write)(struct spi_nor *nor, loff_t to, size_t len, const u8 *buf);
    int (*erase)(struct spi_nor *nor, loff_t offs);
 };

it's just a struct full of function pointers and every single one of them gets a struct spi_nor *nor as its first argument. main character struct, honestly. πŸ‘‘


πŸŽ€ Members πŸŽ€

  • prepare β€” [OPTIONAL] does some preparations for the read/write/erase/lock/unlock operations. like doing your skincare before the event, but for flash I/O. πŸ§–β€β™€οΈ
  • unprepare β€” [OPTIONAL] does some post work after the read/write/erase/lock/unlock operations. the wind-down. the debrief. the "okay we're done here." 🫢
  • read_reg β€” reads out the register. that's it, that's the whole vibe. πŸ“–
  • write_reg β€” writes data to the register. ✍️
  • read β€” reads data from the SPI NOR. πŸ“₯
  • write β€” writes data to the SPI NOR. πŸ“€
  • erase β€” erases a sector of the SPI NOR at the offset offs. and here's the tea β˜•: if the driver doesn't provide this one, SPI NOR will send the erase opcode via write_reg instead. so it's lowkey optional but the fallback path is real. iykyk. πŸ”₯
ngl bestie, prepare and unprepare are marked [OPTIONAL] β€” the rest are just... the job. no skipping. πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./include/linux/mtd/spi-nor.h
  • struct spi_nor_hwcaps(9)
  • enum spi_nor_cmd_ext(9)
  • struct spi_nor(9)
  • spi_nor_scan(9)

and that's the whole page, bestie!! πŸŽ‰ go read spi-nor.h, it's literally right there. this lil gem lives in ./include/linux/mtd, dated October 2026, and the page itself is called struct spi_...ntroller_ops(9) (yes the ellipsis is canon, don't @ me). slay, bye! πŸ’–πŸŒˆβ­

πŸ“¦ where this page comes from