spi_w8r16(9)
π« spi_w8r16(9) π«
ok so welcome to the Kernel API Manual bestie, this is the page for spi_w8r16 and honestly? it's a little cutie. tiny function, big job. let's get into it π
β¨ NAME β¨
spi_w8r16 β SPI synchronous 8 bit write followed by 16 bit read π¦
like, you write 8 bits out, then read 16 bits back. sales. slay. periodt.
πΈ SYNOPSIS πΈ
ssize_t spi_w8r16 (struct spi_device *spi , u8 cmd );
that's the whole thing. one spi, one cmd, one ssize_t coming back atcha π
π§ ARGUMENTS π§
spiβ the device you're exchanging data with. that's your main character, the one you're talking to over SPI πcmdβ the command that gets written before the data is read back. so it goes out first, then we pull the answer in. iykyk π₯
β CONTEXT β
can sleep π΄
no cap, this one's allowed to nap. it's not one of those feral atomic-context functions.
π DESCRIPTION π
ok so the number comes back in wire-order, which is at least sometimes big-endian. the manual is literally saying "at least sometimes" and honestly? relatable. byte order is a whole vibe and it is NOT always consistent π
also, real talk: this is callable only from contexts that can sleep. π«Ά so no, you can't just drop it in an interrupt handler and hope for the best. it needs a context that's allowed to block. lowkey important.
π RETURN π
you get back the (unsigned) sixteen bit number that the device returned π
or, if things went sideways, a negative error code π (yes, negative. check it. always check it. ngl the error code is the drama and you don't want it.)
π SEE ALSO π
like a whole friend group honestly, look at this squad:
- 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_write(9)spi_read(9)spi_w8r8(9)spi_w8r16be(9)struct spi_board_info(9)
the way that list just keeps goingβ¦ obsessed π but fr fr, if you're messing with SPI you're gonna want these.
and that's the page!! π«Ά bye bestie, go forth and read your 16 bits πβ¨π
from ./include/linux/spi, dated October 2026 β mwah, see u in the next manpage π
π
π¦ 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