Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / char / serial167.c
index c2deac9..037c940 100644 (file)
@@ -117,7 +117,7 @@ struct cyclades_port cy_port[] = {
         {-1 },      /* ttyS2 */
         {-1 },      /* ttyS3 */
 };
-#define NR_PORTS        (sizeof(cy_port)/sizeof(struct cyclades_port))
+#define NR_PORTS        ARRAY_SIZE(cy_port)
 
 /*
  * tmp_buf is used as a temporary buffer by serial_write.  We need to
@@ -129,7 +129,6 @@ struct cyclades_port cy_port[] = {
  * memory if large numbers of serial ports are open.
  */
 static unsigned char *tmp_buf = 0;
-DECLARE_MUTEX(tmp_buf_sem);
 
 /*
  * This is used to look up the divisor speeds and the timeouts
@@ -422,45 +421,35 @@ cd2401_rxerr_interrupt(int irq, void *dev_id, struct pt_regs *fp)
            base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
            return IRQ_HANDLED;
        }
-       if (tty->flip.count < TTY_FLIPBUF_SIZE){
-           tty->flip.count++;
+       if (tty_buffer_request_room(tty, 1) != 0){
            if (err & info->read_status_mask){
                if(err & CyBREAK){
-                   *tty->flip.flag_buf_ptr++ = TTY_BREAK;
-                   *tty->flip.char_buf_ptr++ = data;
+                   tty_insert_flip_char(tty, data, TTY_BREAK);
                    if (info->flags & ASYNC_SAK){
                        do_SAK(tty);
                    }
                }else if(err & CyFRAME){
-                   *tty->flip.flag_buf_ptr++ = TTY_FRAME;
-                   *tty->flip.char_buf_ptr++ = data;
+                   tty_insert_flip_char(tty, data, TTY_FRAME);
                }else if(err & CyPARITY){
-                   *tty->flip.flag_buf_ptr++ = TTY_PARITY;
-                   *tty->flip.char_buf_ptr++ = data;
+                   tty_insert_flip_char(tty, data, TTY_PARITY);
                }else if(err & CyOVERRUN){
-                   *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
-                   *tty->flip.char_buf_ptr++ = 0;
+                   tty_insert_flip_char(tty, 0, TTY_OVERRUN);
                    /*
                       If the flip buffer itself is
                       overflowing, we still loose
                       the next incoming character.
                     */
-                   if(tty->flip.count < TTY_FLIPBUF_SIZE){
-                       tty->flip.count++;
-                       *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
-                       *tty->flip.char_buf_ptr++ = data;
-                   }
+                   tty_insert_flip_char(tty, data, TTY_NORMAL);
+               }
                /* These two conditions may imply */
                /* a normal read should be done. */
                /* else if(data & CyTIMEOUT) */
                /* else if(data & CySPECHAR) */
                }else{
-                   *tty->flip.flag_buf_ptr++ = 0;
-                   *tty->flip.char_buf_ptr++ = 0;
+                   tty_insert_flip_char(tty, 0, TTY_NORMAL);
                }
            }else{
-               *tty->flip.flag_buf_ptr++ = 0;
-               *tty->flip.char_buf_ptr++ = 0;
+                   tty_insert_flip_char(tty, data, TTY_NORMAL);
            }
        }else{
            /* there was a software buffer overrun
@@ -692,12 +681,7 @@ cd2401_rx_interrupt(int irq, void *dev_id, struct pt_regs *fp)
 #endif
        while(char_count--){
            data = base_addr[CyRDR];
-           if (tty->flip.count >= TTY_FLIPBUF_SIZE){
-               continue;
-           }
-           tty->flip.count++;
-           *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
-           *tty->flip.char_buf_ptr++ = data;
+           tty_insert_flip_char(tty, data, TTY_NORMAL);
 #ifdef CYCLOM_16Y_HACK
            udelay(10L);
 #endif