diff -Nru linux.orig/drivers/char/xilinx_uartlite/xuartlite_serial.c linux.result/drivers/char/xilinx_uartlite/xuartlite_serial.c --- linux.orig/drivers/char/xilinx_uartlite/xuartlite_serial.c 2005-02-08 13:04:27.000000000 +0300 +++ linux.result/drivers/char/xilinx_uartlite/xuartlite_serial.c 2005-02-08 13:37:40.000000000 +0300 @@ -540,15 +540,18 @@ if (pxs->thr_chars[0] == 0) { pxs->tx_int_cnt += ByteCount; - pgs->xmit_tail += ByteCount; - if (pgs->xmit_tail >= SERIAL_XMIT_SIZE) { - pgs->xmit_tail -= SERIAL_XMIT_SIZE; + if (pgs->xmit_cnt >= ByteCount) { + pgs->xmit_cnt -= ByteCount; + pgs->xmit_tail += ByteCount; + } else { + pgs->xmit_tail += pgs->xmit_cnt; + pgs->xmit_cnt = 0; } - pgs->xmit_cnt -= ByteCount; + if (pgs->xmit_tail >= SERIAL_XMIT_SIZE) + pgs->xmit_tail -= SERIAL_XMIT_SIZE; } else { pxs->tx_thr_cnt += ByteCount; } - /* throttle/unthrottle stuff: queue a byte for transmission (if any), * indicate that there is a room for the next XON/XOFF */ pxs->thr_chars[0] = pxs->thr_chars[1]; @@ -661,6 +664,7 @@ pgs = &pxs->gs_data; tty->driver_data = pgs; + tty->disc_data = pxs; pgs->tty = tty; pgs->count++; @@ -770,6 +774,35 @@ func_exit(); } +static void +xuli_flush_buffer (struct tty_struct *tty) +{ + struct gs_port *port; + struct xs_port *pxs; + unsigned long flags; + + func_enter (); + + if (!tty) return; + + port = tty->driver_data; + if (!port) return; + + pxs = tty->disc_data; + if (!pxs) + return; + del_timer_sync(&pxs->tx_timer); + save_and_cli(flags); + XUartLite_DisableInterrupt(&pxs->x_uart_lite); + gs_flush_buffer(tty); + XUartLite_ResetFifos(&pxs->x_uart_lite); + XUartLite_Send(&pxs->x_uart_lite, port->xmit_buf, 0); /* stop transmission */ + pxs->rx_enabled = 1; + pxs->tx_started = 0; + XUartLite_EnableInterrupt(&pxs->x_uart_lite); + restore_flags(flags); +} + /* * Hang up the serial port */ @@ -1010,7 +1043,7 @@ xuli_driver.flush_chars = gs_flush_chars; xuli_driver.write_room = gs_write_room; xuli_driver.chars_in_buffer = gs_chars_in_buffer; - xuli_driver.flush_buffer = gs_flush_buffer; + xuli_driver.flush_buffer = xuli_flush_buffer; xuli_driver.ioctl = xuli_ioctl; xuli_driver.throttle = xuli_throttle; xuli_driver.unthrottle = xuli_unthrottle;