--- zzzz-none-000/linux-2.4.17/drivers/char/n_hdlc.c 2001-09-13 22:21:32.000000000 +0000 +++ sangam-fb-322/linux-2.4.17/drivers/char/n_hdlc.c 2004-11-24 13:23:21.000000000 +0000 @@ -9,7 +9,7 @@ * Al Longyear , Paul Mackerras * * Original release 01/11/99 - * $Id: n_hdlc.c,v 3.2 2000/11/06 22:34:38 paul Exp $ + * $Id: n_hdlc.c,v 1.1.1.1 2003/06/23 22:18:25 jharrell Exp $ * * This code is released under the GNU General Public License (GPL) * @@ -78,7 +78,7 @@ */ #define HDLC_MAGIC 0x239e -#define HDLC_VERSION "3.2" +#define HDLC_VERSION "$Revision: 1.1.1.1 $" #include #include @@ -160,11 +160,6 @@ struct tty_struct *tty; /* ptr to TTY structure */ struct tty_struct *backup_tty; /* TTY to use if tty gets closed */ - /* Queues for select() functionality */ - wait_queue_head_t read_wait; - wait_queue_head_t write_wait; - wait_queue_head_t poll_wait; - int tbusy; /* reentrancy flag for tx wakeup code */ int woke_up; N_HDLC_BUF *tbuf; /* currently transmitting tx buffer */ @@ -235,9 +230,8 @@ printk("%s(%d)n_hdlc_release() called\n",__FILE__,__LINE__); /* Ensure that the n_hdlcd process is not hanging on select()/poll() */ - wake_up_interruptible (&n_hdlc->read_wait); - wake_up_interruptible (&n_hdlc->poll_wait); - wake_up_interruptible (&n_hdlc->write_wait); + wake_up_interruptible (&tty->read_wait); + wake_up_interruptible (&tty->write_wait); if (tty != NULL && tty->disc_data == n_hdlc) tty->disc_data = NULL; /* Break the tty->n_hdlc link */ @@ -432,8 +426,7 @@ n_hdlc->tbuf = NULL; /* wait up sleeping writers */ - wake_up_interruptible(&n_hdlc->write_wait); - wake_up_interruptible(&n_hdlc->poll_wait); + wake_up_interruptible(&tty->write_wait); /* get next pending transmit buffer */ tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); @@ -575,8 +568,7 @@ n_hdlc_buf_put(&n_hdlc->rx_buf_list,buf); /* wake up any blocked reads and perform async signalling */ - wake_up_interruptible (&n_hdlc->read_wait); - wake_up_interruptible (&n_hdlc->poll_wait); + wake_up_interruptible (&tty->read_wait); if (n_hdlc->tty->fasync != NULL) kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN); @@ -621,6 +613,9 @@ } for (;;) { + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) + return -EIO; + n_hdlc = tty2n_hdlc (tty); if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || tty != n_hdlc->tty) @@ -634,7 +629,7 @@ if (file->f_flags & O_NONBLOCK) return -EAGAIN; - interruptible_sleep_on (&n_hdlc->read_wait); + interruptible_sleep_on (&tty->read_wait); if (signal_pending(current)) return -EINTR; } @@ -703,7 +698,7 @@ count = maxframe; } - add_wait_queue(&n_hdlc->write_wait, &wait); + add_wait_queue(&tty->write_wait, &wait); set_current_state(TASK_INTERRUPTIBLE); /* Allocate transmit buffer */ @@ -726,7 +721,7 @@ } set_current_state(TASK_RUNNING); - remove_wait_queue(&n_hdlc->write_wait, &wait); + remove_wait_queue(&tty->write_wait, &wait); if (!error) { /* Retrieve the user's buffer */ @@ -836,12 +831,14 @@ if (n_hdlc && n_hdlc->magic == HDLC_MAGIC && tty == n_hdlc->tty) { /* queue current process into any wait queue that */ /* may awaken in the future (read and write) */ - poll_wait(filp, &n_hdlc->poll_wait, wait); + + poll_wait(filp, &tty->read_wait, wait); + poll_wait(filp, &tty->write_wait, wait); /* set bits for operations that wont block */ if(n_hdlc->rx_buf_list.head) mask |= POLLIN | POLLRDNORM; /* readable */ - if(tty->flags & (1 << TTY_OTHER_CLOSED)) + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) mask |= POLLHUP; if(tty_hung_up_p(filp)) mask |= POLLHUP; @@ -895,11 +892,7 @@ /* Initialize the control block */ n_hdlc->magic = HDLC_MAGIC; - n_hdlc->flags = 0; - init_waitqueue_head(&n_hdlc->read_wait); - init_waitqueue_head(&n_hdlc->poll_wait); - init_waitqueue_head(&n_hdlc->write_wait); return n_hdlc;