Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: don't optimise away baud rate changes when BOTHER is used

The uart_set_termios() function will bail out early without bothering to
touch the hardware, if it decides that nothing "relevant" has changed.
Unfortunately, its idea of "relevant" doesn't include c_[io]speed. So if
the baud rate bits are BOTHER and you just change the speed, the change
gets optimised away.

This patch makes it ignore the old Bfoo bits in c_cflag and just check
whether c_ispeed and c_ospeed have changed. Those integers are always set
appropriately for us by set_termios().

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Alan Cox <alan@redhat.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Woodhouse and committed by
Linus Torvalds
20620d68 187226f5

+5 -2
+5 -2
drivers/serial/serial_core.c
··· 1146 1146 1147 1147 /* 1148 1148 * These are the bits that are used to setup various 1149 - * flags in the low level driver. 1149 + * flags in the low level driver. We can ignore the Bfoo 1150 + * bits in c_cflag; c_[io]speed will always be set 1151 + * appropriately by set_termios() in tty_ioctl.c 1150 1152 */ 1151 1153 #define RELEVANT_IFLAG(iflag) ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) 1152 - 1153 1154 if ((cflag ^ old_termios->c_cflag) == 0 && 1155 + tty->termios->c_ospeed == old_termios->c_ospeed && 1156 + tty->termios->c_ispeed == old_termios->c_ispeed && 1154 1157 RELEVANT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0) 1155 1158 return; 1156 1159