Skip to content

Commit 5d1678a

Browse files
committed
USB: keyspan: fix tty line-status reporting
Fix handling of TTY error flags, which are not bitmasks and must specifically not be ORed together as this prevents the line discipline from recognising them. Also insert null characters when reporting overrun errors as these are not associated with the received character. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable <[email protected]> Signed-off-by: Johan Hovold <[email protected]>
1 parent 204ec6e commit 5d1678a

File tree

1 file changed

+48
-28
lines changed

1 file changed

+48
-28
lines changed

drivers/usb/serial/keyspan.c

+48-28
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,19 @@ static void usa26_indat_callback(struct urb *urb)
321321
/* some bytes had errors, every byte has status */
322322
dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
323323
for (i = 0; i + 1 < urb->actual_length; i += 2) {
324-
int stat = data[i], flag = 0;
325-
if (stat & RXERROR_OVERRUN)
326-
flag |= TTY_OVERRUN;
327-
if (stat & RXERROR_FRAMING)
328-
flag |= TTY_FRAME;
329-
if (stat & RXERROR_PARITY)
330-
flag |= TTY_PARITY;
324+
int stat = data[i];
325+
int flag = TTY_NORMAL;
326+
327+
if (stat & RXERROR_OVERRUN) {
328+
tty_insert_flip_char(&port->port, 0,
329+
TTY_OVERRUN);
330+
}
331331
/* XXX should handle break (0x10) */
332+
if (stat & RXERROR_PARITY)
333+
flag = TTY_PARITY;
334+
else if (stat & RXERROR_FRAMING)
335+
flag = TTY_FRAME;
336+
332337
tty_insert_flip_char(&port->port, data[i+1],
333338
flag);
334339
}
@@ -649,14 +654,19 @@ static void usa49_indat_callback(struct urb *urb)
649654
} else {
650655
/* some bytes had errors, every byte has status */
651656
for (i = 0; i + 1 < urb->actual_length; i += 2) {
652-
int stat = data[i], flag = 0;
653-
if (stat & RXERROR_OVERRUN)
654-
flag |= TTY_OVERRUN;
655-
if (stat & RXERROR_FRAMING)
656-
flag |= TTY_FRAME;
657-
if (stat & RXERROR_PARITY)
658-
flag |= TTY_PARITY;
657+
int stat = data[i];
658+
int flag = TTY_NORMAL;
659+
660+
if (stat & RXERROR_OVERRUN) {
661+
tty_insert_flip_char(&port->port, 0,
662+
TTY_OVERRUN);
663+
}
659664
/* XXX should handle break (0x10) */
665+
if (stat & RXERROR_PARITY)
666+
flag = TTY_PARITY;
667+
else if (stat & RXERROR_FRAMING)
668+
flag = TTY_FRAME;
669+
660670
tty_insert_flip_char(&port->port, data[i+1],
661671
flag);
662672
}
@@ -713,15 +723,19 @@ static void usa49wg_indat_callback(struct urb *urb)
713723
*/
714724
for (x = 0; x + 1 < len &&
715725
i + 1 < urb->actual_length; x += 2) {
716-
int stat = data[i], flag = 0;
726+
int stat = data[i];
727+
int flag = TTY_NORMAL;
717728

718-
if (stat & RXERROR_OVERRUN)
719-
flag |= TTY_OVERRUN;
720-
if (stat & RXERROR_FRAMING)
721-
flag |= TTY_FRAME;
722-
if (stat & RXERROR_PARITY)
723-
flag |= TTY_PARITY;
729+
if (stat & RXERROR_OVERRUN) {
730+
tty_insert_flip_char(&port->port, 0,
731+
TTY_OVERRUN);
732+
}
724733
/* XXX should handle break (0x10) */
734+
if (stat & RXERROR_PARITY)
735+
flag = TTY_PARITY;
736+
else if (stat & RXERROR_FRAMING)
737+
flag = TTY_FRAME;
738+
725739
tty_insert_flip_char(&port->port, data[i+1],
726740
flag);
727741
i += 2;
@@ -784,14 +798,20 @@ static void usa90_indat_callback(struct urb *urb)
784798
/* some bytes had errors, every byte has status */
785799
dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
786800
for (i = 0; i + 1 < urb->actual_length; i += 2) {
787-
int stat = data[i], flag = 0;
788-
if (stat & RXERROR_OVERRUN)
789-
flag |= TTY_OVERRUN;
790-
if (stat & RXERROR_FRAMING)
791-
flag |= TTY_FRAME;
792-
if (stat & RXERROR_PARITY)
793-
flag |= TTY_PARITY;
801+
int stat = data[i];
802+
int flag = TTY_NORMAL;
803+
804+
if (stat & RXERROR_OVERRUN) {
805+
tty_insert_flip_char(
806+
&port->port, 0,
807+
TTY_OVERRUN);
808+
}
794809
/* XXX should handle break (0x10) */
810+
if (stat & RXERROR_PARITY)
811+
flag = TTY_PARITY;
812+
else if (stat & RXERROR_FRAMING)
813+
flag = TTY_FRAME;
814+
795815
tty_insert_flip_char(&port->port,
796816
data[i+1], flag);
797817
}

0 commit comments

Comments
 (0)