Skip to content

Commit 5bfdd3c

Browse files
TobleMinergregkh
authored andcommitted
serial: atmel: fix incorrect baudrate setup
Commit ba47f97 ("serial: core: remove baud_rates when serial console setup") changed uart_set_options to select the correct baudrate configuration based on the absolute error between requested baudrate and available standard baudrate settings. Prior to that commit the baudrate was selected based on which predefined standard baudrate did not exceed the requested baudrate. This change of selection logic was never reflected in the atmel serial driver. Thus the comment left in the atmel serial driver is no longer accurate. Additionally the manual rounding up described in that comment and applied via (quot - 1) requests an incorrect baudrate. Since uart_set_options uses tty_termios_encode_baud_rate to determine the appropriate baudrate flags this can cause baudrate selection to fail entirely because tty_termios_encode_baud_rate will only select a baudrate if relative error between requested and selected baudrate does not exceed +/-2%. Fix that by requesting actual, exact baudrate used by the serial. Fixes: ba47f97 ("serial: core: remove baud_rates when serial console setup") Cc: stable <stable@kernel.org> Signed-off-by: Tobias Schramm <t.schramm@manjaro.org> Acked-by: Richard Genoud <richard.genoud@gmail.com> Link: https://lore.kernel.org/r/20230109072940.202936-1-t.schramm@manjaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5abbeeb commit 5bfdd3c

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

drivers/tty/serial/atmel_serial.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,13 +2657,7 @@ static void __init atmel_console_get_options(struct uart_port *port, int *baud,
26572657
else if (mr == ATMEL_US_PAR_ODD)
26582658
*parity = 'o';
26592659

2660-
/*
2661-
* The serial core only rounds down when matching this to a
2662-
* supported baud rate. Make sure we don't end up slightly
2663-
* lower than one of those, as it would make us fall through
2664-
* to a much lower baud rate than we really want.
2665-
*/
2666-
*baud = port->uartclk / (16 * (quot - 1));
2660+
*baud = port->uartclk / (16 * quot);
26672661
}
26682662

26692663
static int __init atmel_console_setup(struct console *co, char *options)

0 commit comments

Comments
 (0)