diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2012-11-19 01:40:56 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-21 18:43:26 -0500 |
commit | 1cd3f2d2c99892209c4751155ae56ff18b1b253e (patch) | |
tree | c4ee87525a902864fabf66f5ce3ec0d18756ebde | |
parent | 159a8e92fdf6967cb67e7639832f819fbc607242 (diff) |
serial: bfin_uart: Don't switch baud rate untill the transfer buffer is empty.
set_termios may be invoked before the former data transfer is completed.
Block until the tranfer is done.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/bfin_uart.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c index 18cf45a29d40..e6a008f4939f 100644 --- a/drivers/tty/serial/bfin_uart.c +++ b/drivers/tty/serial/bfin_uart.c | |||
@@ -799,6 +799,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, | |||
799 | unsigned long flags; | 799 | unsigned long flags; |
800 | unsigned int baud, quot; | 800 | unsigned int baud, quot; |
801 | unsigned int ier, lcr = 0; | 801 | unsigned int ier, lcr = 0; |
802 | unsigned long timeout; | ||
802 | 803 | ||
803 | switch (termios->c_cflag & CSIZE) { | 804 | switch (termios->c_cflag & CSIZE) { |
804 | case CS8: | 805 | case CS8: |
@@ -868,6 +869,14 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, | |||
868 | 869 | ||
869 | UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15); | 870 | UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15); |
870 | 871 | ||
872 | /* Wait till the transfer buffer is empty */ | ||
873 | timeout = jiffies + msecs_to_jiffies(10); | ||
874 | while (UART_GET_GCTL(uart) & UCEN && !(UART_GET_LSR(uart) & TEMT)) | ||
875 | if (time_after(jiffies, timeout)) { | ||
876 | dev_warn(port->dev, "timeout waiting for TX buffer empty\n"); | ||
877 | break; | ||
878 | } | ||
879 | |||
871 | /* Disable UART */ | 880 | /* Disable UART */ |
872 | ier = UART_GET_IER(uart); | 881 | ier = UART_GET_IER(uart); |
873 | UART_PUT_GCTL(uart, UART_GET_GCTL(uart) & ~UCEN); | 882 | UART_PUT_GCTL(uart, UART_GET_GCTL(uart) & ~UCEN); |