serial: timbuart: make sure last byte is sent when port is closed
[pandora-kernel.git] / drivers / serial / timbuart.c
index 62f389f..67ca642 100644 (file)
@@ -68,12 +68,22 @@ static void timbuart_start_tx(struct uart_port *port)
        tasklet_schedule(&uart->tasklet);
 }
 
+static unsigned int timbuart_tx_empty(struct uart_port *port)
+{
+       u32 isr = ioread32(port->membase + TIMBUART_ISR);
+
+       return (isr & TXBE) ? TIOCSER_TEMT : 0;
+}
+
 static void timbuart_flush_buffer(struct uart_port *port)
 {
-       u8 ctl = ioread8(port->membase + TIMBUART_CTRL) | TIMBUART_CTRL_FLSHTX;
+       if (!timbuart_tx_empty(port)) {
+               u8 ctl = ioread8(port->membase + TIMBUART_CTRL) |
+                       TIMBUART_CTRL_FLSHTX;
 
-       iowrite8(ctl, port->membase + TIMBUART_CTRL);
-       iowrite32(TXBF, port->membase + TIMBUART_ISR);
+               iowrite8(ctl, port->membase + TIMBUART_CTRL);
+               iowrite32(TXBF, port->membase + TIMBUART_ISR);
+       }
 }
 
 static void timbuart_rx_chars(struct uart_port *port)
@@ -195,13 +205,6 @@ void timbuart_tasklet(unsigned long arg)
        dev_dbg(uart->port.dev, "%s leaving\n", __func__);
 }
 
-static unsigned int timbuart_tx_empty(struct uart_port *port)
-{
-       u32 isr = ioread32(port->membase + TIMBUART_ISR);
-
-       return (isr & TXBE) ? TIOCSER_TEMT : 0;
-}
-
 static unsigned int timbuart_get_mctrl(struct uart_port *port)
 {
        u8 cts = ioread8(port->membase + TIMBUART_CTRL);