mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 21:03:32 +00:00
serial: st-asc: Sanitize CSIZE and correct PARENB for CS7
[ Upstream commit52bb1cb711
] Only CS7 and CS8 seem supported but CSIZE is not sanitized from CS5 or CS6 to CS8. In addition, ASC_CTL_MODE_7BIT_PAR suggests that CS7 has to have parity, thus add PARENB. Incorrect CSIZE results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout(). Fixes:c4b0585607
(serial:st-asc: Add ST ASC driver.) Cc: Srinivas Kandagatla <srinivas.kandagatla@st.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20220519081808.3776-8-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
df6c3ce4ef
commit
2b5a7b222d
1 changed files with 4 additions and 0 deletions
|
@ -535,10 +535,14 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios,
|
|||
/* set character length */
|
||||
if ((cflag & CSIZE) == CS7) {
|
||||
ctrl_val |= ASC_CTL_MODE_7BIT_PAR;
|
||||
cflag |= PARENB;
|
||||
} else {
|
||||
ctrl_val |= (cflag & PARENB) ? ASC_CTL_MODE_8BIT_PAR :
|
||||
ASC_CTL_MODE_8BIT;
|
||||
cflag &= ~CSIZE;
|
||||
cflag |= CS8;
|
||||
}
|
||||
termios->c_cflag = cflag;
|
||||
|
||||
/* set stop bit */
|
||||
ctrl_val |= (cflag & CSTOPB) ? ASC_CTL_STOP_2BIT : ASC_CTL_STOP_1BIT;
|
||||
|
|
Loading…
Reference in a new issue