retval = 0;
add_wait_queue(&port->open_wait, &wait);
- spin_lock_irqsave(&riscom_lock, flags);
-
+ spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count--;
-
- spin_unlock_irqrestore(&riscom_lock, flags);
-
port->blocked_open++;
+ spin_unlock_irqrestore(&port->lock, flags);
+
while (1) {
CD = tty_port_carrier_raised(port);
}
__set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait);
+ spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count++;
port->blocked_open--;
- if (retval)
- return retval;
-
- port->flags |= ASYNC_NORMAL_ACTIVE;
+ if (retval == 0)
+ port->flags |= ASYNC_NORMAL_ACTIVE;
+ spin_unlock_irqrestore(&port->lock, flags);
return 0;
}
if (!port || rc_paranoia_check(port, tty->name, "close"))
return;
- spin_lock_irqsave(&riscom_lock, flags);
+ spin_lock_irqsave(&port->port.lock, flags);
if (tty_hung_up_p(filp))
goto out;
* the line discipline to only process XON/XOFF characters.
*/
tty->closing = 1;
+ spin_unlock_irqrestore(&port->port.lock, flags);
if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, port->port.closing_wait);
/*
* interrupt driver to stop checking the data ready bit in the
* line status register.
*/
+
+ spin_lock_irqsave(&riscom_lock, flags);
port->IER &= ~IER_RXD;
if (port->port.flags & ASYNC_INITIALIZED) {
port->IER &= ~IER_TXRDY;
*/
timeout = jiffies + HZ;
while (port->IER & IER_TXEMPTY) {
+ spin_unlock_irqrestore(&riscom_lock, flags);
msleep_interruptible(jiffies_to_msecs(port->timeout));
+ spin_lock_irqsave(&riscom_lock, flags);
if (time_after(jiffies, timeout))
break;
}
}
rc_shutdown_port(tty, bp, port);
rc_flush_buffer(tty);
+ spin_unlock_irqrestore(&riscom_lock, flags);
tty_ldisc_flush(tty);
+ spin_lock_irqsave(&port->port.lock, flags);
tty->closing = 0;
port->port.tty = NULL;
if (port->port.blocked_open) {
+ spin_unlock_irqrestore(&port->port.lock, flags);
if (port->port.close_delay)
msleep_interruptible(jiffies_to_msecs(port->port.close_delay));
wake_up_interruptible(&port->port.open_wait);
+ spin_lock_irqsave(&port->port.lock, flags);
}
port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&port->port.close_wait);
{
struct riscom_port *port = (struct riscom_port *)tty->driver_data;
struct riscom_board *bp;
+ unsigned long flags;
if (rc_paranoia_check(port, tty->name, "rc_hangup"))
return;
bp = port_Board(port);
rc_shutdown_port(tty, bp, port);
+ spin_lock_irqsave(&port->port.lock, flags);
port->port.count = 0;
port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
port->port.tty = NULL;
wake_up_interruptible(&port->port.open_wait);
+ spin_unlock_irqrestore(&port->port.lock, flags);
}
static void rc_set_termios(struct tty_struct *tty,