Commit 4b6181ca authored by Roland Koebler's avatar Roland Koebler Committed by Greg Kroah-Hartman

USB: serial: cp210x.c: add mark/space parity

Add mark and space parity support.
Signed-off-by: default avatarRoland Koebler <r.koebler@yahoo.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 968b822c
...@@ -520,18 +520,13 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, ...@@ -520,18 +520,13 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
cflag |= PARENB; cflag |= PARENB;
break; break;
case BITS_PARITY_MARK: case BITS_PARITY_MARK:
dbg("%s - parity = MARK (not supported, disabling parity)", dbg("%s - parity = MARK", __func__);
__func__); cflag |= (PARENB|PARODD|CMSPAR);
cflag &= ~PARENB;
bits &= ~BITS_PARITY_MASK;
cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2);
break; break;
case BITS_PARITY_SPACE: case BITS_PARITY_SPACE:
dbg("%s - parity = SPACE (not supported, disabling parity)", dbg("%s - parity = SPACE", __func__);
__func__); cflag &= ~PARODD;
cflag &= ~PARENB; cflag |= (PARENB|CMSPAR);
bits &= ~BITS_PARITY_MASK;
cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2);
break; break;
default: default:
dbg("%s - Unknown parity mode, disabling parity", __func__); dbg("%s - Unknown parity mode, disabling parity", __func__);
...@@ -588,7 +583,6 @@ static void cp210x_set_termios(struct tty_struct *tty, ...@@ -588,7 +583,6 @@ static void cp210x_set_termios(struct tty_struct *tty,
if (!tty) if (!tty)
return; return;
tty->termios->c_cflag &= ~CMSPAR;
cflag = tty->termios->c_cflag; cflag = tty->termios->c_cflag;
old_cflag = old_termios->c_cflag; old_cflag = old_termios->c_cflag;
baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty));
...@@ -643,16 +637,27 @@ static void cp210x_set_termios(struct tty_struct *tty, ...@@ -643,16 +637,27 @@ static void cp210x_set_termios(struct tty_struct *tty,
"not supported by device\n"); "not supported by device\n");
} }
if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))) { if ((cflag & (PARENB|PARODD|CMSPAR)) !=
(old_cflag & (PARENB|PARODD|CMSPAR))) {
cp210x_get_config(port, CP210X_GET_LINE_CTL, &bits, 2); cp210x_get_config(port, CP210X_GET_LINE_CTL, &bits, 2);
bits &= ~BITS_PARITY_MASK; bits &= ~BITS_PARITY_MASK;
if (cflag & PARENB) { if (cflag & PARENB) {
if (cflag & PARODD) { if (cflag & CMSPAR) {
bits |= BITS_PARITY_ODD; if (cflag & PARODD) {
dbg("%s - parity = ODD", __func__); bits |= BITS_PARITY_MARK;
dbg("%s - parity = MARK", __func__);
} else {
bits |= BITS_PARITY_SPACE;
dbg("%s - parity = SPACE", __func__);
}
} else { } else {
bits |= BITS_PARITY_EVEN; if (cflag & PARODD) {
dbg("%s - parity = EVEN", __func__); bits |= BITS_PARITY_ODD;
dbg("%s - parity = ODD", __func__);
} else {
bits |= BITS_PARITY_EVEN;
dbg("%s - parity = EVEN", __func__);
}
} }
} }
if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2))
......
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