patch-2.4.1 linux/drivers/char/n_tty.c
Next file: linux/drivers/i2o/i2o_block.c
Previous file: linux/drivers/char/misc.c
Back to the patch index
Back to the overall index
- Lines: 82
- Date:
Mon Jan 15 18:58:04 2001
- Orig file:
v2.4.0/linux/drivers/char/n_tty.c
- Orig date:
Mon Jul 31 10:14:07 2000
diff -u --recursive --new-file v2.4.0/linux/drivers/char/n_tty.c linux/drivers/char/n_tty.c
@@ -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;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)