]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
serial: core: simplify clipping logic in uart_get_baud_rate()
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Fri, 10 Apr 2026 15:20:12 +0000 (11:20 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 May 2026 15:19:52 +0000 (17:19 +0200)
Simplify the clipping logic in uart_get_baud_rate() to improve code
readability.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://patch.msgid.link/20260410152022.2146488-5-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_core.c

index e6a8ab40442d9fb2f6a153ad6e2a4ec75395aa98..f89c0dc29516340f9b9db9412a87cf921eea8594 100644 (file)
@@ -543,11 +543,11 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
                 */
                if (!hung_up) {
                        if (baud <= min)
-                               tty_termios_encode_baud_rate(termios,
-                                                       min + 1, min + 1);
+                               baud = min + 1;
                        else
-                               tty_termios_encode_baud_rate(termios,
-                                                       max - 1, max - 1);
+                               baud = max - 1;
+
+                       tty_termios_encode_baud_rate(termios, baud, baud);
                }
        }
        return 0;