uart_get_baud_rate(9)
π« 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β theuart_portstructure 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 (orNULL, 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 ismaxπ₯
π 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:
uart_write_wakeup(9)uart_update_timeout(9)uart_get_divisor(9)uart_get_lsr_info(9)uart_console_write(9)uart_parse_earlycon(9)uart_parse_options(9)uart_set_options(9)uart_change_pm(9)uart_register_driver(9)uart_unregister_driver(9)serial_core_add_one_port(9)serial_core_remove_one_port(9)uart_match_port(9)uart_handle_dcd_change(9)uart_handle_cts_change(9)uart_insert_char(9)uart_try_toggle_sysrq(9)uart_get_rs485_mode(9)
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
- 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