[PATCH 2/8] tty: Replace ASYNC_CTS_FLOW bit and update atomically

2016-04-09 Thread Peter Hurley
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 
---
 drivers/char/pcmcia/synclink_cs.c  |  5 +
 drivers/tty/amiserial.c|  6 ++
 drivers/tty/cyclades.c | 10 --
 drivers/tty/isicom.c   |  6 ++
 drivers/tty/mxser.c|  4 +---
 drivers/tty/synclink.c |  7 ++-
 drivers/tty/synclink_gt.c  |  5 +
 drivers/tty/synclinkmp.c   |  5 +
 include/linux/tty.h| 12 ++--
 net/irda/ircomm/ircomm_tty_ioctl.c |  3 +--
 10 files changed, 25 insertions(+), 38 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c 
b/drivers/char/pcmcia/synclink_cs.c
index bcae5bb..bdf41ac 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -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(>port, cflag & CRTSCTS);
 
if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index e68208e..92717b0 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -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 {
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index d67e542..1a12776 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -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(>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(>port, 0);
 
/* XON/XOFF/XANY flow control flags */
sw_flow = 0;
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index 8bf6763..c5f06b5 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -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, C_CRTSCTS(tty));
+   if (C_CRTSCTS(tty))
flow_ctrl |= ISICOM_CTSRTS;
-   }
if (I_IXON(tty))
flow_ctrl |= ISICOM_RESPOND_XONXOFF;
if (I_IXOFF(tty))
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index f23c2a1..8f3fdad 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -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(>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 {
-   

[PATCH 2/8] tty: Replace ASYNC_CTS_FLOW bit and update atomically

2016-04-09 Thread Peter Hurley
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 
---
 drivers/char/pcmcia/synclink_cs.c  |  5 +
 drivers/tty/amiserial.c|  6 ++
 drivers/tty/cyclades.c | 10 --
 drivers/tty/isicom.c   |  6 ++
 drivers/tty/mxser.c|  4 +---
 drivers/tty/synclink.c |  7 ++-
 drivers/tty/synclink_gt.c  |  5 +
 drivers/tty/synclinkmp.c   |  5 +
 include/linux/tty.h| 12 ++--
 net/irda/ircomm/ircomm_tty_ioctl.c |  3 +--
 10 files changed, 25 insertions(+), 38 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c 
b/drivers/char/pcmcia/synclink_cs.c
index bcae5bb..bdf41ac 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -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(>port, cflag & CRTSCTS);
 
if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index e68208e..92717b0 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -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 {
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index d67e542..1a12776 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -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(>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(>port, 0);
 
/* XON/XOFF/XANY flow control flags */
sw_flow = 0;
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index 8bf6763..c5f06b5 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -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, C_CRTSCTS(tty));
+   if (C_CRTSCTS(tty))
flow_ctrl |= ISICOM_CTSRTS;
-   }
if (I_IXON(tty))
flow_ctrl |= ISICOM_RESPOND_XONXOFF;
if (I_IXOFF(tty))
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index f23c2a1..8f3fdad 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -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(>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 &=