tty: Replace ASYNC_CTS_FLOW bit and update atomically
authorPeter Hurley <peter@hurleysoftware.com>
Sun, 10 Apr 2016 00:53:21 +0000 (17:53 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Apr 2016 16:26:55 +0000 (09:26 -0700)
Replace ASYNC_CTS_FLOW bit in the tty_port::flags field with
TTY_PORT_CTS_FLOW bit in the tty_port::iflags field. Add
tty_port_set_cts_flow() helper to abstract the atomic bit ops.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/pcmcia/synclink_cs.c
drivers/tty/amiserial.c
drivers/tty/cyclades.c
drivers/tty/isicom.c
drivers/tty/mxser.c
drivers/tty/synclink.c
drivers/tty/synclink_gt.c
drivers/tty/synclinkmp.c
include/linux/tty.h
net/irda/ircomm/ircomm_tty_ioctl.c

index bcae5bb15751daabd08f4a75992ce500bc977348..bdf41ac613dcafc07ede732f1f5a96bfe73addeb 100644 (file)
@@ -1466,10 +1466,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty)
        }
        info->timeout += HZ/50;         /* Add .02 seconds of slop */
 
-       if (cflag & CRTSCTS)
-               info->port.flags |= ASYNC_CTS_FLOW;
-       else
-               info->port.flags &= ~ASYNC_CTS_FLOW;
+       tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
 
        if (cflag & CLOCAL)
                info->port.flags &= ~ASYNC_CHECK_CD;
index e68208eac32266da430304ea5d0779fc95ab84c3..92717b088959a7082d965dcb290608383dc6c849 100644 (file)
@@ -727,11 +727,9 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
        info->IER &= ~UART_IER_MSI;
        if (port->flags & ASYNC_HARDPPS_CD)
                info->IER |= UART_IER_MSI;
-       if (cflag & CRTSCTS) {
-               port->flags |= ASYNC_CTS_FLOW;
+       tty_port_set_cts_flow(port, cflag & CRTSCTS);
+       if (cflag & CRTSCTS)
                info->IER |= UART_IER_MSI;
-       } else
-               port->flags &= ~ASYNC_CTS_FLOW;
        if (cflag & CLOCAL)
                port->flags &= ~ASYNC_CHECK_CD;
        else {
index d67e542bab1cee0a43f9b83342e99fe03e83f8d0..1a12776ba24c03d14a4a3ae8d47acaa53cd27e56 100644 (file)
@@ -2083,13 +2083,11 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
                        info->cor1 |= CyPARITY_NONE;
 
                /* CTS flow control flag */
-               if (cflag & CRTSCTS) {
-                       info->port.flags |= ASYNC_CTS_FLOW;
+               tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
+               if (cflag & CRTSCTS)
                        info->cor2 |= CyCtsAE;
-               } else {
-                       info->port.flags &= ~ASYNC_CTS_FLOW;
+               else
                        info->cor2 &= ~CyCtsAE;
-               }
                if (cflag & CLOCAL)
                        info->port.flags &= ~ASYNC_CHECK_CD;
                else
@@ -2234,7 +2232,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
                }
                /* As the HW flow control is done in firmware, the driver
                   doesn't need to care about it */
-               info->port.flags &= ~ASYNC_CTS_FLOW;
+               tty_port_set_cts_flow(&info->port, 0);
 
                /* XON/XOFF/XANY flow control flags */
                sw_flow = 0;
index 8bf67630018b8292e5f265f58f217121bbe64df4..c5f06b54b9ca8caf323c0a2f429b762e9f8c91d8 100644 (file)
@@ -765,11 +765,9 @@ static void isicom_config_port(struct tty_struct *tty)
 
        /* flow control settings ...*/
        flow_ctrl = 0;
-       port->port.flags &= ~ASYNC_CTS_FLOW;
-       if (C_CRTSCTS(tty)) {
-               port->port.flags |= ASYNC_CTS_FLOW;
+       tty_port_set_cts_flow(&port->port, C_CRTSCTS(tty));
+       if (C_CRTSCTS(tty))
                flow_ctrl |= ISICOM_CTSRTS;
-       }
        if (I_IXON(tty))
                flow_ctrl |= ISICOM_RESPOND_XONXOFF;
        if (I_IXOFF(tty))
index f23c2a101688c344ba20b23ae48523782e09f58b..8f3fdad37ac7626b78a987b6897c4eb131dbacf5 100644 (file)
@@ -711,8 +711,8 @@ static int mxser_change_speed(struct tty_struct *tty,
        /* CTS flow control flag and modem status interrupts */
        info->IER &= ~UART_IER_MSI;
        info->MCR &= ~UART_MCR_AFE;
+       tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
        if (cflag & CRTSCTS) {
-               info->port.flags |= ASYNC_CTS_FLOW;
                info->IER |= UART_IER_MSI;
                if ((info->type == PORT_16550A) || (info->board->chip_flag)) {
                        info->MCR |= UART_MCR_AFE;
@@ -744,8 +744,6 @@ static int mxser_change_speed(struct tty_struct *tty,
                                }
                        }
                }
-       } else {
-               info->port.flags &= ~ASYNC_CTS_FLOW;
        }
        outb(info->MCR, info->ioaddr + UART_MCR);
        if (cflag & CLOCAL) {
index 3768e5c71c0bcdad2975051bcca3c024d7f404c6..0e42901832806289c5913ded29773d1c7ddd012f 100644 (file)
@@ -1966,11 +1966,8 @@ static void mgsl_change_params(struct mgsl_struct *info)
        }
        info->timeout += HZ/50;         /* Add .02 seconds of slop */
 
-       if (cflag & CRTSCTS)
-               info->port.flags |= ASYNC_CTS_FLOW;
-       else
-               info->port.flags &= ~ASYNC_CTS_FLOW;
-               
+       tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
+
        if (cflag & CLOCAL)
                info->port.flags &= ~ASYNC_CHECK_CD;
        else
index ceeaeb703f51186901834d585d4613904dbf61e8..5da69d30f816154f059e4bb138d28419930237d6 100644 (file)
@@ -2576,10 +2576,7 @@ static void change_params(struct slgt_info *info)
        }
        info->timeout += HZ/50;         /* Add .02 seconds of slop */
 
-       if (cflag & CRTSCTS)
-               info->port.flags |= ASYNC_CTS_FLOW;
-       else
-               info->port.flags &= ~ASYNC_CTS_FLOW;
+       tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
 
        if (cflag & CLOCAL)
                info->port.flags &= ~ASYNC_CHECK_CD;
index b0cce4b24e51c316dcdea2faf01500a6d6b06499..7a21491d0c0d23d9349dea30ce446a90af865e13 100644 (file)
@@ -2813,10 +2813,7 @@ static void change_params(SLMP_INFO *info)
        }
        info->timeout += HZ/50;         /* Add .02 seconds of slop */
 
-       if (cflag & CRTSCTS)
-               info->port.flags |= ASYNC_CTS_FLOW;
-       else
-               info->port.flags &= ~ASYNC_CTS_FLOW;
+       tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
 
        if (cflag & CLOCAL)
                info->port.flags &= ~ASYNC_CHECK_CD;
index 4e0dbda051807d9ceef174102678308d750b092a..989d755b0ae434256eed42dccac45f597b277217 100644 (file)
@@ -255,7 +255,6 @@ struct tty_port {
 #define TTY_PORT_CTS_FLOW      3       /* h/w flow control enabled */
 #define TTY_PORT_CHECK_CD      4       /* carrier detect enabled */
 
-
 /*
  * Where all of the state associated with a tty is kept while the tty
  * is open.  Since the termios state should be kept even if the tty
@@ -561,9 +560,18 @@ static inline struct tty_port *tty_port_get(struct tty_port *port)
 /* If the cts flow control is enabled, return true. */
 static inline bool tty_port_cts_enabled(struct tty_port *port)
 {
-       return port->flags & ASYNC_CTS_FLOW;
+       return test_bit(TTY_PORT_CTS_FLOW, &port->iflags);
 }
 
+static inline void tty_port_set_cts_flow(struct tty_port *port, bool val)
+{
+       if (val)
+               set_bit(TTY_PORT_CTS_FLOW, &port->iflags);
+       else
+               clear_bit(TTY_PORT_CTS_FLOW, &port->iflags);
+}
+
+
 extern struct tty_struct *tty_port_tty_get(struct tty_port *port);
 extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
 extern int tty_port_carrier_raised(struct tty_port *port);
index 8d8fd28ff4d94d155032e4f764f58cfc1720dbcc..1220973c7c43017512cad843b314464e69dc75f0 100644 (file)
@@ -86,15 +86,14 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self,
        ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE);
 
        /* CTS flow control flag and modem status interrupts */
+       tty_port_set_cts_flow(&self->port, cflag & CRTSCTS);
        if (cflag & CRTSCTS) {
-               self->port.flags |= ASYNC_CTS_FLOW;
                self->settings.flow_control |= IRCOMM_RTS_CTS_IN;
                /* This got me. Bummer. Jean II */
                if (self->service_type == IRCOMM_3_WIRE_RAW)
                        net_warn_ratelimited("%s(), enabling RTS/CTS on link that doesn't support it (3-wire-raw)\n",
                                             __func__);
        } else {
-               self->port.flags &= ~ASYNC_CTS_FLOW;
                self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN;
        }
        if (cflag & CLOCAL)