serdev_device_write(9)
π 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 capcountβ how many bytes to write, like literally the numbertimeoutβ timeout in jiffies, or0to 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_wakeupbeing called in the serdev driverwrite_wakeupcallback. 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
countif it got interrupted π -ETIMEDOUTor-ERESTARTSYSif it got interrupted before any bytes were written- Or a negative
errnoon errors, the classic π
π SEE ALSO π
Peep the kernel file ./drivers/tty/serdev/core.c, plus the whole friend group:
serdev_device_add(9)serdev_device_remove(9)serdev_device_write_buf(9)serdev_device_alloc(9)serdev_controller_alloc(9)of_find_serdev_controller_by_node(9)serdev_acpi_get_uart_resource(9)serdev_controller_add(9)serdev_controller_remove(9)__serdev_device_driver_register(9)
β¨ 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
- 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