Commit 2d68655d authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman

tty: Replace ASYNC_CHECK_CD and update atomically

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: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 807c8d81
...@@ -1101,7 +1101,7 @@ static void dcd_change(MGSLPC_INFO *info, struct tty_struct *tty) ...@@ -1101,7 +1101,7 @@ static void dcd_change(MGSLPC_INFO *info, struct tty_struct *tty)
wake_up_interruptible(&info->status_event_wait_q); wake_up_interruptible(&info->status_event_wait_q);
wake_up_interruptible(&info->event_wait_q); wake_up_interruptible(&info->event_wait_q);
if (info->port.flags & ASYNC_CHECK_CD) { if (tty_port_check_carrier(&info->port)) {
if (debug_level >= DEBUG_LEVEL_ISR) if (debug_level >= DEBUG_LEVEL_ISR)
printk("%s CD now %s...", info->device_name, printk("%s CD now %s...", info->device_name,
(info->serial_signals & SerialSignal_DCD) ? "on" : "off"); (info->serial_signals & SerialSignal_DCD) ? "on" : "off");
...@@ -1467,11 +1467,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty) ...@@ -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 */ info->timeout += HZ/50; /* Add .02 seconds of slop */
tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);
if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD;
else
info->port.flags |= ASYNC_CHECK_CD;
/* process tty input control flags */ /* process tty input control flags */
......
...@@ -1043,11 +1043,7 @@ isdn_tty_change_speed(modem_info *info) ...@@ -1043,11 +1043,7 @@ isdn_tty_change_speed(modem_info *info)
if (!(cflag & PARODD)) if (!(cflag & PARODD))
cval |= UART_LCR_EPAR; cval |= UART_LCR_EPAR;
if (cflag & CLOCAL) tty_port_set_check_carrier(port, ~cflag & CLOCAL);
port->flags &= ~ASYNC_CHECK_CD;
else {
port->flags |= ASYNC_CHECK_CD;
}
} }
static int static int
...@@ -2526,7 +2522,7 @@ isdn_tty_modem_result(int code, modem_info *info) ...@@ -2526,7 +2522,7 @@ isdn_tty_modem_result(int code, modem_info *info)
if (info->closing || (!info->port.tty)) if (info->closing || (!info->port.tty))
return; return;
if (info->port.flags & ASYNC_CHECK_CD) if (tty_port_check_carrier(&info->port))
tty_hangup(info->port.tty); tty_hangup(info->port.tty);
} }
} }
......
...@@ -398,7 +398,7 @@ static void check_modem_status(struct serial_state *info) ...@@ -398,7 +398,7 @@ static void check_modem_status(struct serial_state *info)
wake_up_interruptible(&port->delta_msr_wait); wake_up_interruptible(&port->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)) #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
printk("ttyS%d CD now %s...", info->line, printk("ttyS%d CD now %s...", info->line,
(!(status & SER_DCD)) ? "on" : "off"); (!(status & SER_DCD)) ? "on" : "off");
...@@ -730,12 +730,9 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info, ...@@ -730,12 +730,9 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
tty_port_set_cts_flow(port, cflag & CRTSCTS); tty_port_set_cts_flow(port, cflag & CRTSCTS);
if (cflag & CRTSCTS) if (cflag & CRTSCTS)
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
if (cflag & CLOCAL) tty_port_set_check_carrier(port, ~cflag & CLOCAL);
port->flags &= ~ASYNC_CHECK_CD; if (~cflag & CLOCAL)
else {
port->flags |= ASYNC_CHECK_CD;
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
}
/* TBD: /* TBD:
* Does clearing IER_MSI imply that we should disable the VBL interrupt ? * Does clearing IER_MSI imply that we should disable the VBL interrupt ?
*/ */
......
...@@ -714,7 +714,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip, ...@@ -714,7 +714,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
wake_up_interruptible(&info->port.delta_msr_wait); wake_up_interruptible(&info->port.delta_msr_wait);
} }
if ((mdm_change & CyDCD) && (info->port.flags & ASYNC_CHECK_CD)) { if ((mdm_change & CyDCD) && tty_port_check_carrier(&info->port)) {
if (mdm_status & CyDCD) if (mdm_status & CyDCD)
wake_up_interruptible(&info->port.open_wait); wake_up_interruptible(&info->port.open_wait);
else else
...@@ -1119,7 +1119,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) ...@@ -1119,7 +1119,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
case C_CM_MDCD: case C_CM_MDCD:
info->icount.dcd++; info->icount.dcd++;
delta_count++; delta_count++;
if (info->port.flags & ASYNC_CHECK_CD) { if (tty_port_check_carrier(&info->port)) {
u32 dcd = fw_ver > 241 ? param : u32 dcd = fw_ver > 241 ? param :
readl(&info->u.cyz.ch_ctrl->rs_status); readl(&info->u.cyz.ch_ctrl->rs_status);
if (dcd & C_RS_DCD) if (dcd & C_RS_DCD)
...@@ -2088,10 +2088,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty) ...@@ -2088,10 +2088,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
info->cor2 |= CyCtsAE; info->cor2 |= CyCtsAE;
else else
info->cor2 &= ~CyCtsAE; info->cor2 &= ~CyCtsAE;
if (cflag & CLOCAL) tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);
info->port.flags &= ~ASYNC_CHECK_CD;
else
info->port.flags |= ASYNC_CHECK_CD;
/*********************************************** /***********************************************
The hardware option, CyRtsAO, presents RTS when The hardware option, CyRtsAO, presents RTS when
...@@ -2250,10 +2247,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty) ...@@ -2250,10 +2247,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
} }
/* CD sensitivity */ /* CD sensitivity */
if (cflag & CLOCAL) tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);
info->port.flags &= ~ASYNC_CHECK_CD;
else
info->port.flags |= ASYNC_CHECK_CD;
if (baud == 0) { /* baud rate is zero, turn off line */ if (baud == 0) { /* baud rate is zero, turn off line */
cy_writel(&ch_ctrl->rs_control, cy_writel(&ch_ctrl->rs_control,
......
...@@ -577,7 +577,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) ...@@ -577,7 +577,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
header = inw(base); header = inw(base);
switch (header & 0xff) { switch (header & 0xff) {
case 0: /* Change in EIA signals */ case 0: /* Change in EIA signals */
if (port->port.flags & ASYNC_CHECK_CD) { if (tty_port_check_carrier(&port->port)) {
if (port->status & ISI_DCD) { if (port->status & ISI_DCD) {
if (!(header & ISI_DCD)) { if (!(header & ISI_DCD)) {
/* Carrier has been lost */ /* Carrier has been lost */
...@@ -758,10 +758,7 @@ static void isicom_config_port(struct tty_struct *tty) ...@@ -758,10 +758,7 @@ static void isicom_config_port(struct tty_struct *tty)
outw(channel_setup, base); outw(channel_setup, base);
InterruptTheCard(base); InterruptTheCard(base);
} }
if (C_CLOCAL(tty)) tty_port_set_check_carrier(&port->port, !C_CLOCAL(tty));
port->port.flags &= ~ASYNC_CHECK_CD;
else
port->port.flags |= ASYNC_CHECK_CD;
/* flow control settings ...*/ /* flow control settings ...*/
flow_ctrl = 0; flow_ctrl = 0;
......
...@@ -746,12 +746,9 @@ static int mxser_change_speed(struct tty_struct *tty, ...@@ -746,12 +746,9 @@ static int mxser_change_speed(struct tty_struct *tty,
} }
} }
outb(info->MCR, info->ioaddr + UART_MCR); outb(info->MCR, info->ioaddr + UART_MCR);
if (cflag & CLOCAL) { tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);
info->port.flags &= ~ASYNC_CHECK_CD; if (~cflag & CLOCAL)
} else {
info->port.flags |= ASYNC_CHECK_CD;
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
}
outb(info->IER, info->ioaddr + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
/* /*
...@@ -824,7 +821,7 @@ static void mxser_check_modem_status(struct tty_struct *tty, ...@@ -824,7 +821,7 @@ static void mxser_check_modem_status(struct tty_struct *tty,
port->mon_data.modem_status = status; port->mon_data.modem_status = status;
wake_up_interruptible(&port->port.delta_msr_wait); wake_up_interruptible(&port->port.delta_msr_wait);
if ((port->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { if (tty_port_check_carrier(&port->port) && (status & UART_MSR_DDCD)) {
if (status & UART_MSR_DCD) if (status & UART_MSR_DCD)
wake_up_interruptible(&port->port.open_wait); wake_up_interruptible(&port->port.open_wait);
} }
......
...@@ -1340,7 +1340,7 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info ) ...@@ -1340,7 +1340,7 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
wake_up_interruptible(&info->status_event_wait_q); wake_up_interruptible(&info->status_event_wait_q);
wake_up_interruptible(&info->event_wait_q); wake_up_interruptible(&info->event_wait_q);
if ( (info->port.flags & ASYNC_CHECK_CD) && if (tty_port_check_carrier(&info->port) &&
(status & MISCSTATUS_DCD_LATCHED) ) { (status & MISCSTATUS_DCD_LATCHED) ) {
if ( debug_level >= DEBUG_LEVEL_ISR ) if ( debug_level >= DEBUG_LEVEL_ISR )
printk("%s CD now %s...", info->device_name, printk("%s CD now %s...", info->device_name,
...@@ -1967,11 +1967,7 @@ static void mgsl_change_params(struct mgsl_struct *info) ...@@ -1967,11 +1967,7 @@ static void mgsl_change_params(struct mgsl_struct *info)
info->timeout += HZ/50; /* Add .02 seconds of slop */ info->timeout += HZ/50; /* Add .02 seconds of slop */
tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);
if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD;
else
info->port.flags |= ASYNC_CHECK_CD;
/* process tty input control flags */ /* process tty input control flags */
......
...@@ -2080,7 +2080,7 @@ static void dcd_change(struct slgt_info *info, unsigned short status) ...@@ -2080,7 +2080,7 @@ static void dcd_change(struct slgt_info *info, unsigned short status)
wake_up_interruptible(&info->event_wait_q); wake_up_interruptible(&info->event_wait_q);
info->pending_bh |= BH_STATUS; info->pending_bh |= BH_STATUS;
if (info->port.flags & ASYNC_CHECK_CD) { if (tty_port_check_carrier(&info->port)) {
if (info->signals & SerialSignal_DCD) if (info->signals & SerialSignal_DCD)
wake_up_interruptible(&info->port.open_wait); wake_up_interruptible(&info->port.open_wait);
else { else {
...@@ -2577,11 +2577,7 @@ static void change_params(struct slgt_info *info) ...@@ -2577,11 +2577,7 @@ static void change_params(struct slgt_info *info)
info->timeout += HZ/50; /* Add .02 seconds of slop */ info->timeout += HZ/50; /* Add .02 seconds of slop */
tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);
if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD;
else
info->port.flags |= ASYNC_CHECK_CD;
/* process tty input control flags */ /* process tty input control flags */
......
...@@ -2463,7 +2463,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status ) ...@@ -2463,7 +2463,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
wake_up_interruptible(&info->status_event_wait_q); wake_up_interruptible(&info->status_event_wait_q);
wake_up_interruptible(&info->event_wait_q); wake_up_interruptible(&info->event_wait_q);
if ( (info->port.flags & ASYNC_CHECK_CD) && if (tty_port_check_carrier(&info->port) &&
(status & MISCSTATUS_DCD_LATCHED) ) { (status & MISCSTATUS_DCD_LATCHED) ) {
if ( debug_level >= DEBUG_LEVEL_ISR ) if ( debug_level >= DEBUG_LEVEL_ISR )
printk("%s CD now %s...", info->device_name, printk("%s CD now %s...", info->device_name,
...@@ -2814,11 +2814,7 @@ static void change_params(SLMP_INFO *info) ...@@ -2814,11 +2814,7 @@ static void change_params(SLMP_INFO *info)
info->timeout += HZ/50; /* Add .02 seconds of slop */ info->timeout += HZ/50; /* Add .02 seconds of slop */
tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);
if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD;
else
info->port.flags |= ASYNC_CHECK_CD;
/* process tty input control flags */ /* process tty input control flags */
......
...@@ -584,6 +584,19 @@ static inline void tty_port_set_active(struct tty_port *port, bool val) ...@@ -584,6 +584,19 @@ static inline void tty_port_set_active(struct tty_port *port, bool val)
clear_bit(TTY_PORT_ACTIVE, &port->iflags); clear_bit(TTY_PORT_ACTIVE, &port->iflags);
} }
static inline bool tty_port_check_carrier(struct tty_port *port)
{
return test_bit(TTY_PORT_CHECK_CD, &port->iflags);
}
static inline void tty_port_set_check_carrier(struct tty_port *port, bool val)
{
if (val)
set_bit(TTY_PORT_CHECK_CD, &port->iflags);
else
clear_bit(TTY_PORT_CHECK_CD, &port->iflags);
}
extern struct tty_struct *tty_port_tty_get(struct tty_port *port); 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 void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
extern int tty_port_carrier_raised(struct tty_port *port); extern int tty_port_carrier_raised(struct tty_port *port);
......
...@@ -999,7 +999,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self) ...@@ -999,7 +999,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
if (status & IRCOMM_DCE_DELTA_ANY) { if (status & IRCOMM_DCE_DELTA_ANY) {
/*wake_up_interruptible(&self->delta_msr_wait);*/ /*wake_up_interruptible(&self->delta_msr_wait);*/
} }
if ((self->port.flags & ASYNC_CHECK_CD) && (status & IRCOMM_DELTA_CD)) { if (tty_port_check_carrier(&self->port) && (status & IRCOMM_DELTA_CD)) {
pr_debug("%s(), ircomm%d CD now %s...\n", __func__ , self->line, pr_debug("%s(), ircomm%d CD now %s...\n", __func__ , self->line,
(status & IRCOMM_CD) ? "on" : "off"); (status & IRCOMM_CD) ? "on" : "off");
...@@ -1255,7 +1255,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m) ...@@ -1255,7 +1255,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
seq_printf(m, "%cASYNC_CTS_FLOW", sep); seq_printf(m, "%cASYNC_CTS_FLOW", sep);
sep = '|'; sep = '|';
} }
if (self->port.flags & ASYNC_CHECK_CD) { if (tty_port_check_carrier(&self->port)) {
seq_printf(m, "%cASYNC_CHECK_CD", sep); seq_printf(m, "%cASYNC_CHECK_CD", sep);
sep = '|'; sep = '|';
} }
......
...@@ -968,7 +968,7 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, ...@@ -968,7 +968,7 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
ircomm_tty_start_watchdog_timer(self, 3*HZ); ircomm_tty_start_watchdog_timer(self, 3*HZ);
if (self->port.flags & ASYNC_CHECK_CD) { if (tty_port_check_carrier(&self->port)) {
/* Drop carrier */ /* Drop carrier */
self->settings.dce = IRCOMM_DELTA_CD; self->settings.dce = IRCOMM_DELTA_CD;
ircomm_tty_check_modem_status(self); ircomm_tty_check_modem_status(self);
......
...@@ -96,10 +96,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self, ...@@ -96,10 +96,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self,
} else { } else {
self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN; self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN;
} }
if (cflag & CLOCAL) tty_port_set_check_carrier(&self->port, ~cflag & CLOCAL);
self->port.flags &= ~ASYNC_CHECK_CD;
else
self->port.flags |= ASYNC_CHECK_CD;
#if 0 #if 0
/* /*
* Set up parity check flag * Set up parity check flag
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment