tty: Replace ASYNC_CTS_FLOW bit and update atomically

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>
This commit is contained in:
Peter Hurley 2016-04-09 17:53:21 -07:00 committed by Greg Kroah-Hartman
parent e4d38f334a
commit 5604a98e2f
10 changed files with 25 additions and 38 deletions

View 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 */ info->timeout += HZ/50; /* Add .02 seconds of slop */
if (cflag & CRTSCTS) tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
info->port.flags |= ASYNC_CTS_FLOW;
else
info->port.flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL) if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD; info->port.flags &= ~ASYNC_CHECK_CD;

View file

@ -727,11 +727,9 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
info->IER &= ~UART_IER_MSI; info->IER &= ~UART_IER_MSI;
if (port->flags & ASYNC_HARDPPS_CD) if (port->flags & ASYNC_HARDPPS_CD)
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
if (cflag & CRTSCTS) { tty_port_set_cts_flow(port, cflag & CRTSCTS);
port->flags |= ASYNC_CTS_FLOW; if (cflag & CRTSCTS)
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
} else
port->flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL) if (cflag & CLOCAL)
port->flags &= ~ASYNC_CHECK_CD; port->flags &= ~ASYNC_CHECK_CD;
else { else {

View file

@ -2083,13 +2083,11 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
info->cor1 |= CyPARITY_NONE; info->cor1 |= CyPARITY_NONE;
/* CTS flow control flag */ /* CTS flow control flag */
if (cflag & CRTSCTS) { tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
info->port.flags |= ASYNC_CTS_FLOW; if (cflag & CRTSCTS)
info->cor2 |= CyCtsAE; info->cor2 |= CyCtsAE;
} else { else
info->port.flags &= ~ASYNC_CTS_FLOW;
info->cor2 &= ~CyCtsAE; info->cor2 &= ~CyCtsAE;
}
if (cflag & CLOCAL) if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD; info->port.flags &= ~ASYNC_CHECK_CD;
else 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 /* As the HW flow control is done in firmware, the driver
doesn't need to care about it */ 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 */ /* XON/XOFF/XANY flow control flags */
sw_flow = 0; sw_flow = 0;

View file

@ -765,11 +765,9 @@ static void isicom_config_port(struct tty_struct *tty)
/* flow control settings ...*/ /* flow control settings ...*/
flow_ctrl = 0; flow_ctrl = 0;
port->port.flags &= ~ASYNC_CTS_FLOW; tty_port_set_cts_flow(&port->port, C_CRTSCTS(tty));
if (C_CRTSCTS(tty)) { if (C_CRTSCTS(tty))
port->port.flags |= ASYNC_CTS_FLOW;
flow_ctrl |= ISICOM_CTSRTS; flow_ctrl |= ISICOM_CTSRTS;
}
if (I_IXON(tty)) if (I_IXON(tty))
flow_ctrl |= ISICOM_RESPOND_XONXOFF; flow_ctrl |= ISICOM_RESPOND_XONXOFF;
if (I_IXOFF(tty)) if (I_IXOFF(tty))

View file

@ -711,8 +711,8 @@ static int mxser_change_speed(struct tty_struct *tty,
/* CTS flow control flag and modem status interrupts */ /* CTS flow control flag and modem status interrupts */
info->IER &= ~UART_IER_MSI; info->IER &= ~UART_IER_MSI;
info->MCR &= ~UART_MCR_AFE; info->MCR &= ~UART_MCR_AFE;
tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
info->port.flags |= ASYNC_CTS_FLOW;
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
if ((info->type == PORT_16550A) || (info->board->chip_flag)) { if ((info->type == PORT_16550A) || (info->board->chip_flag)) {
info->MCR |= UART_MCR_AFE; 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); outb(info->MCR, info->ioaddr + UART_MCR);
if (cflag & CLOCAL) { if (cflag & CLOCAL) {

View file

@ -1966,11 +1966,8 @@ 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 */
if (cflag & CRTSCTS) tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
info->port.flags |= ASYNC_CTS_FLOW;
else
info->port.flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL) if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD; info->port.flags &= ~ASYNC_CHECK_CD;
else else

View file

@ -2576,10 +2576,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 */
if (cflag & CRTSCTS) tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
info->port.flags |= ASYNC_CTS_FLOW;
else
info->port.flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL) if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD; info->port.flags &= ~ASYNC_CHECK_CD;

View file

@ -2813,10 +2813,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 */
if (cflag & CRTSCTS) tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);
info->port.flags |= ASYNC_CTS_FLOW;
else
info->port.flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL) if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD; info->port.flags &= ~ASYNC_CHECK_CD;

View file

@ -255,7 +255,6 @@ struct tty_port {
#define TTY_PORT_CTS_FLOW 3 /* h/w flow control enabled */ #define TTY_PORT_CTS_FLOW 3 /* h/w flow control enabled */
#define TTY_PORT_CHECK_CD 4 /* carrier detect enabled */ #define TTY_PORT_CHECK_CD 4 /* carrier detect enabled */
/* /*
* Where all of the state associated with a tty is kept while the tty * 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 * 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. */ /* If the cts flow control is enabled, return true. */
static inline bool tty_port_cts_enabled(struct tty_port *port) 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 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);

View file

@ -86,15 +86,14 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self,
ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE); ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE);
/* CTS flow control flag and modem status interrupts */ /* CTS flow control flag and modem status interrupts */
tty_port_set_cts_flow(&self->port, cflag & CRTSCTS);
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
self->port.flags |= ASYNC_CTS_FLOW;
self->settings.flow_control |= IRCOMM_RTS_CTS_IN; self->settings.flow_control |= IRCOMM_RTS_CTS_IN;
/* This got me. Bummer. Jean II */ /* This got me. Bummer. Jean II */
if (self->service_type == IRCOMM_3_WIRE_RAW) 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", net_warn_ratelimited("%s(), enabling RTS/CTS on link that doesn't support it (3-wire-raw)\n",
__func__); __func__);
} else { } else {
self->port.flags &= ~ASYNC_CTS_FLOW;
self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN; self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN;
} }
if (cflag & CLOCAL) if (cflag & CLOCAL)