spi_mem_dirmap_write(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… spi_mem_dirmap_write β€” the "Kernel API Manual" page, bestie edition πŸ’…

okay so you found yourself staring at spi_mem_dirmap_write(9) and you're like "what does this even do" β€” don't worry, I got you. This is the <cyan>Kernel API Manual</cyan> entry, and it's genuinely not that deep. It's giving write data through a direct mapping. Slay. ✨


πŸŽ€ NAME πŸŽ€

spi_mem_dirmap_write β€” write data through a direct mapping, no cap πŸ’«


🌸 SYNOPSIS 🌸

ssize_t spi_mem_dirmap_write (struct spi_mem_dirmap_desc *desc , u64
offs , size_t len , const void *buf );

literally that's the whole signature, copy it exactly, don't @ me 🫢


✨ ARGUMENTS ✨

  • desc β€” the direct mapping descriptor. your little ticket to the mapping, bestie 🎟️
  • offs β€” offset to start writing from. and listen, this is not an absolute offset β€” it's the offset within the direct mapping, which already has its own offset. so don't go adding things up in your head, it's already accounted for πŸ™ˆ
  • len β€” length in bytes. yes, bytes. the normal unit. πŸ’…
  • buf β€” the source buffer. this buffer must be DMA-able β€” like, non-negotiable, fr fr. if it's not DMA-able that's a you problem πŸ’€

πŸ’– DESCRIPTION πŸ’–

so basically this function writes data to a memory device 🌈 using a direct mapping that you already instantiated earlier with spi_mem_dirmap_create. that's it. that's the vibe. it's the write sibling of the read one and it's honestly so iconic for it πŸ‘‘

lowkey important: the mapping has to exist first. this function doesn't create anything, it just uses what you set up. main character energy but make it a helper function 🧚

⭐ RETURN ⭐

it returns the amount of data written to the memory device, or a negative error code 😭

and here's the part people always miss β€” the returned size might be smaller than len. not a bug, just how it is. so if that happens, you (yes, you, the caller) are responsible for calling spi_mem_dirmap_write again. keep going until it's all written. it's giving "loop it yourself, bestie" πŸ”₯


πŸ¦‹ SEE ALSO πŸ¦‹

the kernel file lives at ./drivers/spi/spi-mem.c if you wanna go read the source like the icon you are πŸ“–

and here's the whole friend group, all present and accounted for:

go read spi_mem_dirmap_read(9) next, it's the twin, they're adorable together 🫢


okay that's the page!! this was brought to you by the <mint>./drivers/spigirlies, datedOctober 2026` β€” same energy, same page, see you in the next manpage bestie πŸ’œπŸŽ€βœ¨

πŸ“¦ where this page comes from