-} /* End pc_flush_chars */
-
-/* ------------------ Begin block_til_ready ---------------------- */
-
-static int block_til_ready(struct tty_struct *tty,
- struct file *filp, struct channel *ch)
-{ /* Begin block_til_ready */
- DECLARE_WAITQUEUE(wait,current);
- int retval, do_clocal = 0;
- unsigned long flags;
-
- if (tty_hung_up_p(filp)) {
- if (ch->asyncflags & ASYNC_HUP_NOTIFY)
- retval = -EAGAIN;
- else
- retval = -ERESTARTSYS;
- return(retval);
- }
-
- /* -----------------------------------------------------------------
- If the device is in the middle of being closed, then block
- until it's done, and then try again.
- -------------------------------------------------------------------- */
- if (ch->asyncflags & ASYNC_CLOSING) {
- interruptible_sleep_on(&ch->close_wait);
-
- if (ch->asyncflags & ASYNC_HUP_NOTIFY)
- return -EAGAIN;
- else
- return -ERESTARTSYS;
- }
-
- if (filp->f_flags & O_NONBLOCK) {
- /* -----------------------------------------------------------------
- If non-blocking mode is set, then make the check up front
- and then exit.
- -------------------------------------------------------------------- */
- ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
- return 0;
- }
- if (tty->termios->c_cflag & CLOCAL)
- do_clocal = 1;
- /* Block waiting for the carrier detect and the line to become free */
-
- retval = 0;
- add_wait_queue(&ch->open_wait, &wait);
-
- spin_lock_irqsave(&epca_lock, flags);
- /* We dec count so that pc_close will know when to free things */
- if (!tty_hung_up_p(filp))
- ch->count--;
- ch->blocked_open++;
- while(1)
- { /* Begin forever while */
- set_current_state(TASK_INTERRUPTIBLE);
- if (tty_hung_up_p(filp) ||
- !(ch->asyncflags & ASYNC_INITIALIZED))
- {
- if (ch->asyncflags & ASYNC_HUP_NOTIFY)
- retval = -EAGAIN;
- else
- retval = -ERESTARTSYS;
- break;
- }
- if (!(ch->asyncflags & ASYNC_CLOSING) &&
- (do_clocal || (ch->imodem & ch->dcd)))
- break;
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- }
- spin_unlock_irqrestore(&epca_lock, flags);
- /* ---------------------------------------------------------------
- Allow someone else to be scheduled. We will occasionally go
- through this loop until one of the above conditions change.
- The below schedule call will allow other processes to enter and
- prevent this loop from hogging the cpu.
- ------------------------------------------------------------------ */
- schedule();
- spin_lock_irqsave(&epca_lock, flags);
-
- } /* End forever while */
-
- current->state = TASK_RUNNING;
- remove_wait_queue(&ch->open_wait, &wait);
- if (!tty_hung_up_p(filp))
- ch->count++;
- ch->blocked_open--;
-
- spin_unlock_irqrestore(&epca_lock, flags);
-
- if (retval)
- return retval;