Abstract TTY_THROTTLED bit tests with tty_throttled().
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
                info->serial_signals |= SerialSignal_DTR;
-               if (!C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (!C_CRTSCTS(tty) || !tty_throttled(tty))
                        info->serial_signals |= SerialSignal_RTS;
                spin_lock_irqsave(&info->lock, flags);
                set_signals(info);
 
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
                unsigned int mask = TIOCM_DTR;
-               if (!(cflag & CRTSCTS) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (!(cflag & CRTSCTS) || !tty_throttled(tty))
                        mask |= TIOCM_RTS;
                sdio_uart_set_mctrl(port, mask);
        }
 
 
        tty = tty_port_tty_get(&serial->port);
 
-       if (tty && test_bit(TTY_THROTTLED, &tty->flags)) {
+       if (tty && tty_throttled(tty)) {
                tty_kref_put(tty);
                return -1;
        }
 
        if ((baud == 0) && (old->c_cflag & CBAUD)) {
                port->mctrl &= ~(TIOCM_DTR | TIOCM_RTS);
        } else if ((baud != 0) && !(old->c_cflag & CBAUD)) {
-               if (C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (C_CRTSCTS(tty) || !tty_throttled(tty))
                        port->mctrl |= TIOCM_DTR | TIOCM_RTS;
                else
                        port->mctrl |= TIOCM_DTR;
 
        add_wait_queue(&vc->paste_wait, &wait);
        while (sel_buffer && sel_buffer_lth > pasted) {
                set_current_state(TASK_INTERRUPTIBLE);
-               if (test_bit(TTY_THROTTLED, &tty->flags)) {
+               if (tty_throttled(tty)) {
                        schedule();
                        continue;
                }
 
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
                info->MCR |= SER_DTR;
-               if (!C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (!C_CRTSCTS(tty) || !tty_throttled(tty))
                        info->MCR |= SER_RTS;
                local_irq_save(flags);
                rtsdtr_ctrl(info->MCR);
 
                goto bail;
 
        /* Now check if we can get data (are we throttled ?) */
-       if (test_bit(TTY_THROTTLED, &tty->flags))
+       if (tty_throttled(tty))
                goto throttled;
 
        /* If we aren't notifier driven and aren't throttled, we always
 
 
        hvcs_try_write(hvcsd);
 
-       if (!tty || test_bit(TTY_THROTTLED, &tty->flags)) {
+       if (!tty || tty_throttled(tty)) {
                hvcsd->todo_mask &= ~(HVCS_READ_MASK);
                goto bail;
        } else if (!(hvcsd->todo_mask & (HVCS_READ_MASK)))
 
        }
 
        spin_lock_irqsave(&hp->lock, flags);
-       if (tty && hp->n_throttle && !test_bit(TTY_THROTTLED, &tty->flags)) {
+       if (tty && hp->n_throttle && !tty_throttled(tty)) {
                /* we weren't hung up and we weren't throttled, so we can
                 * deliver the rest now */
                hvsi_send_overflow(hp);
 
                        tty_wakeup(tty);
                }
 
-               if (inited && !test_bit(TTY_THROTTLED, &tty->flags) &&
+               if (inited && !tty_throttled(tty) &&
                                MoxaPortRxQueue(p) > 0) { /* RX */
                        MoxaPortReadData(p);
                        tty_schedule_flip(&p->port);
 
        size = __le32_to_cpu(readl(addr));
        /*  DBG1( "%d bytes port: %d", size, index); */
 
-       if (tty && test_bit(TTY_THROTTLED, &tty->flags)) {
+       if (tty && tty_throttled(tty)) {
                DBG1("No room in tty, don't read data, don't ack interrupt, "
                        "disable interrupt");
 
 
        /* Handle transition away from B0 status */
        else if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
                unsigned int mask = TIOCM_DTR;
-               if (!(cflag & CRTSCTS) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (!(cflag & CRTSCTS) || !tty_throttled(tty))
                        mask |= TIOCM_RTS;
                uart_set_mctrl(uport, mask);
        }
 
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
                info->serial_signals |= SerialSignal_DTR;
-               if (!C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (!C_CRTSCTS(tty) || !tty_throttled(tty))
                        info->serial_signals |= SerialSignal_RTS;
                spin_lock_irqsave(&info->irq_spinlock,flags);
                usc_set_serial_signals(info);
 
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
                info->signals |= SerialSignal_DTR;
-               if (!C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (!C_CRTSCTS(tty) || !tty_throttled(tty))
                        info->signals |= SerialSignal_RTS;
                spin_lock_irqsave(&info->lock,flags);
                set_signals(info);
 
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
                info->serial_signals |= SerialSignal_DTR;
-               if (!C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (!C_CRTSCTS(tty) || !tty_throttled(tty))
                        info->serial_signals |= SerialSignal_RTS;
                spin_lock_irqsave(&info->lock,flags);
                set_signals(info);
 
        int ret = 0;
 
        mutex_lock(&tty->throttle_mutex);
-       if (!test_bit(TTY_THROTTLED, &tty->flags)) {
+       if (!tty_throttled(tty)) {
                if (tty->flow_change != TTY_THROTTLE_SAFE)
                        ret = 1;
                else {
        int ret = 0;
 
        mutex_lock(&tty->throttle_mutex);
-       if (test_bit(TTY_THROTTLED, &tty->flags)) {
+       if (tty_throttled(tty)) {
                if (tty->flow_change != TTY_UNTHROTTLE_SAFE)
                        ret = 1;
                else {
 
        add_wait_queue(&vc->paste_wait, &wait);
        while (sel_buffer && sel_buffer_lth > pasted) {
                set_current_state(TASK_INTERRUPTIBLE);
-               if (test_bit(TTY_THROTTLED, &tty->flags)) {
+               if (tty_throttled(tty)) {
                        schedule();
                        continue;
                }
 
                req = list_first_entry(queue, struct usb_request, list);
 
                /* leave data queued if tty was rx throttled */
-               if (tty && test_bit(TTY_THROTTLED, &tty->flags))
+               if (tty && tty_throttled(tty))
                        break;
 
                switch (req->status) {
         * from starving ... but it's not clear that case ever happens.
         */
        if (!list_empty(queue) && tty) {
-               if (!test_bit(TTY_THROTTLED, &tty->flags)) {
+               if (!tty_throttled(tty)) {
                        if (do_push)
                                tasklet_schedule(&port->push);
                        else
 
                        /* don't set RTS if using hardware flow control */
                        /* and throttling input */
                        modem_signals = TIOCM_DTR;
-                       if (!C_CRTSCTS(tty) ||
-                           !test_bit(TTY_THROTTLED, &tty->flags))
+                       if (!C_CRTSCTS(tty) || !tty_throttled(tty))
                                modem_signals |= TIOCM_RTS;
                        digi_set_modem_signals(port, modem_signals, 1);
                }
 
        return test_bit(TTY_IO_ERROR, &tty->flags);
 }
 
+static inline bool tty_throttled(struct tty_struct *tty)
+{
+       return test_bit(TTY_THROTTLED, &tty->flags);
+}
+
 #ifdef CONFIG_TTY
 extern void console_init(void);
 extern void tty_kref_put(struct tty_struct *tty);
 
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
                self->settings.dte |= IRCOMM_DTR;
-               if (!C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags))
+               if (!C_CRTSCTS(tty) || !tty_throttled(tty))
                        self->settings.dte |= IRCOMM_RTS;
                ircomm_param_request(self, IRCOMM_DTE, TRUE);
        }