Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: max310x: Properly set flags in AutoCTS mode

Commit 391f93f2ec9f ("serial: core: Rework hw-assisted flow control
support") has changed the way the AutoCTS mode is handled.

According to that change, serial drivers which enable H/W AutoCTS mode must
set UPSTAT_AUTORTS, UPSTAT_AUTOCTS and UPSTAT_AUTOXOFF to prevent the
serial core from inadvertently disabling RX or TX. This patch adds proper
handling of UPSTAT_AUTORTS, UPSTAT_AUTOCTS and UPSTAT_AUTOXOFF flags.

Signed-off-by: Christoph Vogtländer <c.vogtlaender@sigma-surface-science.com>
Link: https://lore.kernel.org/r/20190904121141.4570-1-c.vogtlaender@sigma-surface-science.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christoph Vogtländer and committed by
Greg Kroah-Hartman
5a8c296f 8966110c

+10 -2
+10 -2
drivers/tty/serial/max310x.c
··· 955 955 /* Configure flow control */ 956 956 max310x_port_write(port, MAX310X_XON1_REG, termios->c_cc[VSTART]); 957 957 max310x_port_write(port, MAX310X_XOFF1_REG, termios->c_cc[VSTOP]); 958 - if (termios->c_cflag & CRTSCTS) 958 + 959 + port->status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF); 960 + 961 + if (termios->c_cflag & CRTSCTS) { 962 + /* Enable AUTORTS and AUTOCTS */ 963 + port->status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; 959 964 flow |= MAX310X_FLOWCTRL_AUTOCTS_BIT | 960 965 MAX310X_FLOWCTRL_AUTORTS_BIT; 966 + } 961 967 if (termios->c_iflag & IXON) 962 968 flow |= MAX310X_FLOWCTRL_SWFLOW3_BIT | 963 969 MAX310X_FLOWCTRL_SWFLOWEN_BIT; 964 - if (termios->c_iflag & IXOFF) 970 + if (termios->c_iflag & IXOFF) { 971 + port->status |= UPSTAT_AUTOXOFF; 965 972 flow |= MAX310X_FLOWCTRL_SWFLOW1_BIT | 966 973 MAX310X_FLOWCTRL_SWFLOWEN_BIT; 974 + } 967 975 max310x_port_write(port, MAX310X_FLOWCTRL_REG, flow); 968 976 969 977 /* Get baud rate generator configuration */