Support hardware-level Xon/Xoff flow control in transmit direction with
pl2303.

Signed-off-by: Florian Zumbiehl <[email protected]>
---
Note that the patch has only been fully tested with kernel 4.9.28, and
test-compiled against 4.16.8. Tested only with the pl2303 adapters I have
available (which seem to be type 0 if I interpret the code correctly), I
don't have a clue whether this works with other versions of the chip.

--- linux-4.16.8/drivers/usb/serial/pl2303.c.orig       2018-05-09 
09:53:14.000000000 +0200
+++ linux-4.16.8/drivers/usb/serial/pl2303.c    2018-05-14 04:32:27.860780856 
+0200
@@ -544,8 +544,12 @@ static void pl2303_set_termios(struct tt
        int ret;
        u8 control;
 
-       if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
-               return;
+       if (old_termios &&
+               !(tty_termios_hw_change(&tty->termios, old_termios) ||
+                 ((tty->termios.c_iflag ^ old_termios->c_iflag) & (IXON | 
IXANY)) ||
+                 tty->termios.c_cc[VSTOP] != old_termios->c_cc[VSTOP] ||
+                 tty->termios.c_cc[VSTART] != old_termios->c_cc[VSTART]))
+                       return;
 
        buf = kzalloc(7, GFP_KERNEL);
        if (!buf) {
@@ -662,6 +666,9 @@ static void pl2303_set_termios(struct tt
                        pl2303_vendor_write(serial, 0x0, 0x41);
                else
                        pl2303_vendor_write(serial, 0x0, 0x61);
+       } else if (I_IXON(tty) && !I_IXANY(tty) &&
+                  START_CHAR(tty) == 0x11 && STOP_CHAR(tty) == 0x13) {
+                       pl2303_vendor_write(serial, 0x0, 0xc0);
        } else {
                pl2303_vendor_write(serial, 0x0, 0x0);
        }
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to