uart_get_baud_rate(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« uart_get_baud_rate(9) πŸ’«

okay so this is a page from the Kernel API Manual β€” yes, the Kernel Kernel API Manual, we're in the big leagues now bestie πŸ‘‘


🌸 NAME 🌸

uart_get_baud_rate β€” return baud rate for a particular port ✨


πŸŽ€ SYNOPSIS πŸŽ€

unsigned int uart_get_baud_rate (struct uart_port *port , struct
       ktermios *termios , const struct ktermios *old , unsigned int min ,
       unsigned int max );

like, that's the whole vibe. one function, four-ish arguments, one unsigned int coming back at you πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • port β€” the uart_port structure that describes the port in question. it's literally the whole personality of this port 🫢
  • termios β€” the desired termios settings. the dreams. the aspirations πŸ’­
  • old β€” the old termios (or NULL, which is totally valid, no shame) πŸ™ˆ
  • min β€” minimum acceptable baud rate. the floor. the bare minimum, and we do NOT go below it βœ‹
  • max β€” maximum acceptable baud rate. the ceiling. the limit. the sky's the limit but the limit is max πŸ”₯

πŸ’œ DESCRIPTION πŸ’œ

so what this function actually does: it decodes the termios structure into a numeric baud rate. decoding! like it's reading a secret message πŸ•΅οΈβ€β™€οΈ and while it's at it, it takes account of the magic 38400 baud rate (the one with the spd_* flags β€” iykyk), and maps the B0 rate to 9600 baud or the min argument, whichever is greater 🌈

and if the new baud rate is invalid? no worries, it just tries the old termios setting instead. cute, right? but if that's still invalid too, it clips to the nearest chip supported rate β€” like, we tried, bestie, we're getting you as close as we can πŸ₯²

here's the important part: the termios structure is updated to reflect the baud rate we're actually going to be using. πŸ’…

⚠️ but do NOT do this for the case where B0 is requested β€” that's the "hang up" case. literally hanging up. do not update. periodt πŸ’€

Locking: caller dependent πŸ” (yes, that means you, you're on your own for the locking, it's giving main character responsibility)


⭐ SEE ALSO ⭐

Kernel file ./drivers/tty/serial/serial_core.c β€” and the whole friend group:


and that's the whole page, bestie πŸ’– this one lives in ./drivers/tty/serial, stamped October 2026, and it's filed under uart_get_baud_rate(9) β€” go read the neighbors, they're iconic too πŸŒŸπŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from