spi_w8r16(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« 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:

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