Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: core: tidy invalid baudrate handling in uart_get_baud_rate

uart_get_baud_rate has input parameters 'min' and 'max' limiting the
range of acceptable baud rates from the caller's perspective. If neither
current or old termios structures have acceptable baud rate setting and
9600 is not in the min/max range either the function returns 0 and
issues a warning.
However for a UART that does not support speed of 9600 baud this is
expected behavior.
Clarify that 0 can be (and always could be) returned from the
uart_get_baud_rate. Don't issue a warning in that case.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Link: https://lore.kernel.org/r/20231010085926.1021667-2-jcmvbkbc@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Max Filippov and committed by
Greg Kroah-Hartman
23bf72fa 1ed59c5e

+1 -3
+1 -3
drivers/tty/serial/serial_core.c
··· 431 431 * baud. 432 432 * 433 433 * If the new baud rate is invalid, try the @old termios setting. If it's still 434 - * invalid, we try 9600 baud. 434 + * invalid, we try 9600 baud. If that is also invalid 0 is returned. 435 435 * 436 436 * The @termios structure is updated to reflect the baud rate we're actually 437 437 * going to be using. Don't do this for the case where B0 is requested ("hang ··· 515 515 max - 1, max - 1); 516 516 } 517 517 } 518 - /* Should never happen */ 519 - WARN_ON(1); 520 518 return 0; 521 519 } 522 520 EXPORT_SYMBOL(uart_get_baud_rate);