Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / serial / 68360serial.c
index cd2d62c..e80e70e 100644 (file)
@@ -20,7 +20,6 @@
  *     int rs_360_init(void);
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/signal.h>
@@ -394,7 +393,7 @@ static void rs_360_start(struct tty_struct *tty)
 static _INLINE_ void receive_chars(ser_info_t *info)
 {
        struct tty_struct *tty = info->tty;
-       unsigned char ch, *cp;
+       unsigned char ch, flag, *cp;
        /*int   ignored = 0;*/
        int     i;
        ushort  status;
@@ -438,24 +437,15 @@ static _INLINE_ void receive_chars(ser_info_t *info)
                cp = (char *)bdp->buf;
                status = bdp->status;
 
-               /* Check to see if there is room in the tty buffer for
-                * the characters in our BD buffer.  If not, we exit
-                * now, leaving the BD with the characters.  We'll pick
-                * them up again on the next receive interrupt (which could
-                * be a timeout).
-                */
-               if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE)
-                       break;
-
                while (i-- > 0) {
                        ch = *cp++;
-                       *tty->flip.char_buf_ptr = ch;
                        icount->rx++;
 
 #ifdef SERIAL_DEBUG_INTR
                        printk("DR%02x:%02x...", ch, status);
 #endif
-                       *tty->flip.flag_buf_ptr = 0;
+                       flag = TTY_NORMAL;
+
                        if (status & (BD_SC_BR | BD_SC_FR |
                                       BD_SC_PR | BD_SC_OV)) {
                                /*
@@ -490,30 +480,18 @@ static _INLINE_ void receive_chars(ser_info_t *info)
                                        if (info->flags & ASYNC_SAK)
                                                do_SAK(tty);
                                } else if (status & BD_SC_PR)
-                                       *tty->flip.flag_buf_ptr = TTY_PARITY;
+                                       flag = TTY_PARITY;
                                else if (status & BD_SC_FR)
-                                       *tty->flip.flag_buf_ptr = TTY_FRAME;
-                               if (status & BD_SC_OV) {
-                                       /*
-                                        * Overrun is special, since it's
-                                        * reported immediately, and doesn't
-                                        * affect the current character
-                                        */
-                                       if (tty->flip.count < TTY_FLIPBUF_SIZE) {
-                                               tty->flip.count++;
-                                               tty->flip.flag_buf_ptr++;
-                                               tty->flip.char_buf_ptr++;
-                                               *tty->flip.flag_buf_ptr =
-                                                               TTY_OVERRUN;
-                                       }
-                               }
+                                       flag = TTY_FRAME;
                        }
-                       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                               break;
-
-                       tty->flip.flag_buf_ptr++;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
+                       tty_insert_flip_char(tty, ch, flag);
+                       if (status & BD_SC_OV)
+                               /*
+                                * Overrun is special, since it's
+                                * reported immediately, and doesn't
+                                * affect the current character
+                                */
+                               tty_insert_flip_char(tty, 0, TTY_OVERRUN);
                }
 
                /* This BD is ready to be used again.  Clear status.
@@ -530,7 +508,7 @@ static _INLINE_ void receive_chars(ser_info_t *info)
 
        info->rx_cur = (QUICC_BD *)bdp;
 
-       schedule_work(&tty->flip.work);
+       tty_schedule_flip(tty);
 }
 
 static _INLINE_ void receive_break(ser_info_t *info)
@@ -541,13 +519,8 @@ static _INLINE_ void receive_break(ser_info_t *info)
        /* Check to see if there is room in the tty buffer for
         * the break.  If not, we exit now, losing the break.  FIXME
         */
-       if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE)
-               return;
-       *(tty->flip.flag_buf_ptr++) = TTY_BREAK;
-       *(tty->flip.char_buf_ptr++) = 0;
-       tty->flip.count++;
-
-       schedule_work(&tty->flip.work);
+       tty_insert_flip_char(tty, 0, TTY_BREAK);
+       tty_schedule_flip(tty);
 }
 
 static _INLINE_ void transmit_chars(ser_info_t *info)
@@ -1047,7 +1020,7 @@ static void rs_360_put_char(struct tty_struct *tty, unsigned char ch)
 
 }
 
-static int rs_360_write(struct tty_struct * tty, int from_user,
+static int rs_360_write(struct tty_struct * tty,
                    const unsigned char *buf, int count)
 {
        int     c, ret = 0;
@@ -1079,16 +1052,8 @@ static int rs_360_write(struct tty_struct * tty, int from_user,
                        break;
                }
 
-               if (from_user) {
-                       if (copy_from_user((void *)bdp->buf, buf, c)) {
-                               if (!ret)
-                                       ret = -EFAULT;
-                               break;
-                       }
-               } else {
-                       /* memcpy(__va(bdp->buf), buf, c); */
-                       memcpy((void *)bdp->buf, buf, c);
-               }
+               /* memcpy(__va(bdp->buf), buf, c); */
+               memcpy((void *)bdp->buf, buf, c);
 
                bdp->length = c;
                bdp->status |= BD_SC_READY;
@@ -1402,14 +1367,13 @@ static void end_break(ser_info_t *info)
 /*
  * This routine sends a break character out the serial port.
  */
-static void send_break(ser_info_t *info, int duration)
+static void send_break(ser_info_t *info, unsigned int duration)
 {
-       current->state = TASK_INTERRUPTIBLE;
 #ifdef SERIAL_DEBUG_SEND_BREAK
        printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
 #endif
        begin_break(info);
-       schedule_timeout(duration);
+       msleep_interruptible(duration);
        end_break(info);
 #ifdef SERIAL_DEBUG_SEND_BREAK
        printk("done jiffies=%lu\n", jiffies);
@@ -1444,7 +1408,7 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file,
                        if (signal_pending(current))
                                return -EINTR;
                        if (!arg) {
-                               send_break(info, HZ/4); /* 1/4 second */
+                               send_break(info, 250);  /* 1/4 second */
                                if (signal_pending(current))
                                        return -EINTR;
                        }
@@ -1456,7 +1420,7 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file,
                        tty_wait_until_sent(tty, 0);
                        if (signal_pending(current))
                                return -EINTR;
-                       send_break(info, arg ? arg*(HZ/10) : HZ/4);
+                       send_break(info, arg ? arg*100 : 250);
                        if (signal_pending(current))
                                return -EINTR;
                        return 0;
@@ -1715,8 +1679,7 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp)
        info->tty = 0;
        if (info->blocked_open) {
                if (info->close_delay) {
-                       current->state = TASK_INTERRUPTIBLE;
-                       schedule_timeout(info->close_delay);
+                       msleep_interruptible(jiffies_to_msecs(info->close_delay));
                }
                wake_up_interruptible(&info->open_wait);
        }
@@ -1769,9 +1732,8 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
                printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
 #endif
-               current->state = TASK_INTERRUPTIBLE;
 /*             current->counter = 0;    make us low-priority */
-               schedule_timeout(char_time);
+               msleep_interruptible(jiffies_to_msecs(char_time));
                if (signal_pending(current))
                        break;
                if (timeout && ((orig_jiffies + timeout) < jiffies))
@@ -2485,8 +2447,7 @@ static struct tty_operations rs_360_ops = {
        .tiocmset = rs_360_tiocmset,
 };
 
-/* int __init rs_360_init(void) */
-int rs_360_init(void)
+static int __init rs_360_init(void)
 {
        struct serial_state * state;
        ser_info_t      *info;
@@ -2838,10 +2799,7 @@ int rs_360_init(void)
 
        return 0;
 }
-
-
-
-
+module_init(rs_360_init);
 
 /* This must always be called before the rs_360_init() function, otherwise
  * it blows away the port control information.