spi_read(9)
π spi_read β SPI synchronous read β¨
okay bestie, so we're in the Kernel API Manual, section 9 (that's the kernel API section, iykyk), and today's main character is spi_read. it's a tiny little function, but it's lowkey carrying the whole SPI read situation. let's get into it π«Ά
πΈ NAME πΈ
spi_read β SPI synchronous read. that's it, that's the whole vibe. synchronous, so it does the thing and waits, no chaotic async energy here π
β¨ SYNOPSIS β¨
int spi_read (struct spi_device *spi , void *buf , size_t len );
look at her. three params, one int return, iconic behavior honestly π
π ARGUMENTS π
spiβ the device you're reading data from, bestie. this is the one doing the supplying πbufβ the data buffer. this is where the data goes, it's literally the whole point π¦lenβ the data buffer size. how much room you've got. respect thelenor the kernel will be salty about it π
π CONTEXT π
can sleep π΄
like, fr fr, can sleep. this is not a "call me from an interrupt handler" situation. she needs her rest.
π§ DESCRIPTION π§
so, this function reads the buffer buf. that's the whole description, no notes, she said what she said β¨
and to be crystal clear β it's callable only from contexts that can sleep. so like, process context, places where blocking is allowed. if you're sitting in a context that absolutely cannot sleep, this is not your girl π ngl this part matters, don't skip it.
π reminder: can sleep in CONTEXT and "Callable only from contexts that can sleep" in DESCRIPTION are the same warning said twice, so yes, the kernel devs really wanted you to notice. consider yourself noticed, bestie π
π₯ RETURN π₯
- zero on success π (zero is the good number here, don't be weirded out by that)
- else a negative error code π β if things went sideways, you get a negative number back. so remember: check it. slay responsibly π
π¦ SEE ALSO π¦
the kernel file: ./include/linux/spi/spi.h
and the whole friend group π«Ά:
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_write(9)spi_w8r8(9)spi_w8r16(9)spi_w8r16be(9)struct spi_board_info(9)
π the cute sign-off π
this little masterpiece lives in ./include/linux/spi and it's dated October 2026. so whenever you're reading it, just know: version vibes, timestamped and everything πΈ
anyway bestie, go read your buffers. synchronously. after a nice long sleep. periodt π β¨
π¦ 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