spi_write(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ spi_write(9) ✨

okay so this is a page from the Kernel API Manual β€” yes bestie, we're reading kernel docs together, it's giving study date energy πŸŽ€ and honestly? this one's short and sweet, so you're gonna slay it.


πŸ’– NAME πŸ’–

spi_write β€” SPI synchronous write. it writes, it's synchronous, it's an SPI moment. periodt. πŸ’…


🌸 SYNOPSIS 🌸

int spi_write (struct spi_device *spi , const void *buf , size_t len );

like, that's the whole signature, no cap. three args, one int coming back atcha.


πŸ¦‹ ARGUMENTS πŸ¦‹

  • spi β€” the device you're writing data to. the main character of this operation tbh πŸ‘‘
  • buf β€” the data buffer. it's holding your actual bytes, your whole vibe. πŸ“
  • len β€” the size of the data buffer, aka how much of buf we're working with. don't skip this one bestie, it's literally the length. 😭

🧚 CONTEXT 🧚

can sleep 😴 β€” yes, for real. this one is allowed to sleep (more on that below). not every kernel function gets that privilege, so we love her for it. 🫢


⭐ DESCRIPTION ⭐

so what does it do? it writes the buffer buf. that's it, that's the whole thing. πŸ’€

the important bit though β€” the lowkey crucial caveat β€” is that it's callable only from contexts that can sleep. so if you're somewhere that absolutely cannot sleep, do not come here, because this function highkey needs that nap permission. ngl this is the part people get wrong, so like… remember it. πŸ™ˆ


πŸ”₯ RETURN πŸ”₯

  • zero on success πŸŽ‰ (yes, zero means yay in kernel land, iconic behaviour)
  • else a negative error code πŸ’€ so if it's negative, something went wrong. vibe check failed, basically.

🌈 SEE ALSO 🌈

so many friends, we love a connected ecosystem πŸ’œ all of these live in the kernel file ./include/linux/spi/spi.h:


ngl the whole thing is short, so if you blinked you missed it. but every detail up there is load-bearing, so don't go skipping the "can sleep" part β€” that's the one that'll bite you. πŸ’€πŸ’…

and that's the page!! πŸŽ€ source is ./include/linux/spi, and it's dated October 2026 β€” yeah bestie, from the future, we love a time traveler. mwah, go write some SPI, ily πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from