[ARM] 4994/1: <IMX UART>: Move error handling into execution path
[linux-block.git] / drivers / serial / imx.c
index dc1967176fe228811b77a27fb2fcb82c41c8274c..c637ae219126939e62bcc5582299dcbf5e3541c5 100644 (file)
 #define SERIAL_IMX_MAJOR       204
 #define MINOR_START            41
 
-#define NR_PORTS               2
-
-#define IMX_ISR_PASS_LIMIT     256
-
 /*
  * This is the size of our serial port register set.
  */
@@ -308,7 +304,7 @@ static void imx_start_tx(struct uart_port *port)
 
 static irqreturn_t imx_rtsint(int irq, void *dev_id)
 {
-       struct imx_port *sport = (struct imx_port *)dev_id;
+       struct imx_port *sport = dev_id;
        unsigned int val = readl(sport->port.membase + USR1) & USR1_RTSS;
        unsigned long flags;
 
@@ -324,7 +320,7 @@ static irqreturn_t imx_rtsint(int irq, void *dev_id)
 
 static irqreturn_t imx_txint(int irq, void *dev_id)
 {
-       struct imx_port *sport = (struct imx_port *)dev_id;
+       struct imx_port *sport = dev_id;
        struct circ_buf *xmit = &sport->port.info->xmit;
        unsigned long flags;
 
@@ -358,66 +354,58 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
        struct tty_struct *tty = sport->port.info->tty;
        unsigned long flags, temp;
 
-       rx = readl(sport->port.membase + URXD0);
        spin_lock_irqsave(&sport->port.lock,flags);
 
-       do {
+       while ((rx = readl(sport->port.membase + URXD0)) & URXD_CHARRDY) {
                flg = TTY_NORMAL;
                sport->port.icount.rx++;
 
                temp = readl(sport->port.membase + USR2);
-               if( temp & USR2_BRCD ) {
+               if (temp & USR2_BRCD) {
                        writel(temp | USR2_BRCD, sport->port.membase + USR2);
-                       if(uart_handle_break(&sport->port))
-                               goto ignore_char;
+                       if (uart_handle_break(&sport->port))
+                               continue;
                }
 
                if (uart_handle_sysrq_char
                            (&sport->port, (unsigned char)rx))
-                       goto ignore_char;
+                       continue;
+
+               if (rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) {
+                       if (rx & URXD_PRERR)
+                               sport->port.icount.parity++;
+                       else if (rx & URXD_FRMERR)
+                               sport->port.icount.frame++;
+                       if (rx & URXD_OVRRUN)
+                               sport->port.icount.overrun++;
+
+                       if (rx & sport->port.ignore_status_mask) {
+                               if (++ignored > 100)
+                                       goto out;
+                               continue;
+                       }
+
+                       rx &= sport->port.read_status_mask;
+
+                       if (rx & URXD_PRERR)
+                               flg = TTY_PARITY;
+                       else if (rx & URXD_FRMERR)
+                               flg = TTY_FRAME;
+                       if (rx & URXD_OVRRUN)
+                               flg = TTY_OVERRUN;
 
-               if( rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) )
-                       goto handle_error;
+#ifdef SUPPORT_SYSRQ
+                       sport->port.sysrq = 0;
+#endif
+               }
 
-       error_return:
                tty_insert_flip_char(tty, rx, flg);
-
-       ignore_char:
-               rx = readl(sport->port.membase + URXD0);
-       } while(rx & URXD_CHARRDY);
+       }
 
 out:
        spin_unlock_irqrestore(&sport->port.lock,flags);
        tty_flip_buffer_push(tty);
        return IRQ_HANDLED;
-
-handle_error:
-       if (rx & URXD_PRERR)
-               sport->port.icount.parity++;
-       else if (rx & URXD_FRMERR)
-               sport->port.icount.frame++;
-       if (rx & URXD_OVRRUN)
-               sport->port.icount.overrun++;
-
-       if (rx & sport->port.ignore_status_mask) {
-               if (++ignored > 100)
-                       goto out;
-               goto ignore_char;
-       }
-
-       rx &= sport->port.read_status_mask;
-
-       if (rx & URXD_PRERR)
-               flg = TTY_PARITY;
-       else if (rx & URXD_FRMERR)
-               flg = TTY_FRAME;
-       if (rx & URXD_OVRRUN)
-               flg = TTY_OVERRUN;
-
-#ifdef SUPPORT_SYSRQ
-       sport->port.sysrq = 0;
-#endif
-       goto error_return;
 }
 
 /*