tty: Replace TTY_THROTTLED bit tests with tty_throttled()
authorPeter Hurley <peter@hurleysoftware.com>
Sun, 10 Apr 2016 00:11:36 +0000 (17:11 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Apr 2016 16:26:55 +0000 (09:26 -0700)
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>
21 files changed:
drivers/char/pcmcia/synclink_cs.c
drivers/mmc/card/sdio_uart.c
drivers/net/usb/hso.c
drivers/staging/fwserial/fwserial.c
drivers/staging/speakup/selection.c
drivers/tty/amiserial.c
drivers/tty/hvc/hvc_console.c
drivers/tty/hvc/hvcs.c
drivers/tty/hvc/hvsi.c
drivers/tty/moxa.c
drivers/tty/nozomi.c
drivers/tty/serial/serial_core.c
drivers/tty/synclink.c
drivers/tty/synclink_gt.c
drivers/tty/synclinkmp.c
drivers/tty/tty_ioctl.c
drivers/tty/vt/selection.c
drivers/usb/gadget/function/u_serial.c
drivers/usb/serial/digi_acceleport.c
include/linux/tty.h
net/irda/ircomm/ircomm_tty_ioctl.c

index 825db423b7a86ed396aae7f4d900c58c2b9d69eb..bcae5bb15751daabd08f4a75992ce500bc977348 100644 (file)
@@ -2316,7 +2316,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term
        /* 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);
index 5415056f9aa5b109c67a075fa2fd3bfd7a335acf..5af6fb9a9ce2e56cf78ce3f3629aee6a63f0f6a1 100644 (file)
@@ -895,7 +895,7 @@ static void sdio_uart_set_termios(struct tty_struct *tty,
        /* 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);
        }
index 111d907e0c117e8f8efb4b6c3b50607994f6c7b9..4b4458616693f9294e1150da8db351163c29aa9b 100644 (file)
@@ -2029,7 +2029,7 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
 
        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;
        }
index 9b23b5c95f5e80a840d01c563cf25539ff670448..1f9389d8c15234a300d222bdb68868e10de0f9c4 100644 (file)
@@ -1305,7 +1305,7 @@ static void fwtty_set_termios(struct tty_struct *tty, struct ktermios *old)
        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;
index 41ef099b7aa69f345d33998c46e2bce11ad691d9..0149edc1e0aef63b5a690654e6099d301301a93e 100644 (file)
@@ -150,7 +150,7 @@ static void __speakup_paste_selection(struct work_struct *work)
        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;
                }
index 183e98e84d09fb5546a29ca386b976ba692945ee..e68208eac32266da430304ea5d0779fc95ab84c3 100644 (file)
@@ -1342,7 +1342,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
        /* 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);
index e46d628998f5cffb9b4be2366c635f0d9ced1b77..209dad8c96a0cdfa4bc675a7558b6b77a6f892c0 100644 (file)
@@ -632,7 +632,7 @@ int hvc_poll(struct hvc_struct *hp)
                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
index 5997b17311113150b93167aaaa4b1e37bb160cb3..3c4d7c2b4ade876a06a7bd5939638302178cf39f 100644 (file)
@@ -600,7 +600,7 @@ static int hvcs_io(struct hvcs_struct *hvcsd)
 
        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)))
index a75146f600cb7c4b98f6c4b5cad18093c4bbc209..96ce6bd1cc6f699260b5b9613487d352cab57c08 100644 (file)
@@ -509,7 +509,7 @@ static irqreturn_t hvsi_interrupt(int irq, void *arg)
        }
 
        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);
index 92982d7c04894f28401f7c8bd07697f49360be5d..ce521d3f58cb1ffdb865c23832c20a60dfb6b9c1 100644 (file)
@@ -1394,7 +1394,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
                        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);
index 5cc80b80c82b6cb0a90d6887d188510d60e228f5..d6fd0e802ef512732951bc6e8eaca099ce7bfc1d 100644 (file)
@@ -826,7 +826,7 @@ static int receive_data(enum port_type index, struct nozomi *dc)
        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");
 
index 67b395031347c07abdc956ad99e3f851625e1e04..64a5c00d74683e4cab3452f1bdbf6fd76cdd4393 100644 (file)
@@ -1350,7 +1350,7 @@ static void uart_set_termios(struct tty_struct *tty,
        /* 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);
        }
index 8b2277223ee79e43e6b80c2c34ab90d891fff523..3768e5c71c0bcdad2975051bcca3c024d7f404c6 100644 (file)
@@ -3049,7 +3049,7 @@ static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termio
        /* 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);
index 1f7d6d9437e64c601390f5fbfa6e2889ef3f5fab..ceeaeb703f51186901834d585d4613904dbf61e8 100644 (file)
@@ -784,7 +784,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
        /* 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);
index e938799449053fdd7044c5177dd39bb2029b24e2..b0cce4b24e51c316dcdea2faf01500a6d6b06499 100644 (file)
@@ -881,7 +881,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
        /* 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);
index 23bf5bb1d8bf74d01ea0a29b5ddb1e095e1855db..bf36ac9aee41cdb7aa1172e65c55d5bd5e20beda 100644 (file)
@@ -158,7 +158,7 @@ int tty_throttle_safe(struct tty_struct *tty)
        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 {
@@ -189,7 +189,7 @@ int tty_unthrottle_safe(struct tty_struct *tty)
        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 {
index 4dd9dd2270a01d31ded104bd789883b3bb356c3d..368ce1803e8f229e3cfc0be9ddd405d52b34e6f1 100644 (file)
@@ -354,7 +354,7 @@ int paste_selection(struct tty_struct *tty)
        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;
                }
index 6af145f2a99dda265bd87021f3d50f6d38611140..3580f198df8b4d49a0f817aeaae3ef4e49a9a720 100644 (file)
@@ -512,7 +512,7 @@ static void gs_rx_push(unsigned long _port)
                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) {
@@ -579,7 +579,7 @@ static void gs_rx_push(unsigned long _port)
         * 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
index 16e8e37b3b36d521749ec48d17b2becfc4ae4f51..6a1df9e824ca2bc9fedaa2d32dea0bb5361b0b53 100644 (file)
@@ -699,8 +699,7 @@ static void digi_set_termios(struct tty_struct *tty,
                        /* 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);
                }
index 68d829bf93b8883fc2fe56dab666b842bb1ef9ef..89f9c91b40f54bedbfdd862580bcbd0c3fa43827 100644 (file)
@@ -365,6 +365,11 @@ static inline bool tty_io_error(struct tty_struct *tty)
        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);
index 9beb011441fa644e67e2a7a2aa0fcbc12a329977..8d8fd28ff4d94d155032e4f764f58cfc1720dbcc 100644 (file)
@@ -166,7 +166,7 @@ void ircomm_tty_set_termios(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);
        }