Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Kernel v2.4.1 /drivers/char/n_tty.c

Filename:/drivers/char/n_tty.c
Lines Added:23
Lines Deleted:13
Also changed in: (Previous) 2.4.1-pre12  2.4.1-pre11  2.4.1-pre10  2.4.1-pre9  2.4.1-pre8  2.4.0-ac12 
(Following) 2.4.1-ac9  2.4.1-ac10  2.4.1-ac11  2.4.1-ac12  2.4.1-ac13  2.4.1-ac14 

Location
[  2.4.1
  [  drivers
    [  char
       o  n_tty.c

Patch

diff -u --recursive --new-file v2.4.0/linux/drivers/char/n_tty.c linux/drivers/char/n_tty.c
--- v2.4.0/linux/drivers/char/n_tty.c   Mon Jul 31 10:14:07 2000
+++ linux/drivers/char/n_tty.c   Mon Jan 15 18:58:04 2001
@@ -86,6 +86,15 @@
       free_page((unsigned long) buf);
 }
 
+static inline void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)
+{
+   if (tty->read_cnt < N_TTY_BUF_SIZE) {
+      tty->read_buf[tty->read_head] = c;
+      tty->read_head = (tty->read_head + 1) & (N_TTY_BUF_SIZE-1);
+      tty->read_cnt++;
+   }
+}
+
 static inline void put_tty_queue(unsigned char c, struct tty_struct *tty)
 {
    unsigned long flags;
@@ -94,11 +103,7 @@
     *   Why didn't anyone see this one comming? --AJK
    */
    spin_lock_irqsave(&tty->read_lock, flags);
-   if (tty->read_cnt < N_TTY_BUF_SIZE) {
-      tty->read_buf[tty->read_head] = c;
-      tty->read_head = (tty->read_head + 1) & (N_TTY_BUF_SIZE-1);
-      tty->read_cnt++;
-   }
+   put_tty_queue_nolock(c, tty);
    spin_unlock_irqrestore(&tty->read_lock, flags);
 }
 
@@ -499,6 +504,8 @@
 
 static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
 {
+   unsigned long flags;
+
    if (tty->raw) {
       put_tty_queue(c, tty);
       return;
@@ -651,10 +658,12 @@
             put_tty_queue(c, tty);
 
       handle_newline:
+         spin_lock_irqsave(&tty->read_lock, flags);
          set_bit(tty->read_head, &tty->read_flags);
-         put_tty_queue(c, tty);
+         put_tty_queue_nolock(c, tty);
          tty->canon_head = tty->read_head;
          tty->canon_data++;
+         spin_unlock_irqrestore(&tty->read_lock, flags);
          kill_fasync(&tty->fasync, SIGIO, POLL_IN);
          if (waitqueue_active(&tty->read_wait))
             wake_up_interruptible(&tty->read_wait);
@@ -1055,12 +1064,6 @@
             tty->read_tail = ((tty->read_tail+1) &
                     (N_TTY_BUF_SIZE-1));
             tty->read_cnt--;
-            spin_unlock_irqrestore(&tty->read_lock, flags);
-
-            if (!eol || (c != __DISABLED_CHAR)) {
-               put_user(c, b++);
-               nr--;
-            }
             if (eol) {
                /* this test should be redundant:
                 * we shouldn't be reading data if
@@ -1068,8 +1071,15 @@
                 */
                if (--tty->canon_data < 0)
                   tty->canon_data = 0;
-               break;
             }
+            spin_unlock_irqrestore(&tty->read_lock, flags);
+
+            if (!eol || (c != __DISABLED_CHAR)) {
+               put_user(c, b++);
+               nr--;
+            }
+            if (eol)
+               break;
          }
       } else {
          int uncopied;


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.