spi_write(9)
β¨ 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 ofbufwe'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 π₯
zeroon 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:
struct spi_statistics(9)struct spi_delay(9)struct spi_device(9)struct spi_driver(9)spi_unregister_driver(9)module_spi_driver(9)struct spi_controller(9)struct spi_res(9)struct spi_transfer(9)struct spi_message(9)spi_message_init_with_transfers(9)spi_is_bpw_supported(9)spi_bpw_to_bytes(9)spi_controller_xfer_timeout(9)struct spi_replaced_transfers(9)spi_sync_transfer(9)spi_read(9)β her sister function, the reading one, go say hi π«Άspi_w8r8(9)spi_w8r16(9)spi_w8r16be(9)struct spi_board_info(9)
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
- 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