diff options
author | Roland Koebler <r.koebler@yahoo.de> | 2011-11-09 13:37:08 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-14 19:46:06 -0500 |
commit | 4b6181caa411ccb91ff4aad10b83d62d5a0464d3 (patch) | |
tree | 085e904de89946babe7c4a4a949f735ee3e6d6e4 /drivers/usb/serial/cp210x.c | |
parent | 968b822c0023861ef6e4e15bb68582b36e89ad29 (diff) |
USB: serial: cp210x.c: add mark/space parity
Add mark and space parity support.
Signed-off-by: Roland Koebler <r.koebler@yahoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/cp210x.c')
-rw-r--r-- | drivers/usb/serial/cp210x.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index fd67cc53545b..b1e5db161487 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -520,18 +520,13 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
520 | cflag |= PARENB; | 520 | cflag |= PARENB; |
521 | break; | 521 | break; |
522 | case BITS_PARITY_MARK: | 522 | case BITS_PARITY_MARK: |
523 | dbg("%s - parity = MARK (not supported, disabling parity)", | 523 | dbg("%s - parity = MARK", __func__); |
524 | __func__); | 524 | cflag |= (PARENB|PARODD|CMSPAR); |
525 | cflag &= ~PARENB; | ||
526 | bits &= ~BITS_PARITY_MASK; | ||
527 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); | ||
528 | break; | 525 | break; |
529 | case BITS_PARITY_SPACE: | 526 | case BITS_PARITY_SPACE: |
530 | dbg("%s - parity = SPACE (not supported, disabling parity)", | 527 | dbg("%s - parity = SPACE", __func__); |
531 | __func__); | 528 | cflag &= ~PARODD; |
532 | cflag &= ~PARENB; | 529 | cflag |= (PARENB|CMSPAR); |
533 | bits &= ~BITS_PARITY_MASK; | ||
534 | cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); | ||
535 | break; | 530 | break; |
536 | default: | 531 | default: |
537 | dbg("%s - Unknown parity mode, disabling parity", __func__); | 532 | dbg("%s - Unknown parity mode, disabling parity", __func__); |
@@ -588,7 +583,6 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
588 | if (!tty) | 583 | if (!tty) |
589 | return; | 584 | return; |
590 | 585 | ||
591 | tty->termios->c_cflag &= ~CMSPAR; | ||
592 | cflag = tty->termios->c_cflag; | 586 | cflag = tty->termios->c_cflag; |
593 | old_cflag = old_termios->c_cflag; | 587 | old_cflag = old_termios->c_cflag; |
594 | baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); | 588 | baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); |
@@ -643,16 +637,27 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
643 | "not supported by device\n"); | 637 | "not supported by device\n"); |
644 | } | 638 | } |
645 | 639 | ||
646 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))) { | 640 | if ((cflag & (PARENB|PARODD|CMSPAR)) != |
641 | (old_cflag & (PARENB|PARODD|CMSPAR))) { | ||
647 | cp210x_get_config(port, CP210X_GET_LINE_CTL, &bits, 2); | 642 | cp210x_get_config(port, CP210X_GET_LINE_CTL, &bits, 2); |
648 | bits &= ~BITS_PARITY_MASK; | 643 | bits &= ~BITS_PARITY_MASK; |
649 | if (cflag & PARENB) { | 644 | if (cflag & PARENB) { |
650 | if (cflag & PARODD) { | 645 | if (cflag & CMSPAR) { |
651 | bits |= BITS_PARITY_ODD; | 646 | if (cflag & PARODD) { |
652 | dbg("%s - parity = ODD", __func__); | 647 | bits |= BITS_PARITY_MARK; |
648 | dbg("%s - parity = MARK", __func__); | ||
649 | } else { | ||
650 | bits |= BITS_PARITY_SPACE; | ||
651 | dbg("%s - parity = SPACE", __func__); | ||
652 | } | ||
653 | } else { | 653 | } else { |
654 | bits |= BITS_PARITY_EVEN; | 654 | if (cflag & PARODD) { |
655 | dbg("%s - parity = EVEN", __func__); | 655 | bits |= BITS_PARITY_ODD; |
656 | dbg("%s - parity = ODD", __func__); | ||
657 | } else { | ||
658 | bits |= BITS_PARITY_EVEN; | ||
659 | dbg("%s - parity = EVEN", __func__); | ||
660 | } | ||
656 | } | 661 | } |
657 | } | 662 | } |
658 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 663 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |