aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorSonic Zhang <sonic.zhang@analog.com>2012-11-19 14:40:56 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-21 15:43:26 -0800
commit1cd3f2d2c99892209c4751155ae56ff18b1b253e (patch)
treec4ee87525a902864fabf66f5ce3ec0d18756ebde /drivers/tty
parentpty: Mark pty_resize static (diff)
downloadlinux-dev-1cd3f2d2c99892209c4751155ae56ff18b1b253e.tar.xz
linux-dev-1cd3f2d2c99892209c4751155ae56ff18b1b253e.zip
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>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/bfin_uart.c9
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,
unsigned long flags;
unsigned int baud, quot;
unsigned int ier, lcr = 0;
+ unsigned long timeout;
switch (termios->c_cflag & CSIZE) {
case CS8:
@@ -868,6 +869,14 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
+ /* Wait till the transfer buffer is empty */
+ timeout = jiffies + msecs_to_jiffies(10);
+ while (UART_GET_GCTL(uart) & UCEN && !(UART_GET_LSR(uart) & TEMT))
+ if (time_after(jiffies, timeout)) {
+ dev_warn(port->dev, "timeout waiting for TX buffer empty\n");
+ break;
+ }
+
/* Disable UART */
ier = UART_GET_IER(uart);
UART_PUT_GCTL(uart, UART_GET_GCTL(uart) & ~UCEN);