summaryrefslogtreecommitdiff
path: root/drivers/tty/serial/dz.c
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2022-08-16 14:57:34 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-08-30 14:22:34 +0200
commitc87391b5dd77fbd4fd0b0a96fa867a169842b0a9 (patch)
tree4abf0e70f97e97bc702fbb4ce116e2b30bbdd27c /drivers/tty/serial/dz.c
parent292e2e7a639dad2392e5af5281d1f48f05dde10d (diff)
serial: dz: Assume previous baudrate is valid
Assume previously used termios has a valid baudrate and use it directly. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Maciej W. Rozycki <macro@orcam.me.uk> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20220816115739.10928-4-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/dz.c')
-rw-r--r--drivers/tty/serial/dz.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index 2e21acf39720..3eaf4e85bfdd 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -592,9 +592,12 @@ static void dz_set_termios(struct uart_port *uport, struct ktermios *termios,
baud = uart_get_baud_rate(uport, termios, old_termios, 50, 9600);
bflag = dz_encode_baud_rate(baud);
- if (bflag < 0) { /* Try to keep unchanged. */
- baud = uart_get_baud_rate(uport, old_termios, NULL, 50, 9600);
- bflag = dz_encode_baud_rate(baud);
+ if (bflag < 0) {
+ if (old_termios) {
+ /* Keep unchanged. */
+ baud = tty_termios_baud_rate(old_termios);
+ bflag = dz_encode_baud_rate(baud);
+ }
if (bflag < 0) { /* Resort to 9600. */
baud = 9600;
bflag = DZ_B9600;