serdev_device_write(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… serdev_device_write β€” the Kernel API Manual page you actually wanna read

Okay bestie, so this is serdev_device_write(9) from the Kernel API Manual, and honestly? It's giving "write it and forget it" β€” except you can't forget it, because it's synchronous. Let me walk you through it. πŸŽ€


✨ NAME ✨

serdev_device_write β€” write data synchronously βœοΈπŸ’«


πŸ¦‹ SYNOPSIS πŸ¦‹

ssize_t serdev_device_write (struct serdev_device *serdev , const u8
*buf , size_t count , long timeout );

That's the whole vibe. Four args, one ssize_t back. Slay.


🌸 ARGUMENTS 🌸

  • serdev β€” the serdev device itself, your main character 🫢
  • buf β€” the data you wanna write, the actual bytes, no cap
  • count β€” how many bytes to write, like literally the number
  • timeout β€” timeout in jiffies, or 0 to wait indefinitely (yes, forever-forever, don't say I didn't warn you 😭)

πŸ’– DESCRIPTION πŸ’–

So here's the tea: you write data to the device synchronously, and it does this by repeatedly calling serdev_device_write until the controller has accepted all the data β€” unless it gets interrupted by a timeout or a signal. Rude, but okay. πŸ’€

ngl there are two notes here and they're both important, so pay attention bestie:
  • Any accepted data has only been buffered by the controller. So if you actually want the controller write buffer to be genuinely emptied, use serdev_device_wait_until_sent. Like, actually actually. ⭐
  • This function depends on serdev_device_write_wakeup being called in the serdev driver write_wakeup callback. That's the whole engine, iykyk. πŸ”₯

πŸ”₯ RETURN πŸ”₯

Here's the vibe check on what comes back:

  • The number of bytes written β€” this can be less than count if it got interrupted πŸ‘€
  • -ETIMEDOUT or -ERESTARTSYS if it got interrupted before any bytes were written
  • Or a negative errno on errors, the classic πŸ˜”

🌈 SEE ALSO 🌈

Peep the kernel file ./drivers/tty/serdev/core.c, plus the whole friend group:


✨ that's the whole page, bestie ✨

This iconic lil doc comes from ./drivers/tty/serdev, dated October 2026, and it's literally titled serdev_device_write(9). Go write some bytes, you absolute legend πŸ’…πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from