[PATCH v3 1/2] serial: core: Unify uart_get_baud_rate() success return paths
From: Maciej W. Rozycki
Date: Tue Nov 03 2026 - 17:13:47 EST
In preparation to adding extra return actions merge the two success
return paths in uart_get_baud_rate() into one.
Since as from commit 091ea8e5d34e ("serial: core: prevent division by
zero by always returning non-zero baud rate") it is now guaranteed that
the B0 baud rate is within [min; max], deferring to the regular return
path in the B0 case causes no functional change.
That is as long as max >= max(min, 9600), which I believe is always the
case and none of UART hardware our drivers provide support for has its
highest baud rate below 9600.
Signed-off-by: Maciej W. Rozycki <macro@xxxxxxxxxxx>
---
New change in v3.
---
drivers/tty/serial/serial_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
linux-serial-uart-get-baud-rate-return.diff
Index: linux-macro/drivers/tty/serial/serial_core.c
===================================================================
--- linux-macro.orig/drivers/tty/serial/serial_core.c
+++ linux-macro/drivers/tty/serial/serial_core.c
@@ -515,7 +515,7 @@ uart_get_baud_rate(struct uart_port *por
* Special case: B0 rate.
*/
if (baud == 0)
- return max(min, 9600);
+ baud = max(min, 9600);
if (baud >= min && baud <= max)
return baud;