spi_nor_otp_read_secr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… spi_nor_otp_read_secr(9) β€” the Kernel API Manual, bestie edition πŸŽ€

okay so this is spi_nor_otp_read_secr from the Kernel API Manual and she is lowkey iconic β€” she reads a security register for you, no cap ✨


✨ NAME ✨

spi_nor_otp_read_secr β€” read security register πŸ¦‹


🌸 SYNOPSIS 🌸

int spi_nor_otp_read_secr (struct spi_nor *nor , loff_t addr , size_t
len , u8 *buf );

literally that's the whole signature, copy it exactly pls πŸ™ˆ


πŸ’– ARGUMENTS πŸ’–

  • nor β€” pointer to struct spi_nor, the main character of this whole operation πŸ‘‘
  • addr β€” the offset to read from, i.e. where the tea is located πŸ“
  • len β€” number of bytes to read, so like how much tea you're grabbing 🫢
  • buf β€” pointer to dst buffer, the lil basket where your bytes go πŸ’…

🧚 DESCRIPTION 🧚

So here's the vibe: this reads a security register by using the SPINOR_OP_RSECR commands. That's it, that's the job ✨

Now for the lore: in Winbond/GigaDevice datasheets the term "security register" stands for an one-time-programmable memory area, consisting of multiple bytes (usually 256). So one "security register" maps to one OTP region. iykyk πŸ’œ

This method is used on GigaDevice and Winbond flashes. Only those two, fr fr πŸ”₯

⚠️ Please note, the read must not span multiple registers. Like, do not do that. Respect the boundaries bestie πŸ’€

🌈 RETURN 🌈

number of bytes read successfully, -errno otherwise 😭 β€” so you either get your byte count or you get told off with an error code, there is no third option πŸŽ€


⭐ SEE ALSO ⭐

Kernel file ./drivers/mtd/spi-nor/otp.c β€” go read the source, she's right there πŸ¦‹

the whole OTP friend group honestly, obsessed with them πŸ’–


and that's the page!! brought to you by the fine folks over at ./drivers/mtd/spi-nor, dated October 2026 β€” mwah, love u, go read ur security registers responsibly πŸ§šβ€β™€οΈπŸ’…πŸŒΈ

πŸ“¦ where this page comes from