mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 22:25:03 +00:00
serial: imx: set_termios(): clarify RTS/CTS bits calculation
Avoid repeating the same code for rs485 twice. Make it obvious we clear CRTSCTS bit in termios->c_cflag whenever sport->have_rtscts is false. Make it obvious we clear UCR2_IRTS whenever CRTSCTS is set. Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Sergey Organov <sorganov@gmail.com> Link: https://lore.kernel.org/r/1561558293-7683-4-git-send-email-sorganov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
41ffa48ea7
commit
ddf89e7503
1 changed files with 13 additions and 23 deletions
|
@ -1566,35 +1566,25 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios,
|
||||||
if ((termios->c_cflag & CSIZE) == CS8)
|
if ((termios->c_cflag & CSIZE) == CS8)
|
||||||
ucr2 |= UCR2_WS;
|
ucr2 |= UCR2_WS;
|
||||||
|
|
||||||
if (termios->c_cflag & CRTSCTS) {
|
if (!sport->have_rtscts)
|
||||||
if (sport->have_rtscts) {
|
termios->c_cflag &= ~CRTSCTS;
|
||||||
ucr2 &= ~UCR2_IRTS;
|
|
||||||
|
|
||||||
if (port->rs485.flags & SER_RS485_ENABLED) {
|
if (port->rs485.flags & SER_RS485_ENABLED) {
|
||||||
/*
|
/*
|
||||||
* RTS is mandatory for rs485 operation, so keep
|
* RTS is mandatory for rs485 operation, so keep
|
||||||
* it under manual control and keep transmitter
|
* it under manual control and keep transmitter
|
||||||
* disabled.
|
* disabled.
|
||||||
*/
|
*/
|
||||||
if (port->rs485.flags &
|
|
||||||
SER_RS485_RTS_AFTER_SEND)
|
|
||||||
imx_uart_rts_active(sport, &ucr2);
|
|
||||||
else
|
|
||||||
imx_uart_rts_inactive(sport, &ucr2);
|
|
||||||
} else {
|
|
||||||
imx_uart_rts_auto(sport, &ucr2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
termios->c_cflag &= ~CRTSCTS;
|
|
||||||
}
|
|
||||||
} else if (port->rs485.flags & SER_RS485_ENABLED) {
|
|
||||||
/* disable transmitter */
|
|
||||||
if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND)
|
if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND)
|
||||||
imx_uart_rts_active(sport, &ucr2);
|
imx_uart_rts_active(sport, &ucr2);
|
||||||
else
|
else
|
||||||
imx_uart_rts_inactive(sport, &ucr2);
|
imx_uart_rts_inactive(sport, &ucr2);
|
||||||
}
|
|
||||||
|
|
||||||
|
} else if (termios->c_cflag & CRTSCTS)
|
||||||
|
imx_uart_rts_auto(sport, &ucr2);
|
||||||
|
|
||||||
|
if (termios->c_cflag & CRTSCTS)
|
||||||
|
ucr2 &= ~UCR2_IRTS;
|
||||||
|
|
||||||
if (termios->c_cflag & CSTOPB)
|
if (termios->c_cflag & CSTOPB)
|
||||||
ucr2 |= UCR2_STPB;
|
ucr2 |= UCR2_STPB;
|
||||||
|
|
Loading…
Reference in a new issue