[PATCH 4/5] serial: core: avoid redundant baud assignment without any UPF_SPD_* flags

From: Hugo Villeneuve

Date: Tue Oct 20 2026 - 14:43:51 EST


From: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>

If no UPF_SPD_* flags are set, the spd_* flags kludge is not necessary, so
avoid redundant and confusing "baud = altbaud" assignment.

No functional change intended.

Signed-off-by: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
---
drivers/tty/serial/serial_core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d9ed7db53e68d..08a6afa75af07 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -494,7 +494,7 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
altbaud = 460800;
break;
default:
- altbaud = 38400;
+ altbaud = 0;
break;
}

@@ -505,7 +505,7 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
* The spd_hi, spd_vhi, spd_shi, spd_warp kludge...
* Die! Die! Die!
*/
- if (try == 0 && baud == 38400)
+ if (altbaud && baud == 38400)
baud = altbaud;

/*
@@ -517,6 +517,8 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
if (baud >= min && baud <= max)
return baud;

+ altbaud = 0; /* No more spd_* kludge for next iterations. */
+
/*
* If the range cannot be met then try again with
* the old baud rate if possible.
--
2.47.3