[PATCH 4/8] tty: Replace ASYNC_CHECK_CD and update atomically

2016-04-09 Thread Peter Hurley
Replace ASYNC_CHECK_CD bit in the tty_port::flags field with
TTY_PORT_CHECK_CD bit in the tty_port::iflags field. Introduce helpers
tty_port_set_check_carrier() and tty_port_check_carrier() to abstract
the atomic bit ops.

Signed-off-by: Peter Hurley 
---
 drivers/char/pcmcia/synclink_cs.c   |  8 ++--
 drivers/isdn/i4l/isdn_tty.c |  8 ++--
 drivers/tty/amiserial.c |  9 +++--
 drivers/tty/cyclades.c  | 14 --
 drivers/tty/isicom.c|  7 ++-
 drivers/tty/mxser.c |  9 +++--
 drivers/tty/synclink.c  |  8 ++--
 drivers/tty/synclink_gt.c   |  8 ++--
 drivers/tty/synclinkmp.c|  8 ++--
 include/linux/tty.h | 13 +
 net/irda/ircomm/ircomm_tty.c|  4 ++--
 net/irda/ircomm/ircomm_tty_attach.c |  2 +-
 net/irda/ircomm/ircomm_tty_ioctl.c  |  5 +
 13 files changed, 39 insertions(+), 64 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c 
b/drivers/char/pcmcia/synclink_cs.c
index bdf41ac..bf54f4e 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -1101,7 +1101,7 @@ static void dcd_change(MGSLPC_INFO *info, struct 
tty_struct *tty)
wake_up_interruptible(>status_event_wait_q);
wake_up_interruptible(>event_wait_q);
 
-   if (info->port.flags & ASYNC_CHECK_CD) {
+   if (tty_port_check_carrier(>port)) {
if (debug_level >= DEBUG_LEVEL_ISR)
printk("%s CD now %s...", info->device_name,
   (info->serial_signals & SerialSignal_DCD) ? "on" 
: "off");
@@ -1467,11 +1467,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info, 
struct tty_struct *tty)
info->timeout += HZ/50; /* Add .02 seconds of slop */
 
tty_port_set_cts_flow(>port, cflag & CRTSCTS);
-
-   if (cflag & CLOCAL)
-   info->port.flags &= ~ASYNC_CHECK_CD;
-   else
-   info->port.flags |= ASYNC_CHECK_CD;
+   tty_port_set_check_carrier(>port, ~cflag & CLOCAL);
 
/* process tty input control flags */
 
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index d8468f3..023a350a 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1043,11 +1043,7 @@ isdn_tty_change_speed(modem_info *info)
if (!(cflag & PARODD))
cval |= UART_LCR_EPAR;
 
-   if (cflag & CLOCAL)
-   port->flags &= ~ASYNC_CHECK_CD;
-   else {
-   port->flags |= ASYNC_CHECK_CD;
-   }
+   tty_port_set_check_carrier(port, ~cflag & CLOCAL);
 }
 
 static int
@@ -2526,7 +2522,7 @@ isdn_tty_modem_result(int code, modem_info *info)
if (info->closing || (!info->port.tty))
return;
 
-   if (info->port.flags & ASYNC_CHECK_CD)
+   if (tty_port_check_carrier(>port))
tty_hangup(info->port.tty);
}
 }
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 80d6165..b4ab97d 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -398,7 +398,7 @@ static void check_modem_status(struct serial_state *info)
wake_up_interruptible(>delta_msr_wait);
}
 
-   if ((port->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
+   if (tty_port_check_carrier(port) && (dstatus & SER_DCD)) {
 #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
printk("ttyS%d CD now %s...", info->line,
   (!(status & SER_DCD)) ? "on" : "off");
@@ -730,12 +730,9 @@ static void change_speed(struct tty_struct *tty, struct 
serial_state *info,
tty_port_set_cts_flow(port, cflag & CRTSCTS);
if (cflag & CRTSCTS)
info->IER |= UART_IER_MSI;
-   if (cflag & CLOCAL)
-   port->flags &= ~ASYNC_CHECK_CD;
-   else {
-   port->flags |= ASYNC_CHECK_CD;
+   tty_port_set_check_carrier(port, ~cflag & CLOCAL);
+   if (~cflag & CLOCAL)
info->IER |= UART_IER_MSI;
-   }
/* TBD:
 * Does clearing IER_MSI imply that we should disable the VBL interrupt 
?
 */
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 1a12776..9d1e19b 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -714,7 +714,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int 
chip,
wake_up_interruptible(>port.delta_msr_wait);
}
 
-   if ((mdm_change & CyDCD) && (info->port.flags & ASYNC_CHECK_CD)) {
+   if ((mdm_change & CyDCD) && tty_port_check_carrier(>port)) {
if (mdm_status & CyDCD)
wake_up_interruptible(>port.open_wait);
else
@@ -1119,7 +1119,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
case C_CM_MDCD:

[PATCH 4/8] tty: Replace ASYNC_CHECK_CD and update atomically

2016-04-09 Thread Peter Hurley
Replace ASYNC_CHECK_CD bit in the tty_port::flags field with
TTY_PORT_CHECK_CD bit in the tty_port::iflags field. Introduce helpers
tty_port_set_check_carrier() and tty_port_check_carrier() to abstract
the atomic bit ops.

Signed-off-by: Peter Hurley 
---
 drivers/char/pcmcia/synclink_cs.c   |  8 ++--
 drivers/isdn/i4l/isdn_tty.c |  8 ++--
 drivers/tty/amiserial.c |  9 +++--
 drivers/tty/cyclades.c  | 14 --
 drivers/tty/isicom.c|  7 ++-
 drivers/tty/mxser.c |  9 +++--
 drivers/tty/synclink.c  |  8 ++--
 drivers/tty/synclink_gt.c   |  8 ++--
 drivers/tty/synclinkmp.c|  8 ++--
 include/linux/tty.h | 13 +
 net/irda/ircomm/ircomm_tty.c|  4 ++--
 net/irda/ircomm/ircomm_tty_attach.c |  2 +-
 net/irda/ircomm/ircomm_tty_ioctl.c  |  5 +
 13 files changed, 39 insertions(+), 64 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c 
b/drivers/char/pcmcia/synclink_cs.c
index bdf41ac..bf54f4e 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -1101,7 +1101,7 @@ static void dcd_change(MGSLPC_INFO *info, struct 
tty_struct *tty)
wake_up_interruptible(>status_event_wait_q);
wake_up_interruptible(>event_wait_q);
 
-   if (info->port.flags & ASYNC_CHECK_CD) {
+   if (tty_port_check_carrier(>port)) {
if (debug_level >= DEBUG_LEVEL_ISR)
printk("%s CD now %s...", info->device_name,
   (info->serial_signals & SerialSignal_DCD) ? "on" 
: "off");
@@ -1467,11 +1467,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info, 
struct tty_struct *tty)
info->timeout += HZ/50; /* Add .02 seconds of slop */
 
tty_port_set_cts_flow(>port, cflag & CRTSCTS);
-
-   if (cflag & CLOCAL)
-   info->port.flags &= ~ASYNC_CHECK_CD;
-   else
-   info->port.flags |= ASYNC_CHECK_CD;
+   tty_port_set_check_carrier(>port, ~cflag & CLOCAL);
 
/* process tty input control flags */
 
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index d8468f3..023a350a 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1043,11 +1043,7 @@ isdn_tty_change_speed(modem_info *info)
if (!(cflag & PARODD))
cval |= UART_LCR_EPAR;
 
-   if (cflag & CLOCAL)
-   port->flags &= ~ASYNC_CHECK_CD;
-   else {
-   port->flags |= ASYNC_CHECK_CD;
-   }
+   tty_port_set_check_carrier(port, ~cflag & CLOCAL);
 }
 
 static int
@@ -2526,7 +2522,7 @@ isdn_tty_modem_result(int code, modem_info *info)
if (info->closing || (!info->port.tty))
return;
 
-   if (info->port.flags & ASYNC_CHECK_CD)
+   if (tty_port_check_carrier(>port))
tty_hangup(info->port.tty);
}
 }
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 80d6165..b4ab97d 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -398,7 +398,7 @@ static void check_modem_status(struct serial_state *info)
wake_up_interruptible(>delta_msr_wait);
}
 
-   if ((port->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
+   if (tty_port_check_carrier(port) && (dstatus & SER_DCD)) {
 #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
printk("ttyS%d CD now %s...", info->line,
   (!(status & SER_DCD)) ? "on" : "off");
@@ -730,12 +730,9 @@ static void change_speed(struct tty_struct *tty, struct 
serial_state *info,
tty_port_set_cts_flow(port, cflag & CRTSCTS);
if (cflag & CRTSCTS)
info->IER |= UART_IER_MSI;
-   if (cflag & CLOCAL)
-   port->flags &= ~ASYNC_CHECK_CD;
-   else {
-   port->flags |= ASYNC_CHECK_CD;
+   tty_port_set_check_carrier(port, ~cflag & CLOCAL);
+   if (~cflag & CLOCAL)
info->IER |= UART_IER_MSI;
-   }
/* TBD:
 * Does clearing IER_MSI imply that we should disable the VBL interrupt 
?
 */
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 1a12776..9d1e19b 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -714,7 +714,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int 
chip,
wake_up_interruptible(>port.delta_msr_wait);
}
 
-   if ((mdm_change & CyDCD) && (info->port.flags & ASYNC_CHECK_CD)) {
+   if ((mdm_change & CyDCD) && tty_port_check_carrier(>port)) {
if (mdm_status & CyDCD)
wake_up_interruptible(>port.open_wait);
else
@@ -1119,7 +1119,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
case C_CM_MDCD:
info->icount.dcd++;