struct uart_state *state = tty->driver_data;
        struct tty_port *port;
        struct uart_port *uport;
+       unsigned long flags;
 
        BUG_ON(!kernel_locked());
 
        pr_debug("uart_close(%d) called\n", uport->line);
 
        mutex_lock(&port->mutex);
+       spin_lock_irqsave(&port->lock, flags);
 
-       if (tty_hung_up_p(filp))
+       if (tty_hung_up_p(filp)) {
+               spin_unlock_irqrestore(&port->lock, flags);
                goto done;
+       }
 
        if ((tty->count == 1) && (port->count != 1)) {
                /*
                       tty->name, port->count);
                port->count = 0;
        }
-       if (port->count)
+       if (port->count) {
+               spin_unlock_irqrestore(&port->lock, flags);
                goto done;
+       }
 
        /*
         * Now we wait for the transmit buffer to clear; and we notify
         * setting tty->closing.
         */
        tty->closing = 1;
+       spin_unlock_irqrestore(&port->lock, flags);
 
        if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
                tty_wait_until_sent(tty, msecs_to_jiffies(port->closing_wait));
 
        tty_ldisc_flush(tty);
 
-       tty->closing = 0;
        tty_port_tty_set(port, NULL);
+       spin_lock_irqsave(&port->lock, flags);
+       tty->closing = 0;
 
        if (port->blocked_open) {
+               spin_unlock_irqrestore(&port->lock, flags);
                if (port->close_delay)
                        msleep_interruptible(port->close_delay);
+               spin_lock_irqsave(&port->lock, flags);
        } else if (!uart_console(uport)) {
+               spin_unlock_irqrestore(&port->lock, flags);
                uart_change_pm(state, 3);
+               spin_lock_irqsave(&port->lock, flags);
        }
 
        /*
         * Wake up anyone trying to open this port.
         */
        clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
+       spin_unlock_irqrestore(&port->lock, flags);
        wake_up_interruptible(&port->open_wait);
 
 done:
 {
        struct uart_state *state = tty->driver_data;
        struct tty_port *port = &state->port;
+       unsigned long flags;
 
        BUG_ON(!kernel_locked());
        pr_debug("uart_hangup(%d)\n", state->uart_port->line);
        if (port->flags & ASYNC_NORMAL_ACTIVE) {
                uart_flush_buffer(tty);
                uart_shutdown(tty, state);
+               spin_lock_irqsave(&port->lock, flags);
                port->count = 0;
                clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
+               spin_unlock_irqrestore(&port->lock, flags);
                tty_port_tty_set(port, NULL);
                wake_up_interruptible(&port->open_wait);
                wake_up_interruptible(&port->delta_msr_wait);
        struct uart_port *uport = state->uart_port;
        struct tty_port *port = &state->port;
        unsigned int mctrl;
+       unsigned long flags;
 
+       spin_lock_irqsave(&port->lock, flags);
+       if (!tty_hung_up_p(filp))
+               port->count--;
        port->blocked_open++;
-       port->count--;
+       spin_unlock_irqrestore(&port->lock, flags);
 
        add_wait_queue(&port->open_wait, &wait);
        while (1) {
                 * not set RTS here - we want to make sure we catch
                 * the data from the modem.
                 */
-               if (port->tty->termios->c_cflag & CBAUD)
+               if (port->tty->termios->c_cflag & CBAUD) {
+                       mutex_lock(&port->mutex);
                        uart_set_mctrl(uport, TIOCM_DTR);
+                       mutex_unlock(&port->mutex);
+               }
 
                /*
                 * and wait for the carrier to indicate that the
                 * modem is ready for us.
                 */
+               mutex_lock(&port->mutex);
                spin_lock_irq(&uport->lock);
                uport->ops->enable_ms(uport);
                mctrl = uport->ops->get_mctrl(uport);
                spin_unlock_irq(&uport->lock);
+               mutex_unlock(&port->mutex);
                if (mctrl & TIOCM_CAR)
                        break;
 
-               mutex_unlock(&port->mutex);
                schedule();
-               mutex_lock(&port->mutex);
 
                if (signal_pending(current))
                        break;
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&port->open_wait, &wait);
 
-       port->count++;
+       spin_lock_irqsave(&port->lock, flags);
+       if (!tty_hung_up_p(filp))
+               port->count++;
        port->blocked_open--;
+       spin_unlock_irqrestore(&port->lock, flags);
 
        if (signal_pending(current))
                return -ERESTARTSYS;
        /*
         * If we succeeded, wait until the port is ready.
         */
+       mutex_unlock(&port->mutex);
        if (retval == 0)
                retval = uart_block_til_ready(filp, state);
-       mutex_unlock(&port->mutex);
 
        /*
         * If this is the first open to succeed, adjust things to suit.