block: bd_start_claiming cleanup
[safe/jmp/linux-2.6] / drivers / serial / bfin_sport_uart.c
index 5224db2..e57fb3d 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/tty_flip.h>
 #include <linux/serial_core.h>
 
+#include <asm/bfin_sport.h>
 #include <asm/delay.h>
 #include <asm/portmux.h>
 
@@ -54,7 +55,7 @@ struct sport_uart_port {
 #endif
 };
 
-static void sport_uart_tx_chars(struct sport_uart_port *up);
+static int sport_uart_tx_chars(struct sport_uart_port *up);
 static void sport_stop_tx(struct uart_port *port);
 
 static inline void tx_one_byte(struct sport_uart_port *up, unsigned int value)
@@ -307,18 +308,24 @@ static int sport_startup(struct uart_port *port)
        return ret;
 }
 
-static void sport_uart_tx_chars(struct sport_uart_port *up)
+/*
+ * sport_uart_tx_chars
+ *
+ * ret 1 means need to enable sport.
+ * ret 0 means do nothing.
+ */
+static int sport_uart_tx_chars(struct sport_uart_port *up)
 {
        struct circ_buf *xmit = &up->port.state->xmit;
 
        if (SPORT_GET_STAT(up) & TXF)
-               return;
+               return 0;
 
        if (up->port.x_char) {
                tx_one_byte(up, up->port.x_char);
                up->port.icount.tx++;
                up->port.x_char = 0;
-               return;
+               return 1;
        }
 
        if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
@@ -329,7 +336,7 @@ static void sport_uart_tx_chars(struct sport_uart_port *up)
                 */
                if (SPORT_GET_STAT(up) & TXHRE)
                        sport_stop_tx(&up->port);
-               return;
+               return 0;
        }
 
        while(!(SPORT_GET_STAT(up) & TXF) && !uart_circ_empty(xmit)) {
@@ -340,6 +347,8 @@ static void sport_uart_tx_chars(struct sport_uart_port *up)
 
        if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
                uart_write_wakeup(&up->port);
+
+       return 1;
 }
 
 static unsigned int sport_tx_empty(struct uart_port *port)
@@ -361,6 +370,9 @@ static void sport_stop_tx(struct uart_port *port)
 
        pr_debug("%s enter\n", __func__);
 
+       if (!(SPORT_GET_TCR1(up) & TSPEN))
+               return;
+
        /* Although the hold register is empty, last byte is still in shift
         * register and not sent out yet. So, put a dummy data into TX FIFO.
         * Then, sport tx stops when last byte is shift out and the dummy
@@ -383,11 +395,12 @@ static void sport_start_tx(struct uart_port *port)
        pr_debug("%s enter\n", __func__);
 
        /* Write data into SPORT FIFO before enable SPROT to transmit */
-       sport_uart_tx_chars(up);
+       if (sport_uart_tx_chars(up)) {
+               /* Enable transmit, then an interrupt will generated */
+               SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) | TSPEN));
+               SSYNC();
+       }
 
-       /* Enable transmit, then an interrupt will generated */
-       SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) | TSPEN));
-       SSYNC();
        pr_debug("%s exit\n", __func__);
 }
 
@@ -500,27 +513,12 @@ static void sport_set_termios(struct uart_port *port,
 
        spin_lock_irqsave(&up->port.lock, flags);
 
-       port->read_status_mask = OE;
-       if (termios->c_iflag & INPCK)
-               port->read_status_mask |= (FE | PE);
-       if (termios->c_iflag & (BRKINT | PARMRK))
-               port->read_status_mask |= BI;
+       port->read_status_mask = 0;
 
        /*
         * Characters to ignore
         */
        port->ignore_status_mask = 0;
-       if (termios->c_iflag & IGNPAR)
-               port->ignore_status_mask |= FE | PE;
-       if (termios->c_iflag & IGNBRK) {
-               port->ignore_status_mask |= BI;
-               /*
-                * If we're ignoring parity and break indicators,
-                * ignore overruns too (for real raw support).
-                */
-               if (termios->c_iflag & IGNPAR)
-                       port->ignore_status_mask |= OE;
-       }
 
        /* RX extract mask */
        up->rxmask = 0x01 | (((up->csize + up->stopb) * 2 - 1) << 0x8);
@@ -746,11 +744,11 @@ static int __devinit sport_uart_probe(struct platform_device *pdev)
 
        if (bfin_sport_uart_ports[pdev->id] == NULL) {
                bfin_sport_uart_ports[pdev->id] =
-                       kmalloc(sizeof(struct sport_uart_port), GFP_KERNEL);
+                       kzalloc(sizeof(struct sport_uart_port), GFP_KERNEL);
                sport = bfin_sport_uart_ports[pdev->id];
                if (!sport) {
                        dev_err(&pdev->dev,
-                               "Fail to kmalloc sport_uart_port\n");
+                               "Fail to malloc sport_uart_port\n");
                        return -ENOMEM;
                }
 
@@ -776,8 +774,7 @@ static int __devinit sport_uart_probe(struct platform_device *pdev)
                        goto out_error_free_peripherals;
                }
 
-               sport->port.membase = ioremap(res->start,
-                       res->end - res->start);
+               sport->port.membase = ioremap(res->start, resource_size(res));
                if (!sport->port.membase) {
                        dev_err(&pdev->dev, "Cannot map sport IO\n");
                        ret = -ENXIO;