usbserial: pl2303 tx xon/xoff flow control
Subsystems (2)
Johan Hovold
maintainerPATCH v2 1/1 usbserial: pl2303 tx xon/xoff flow control
Quoted 17 lines · Florian Zumbiehl
Support hardware-level Xon/Xoff flow control in transmit direction with pl2303.
I only know how to get the hardware to do IXON/!IXANY with ^S/^Q as control characters, so I preserve the old behaviour for all other cases.
Signed-off-by Florian Zumbiehl <[email protected]>---
drivers/usb/serial/pl2303.c renamed from drivers/usb/serial/pl2303.c.orig +1
-0@@ -539,12 +539,18 @@struct usb_serial *serial = port->serial;struct pl2303_serial_private *spriv =usb_get_serial_data (serial);struct pl2303_private *priv =usb_get_serial_port_data (port); +bool termios_unchanged;unsigned long flags;unsigned char *buf;
drivers/usb/serial/pl2303.c line 553
Quoted 10 lines
drivers/usb/serial/pl2303.c renamed from drivers/usb/serial/pl2303.c.orig +6
-1int ret;u8 control; -if (old_termios && !tty_termios_hw_change (&tty->termios, old_termios)) + termios_unchanged = 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 ]); +if (termios_unchanged)
This is slightly more readable, but you still violate indentation rules (e.g. two tabs for continuation lines) and the expression is just generally hard to parse.
I played around with an ixon_changed intermediate (which what I had in mind when I suggested an intermediate), but in the end I settled on a helper function.
The result, which I've applied for -next, can be found below.
Thanks,
Johan
From 1f09807ed52bc530a1139c6ae6092b9176ded45f Mon Sep 17 00:00:00 2001
From: Florian Zumbiehl <[email protected]>
Date: Sun, 20 May 2018 02:23:12 +0200
Subject: [PATCH] USB: serial: pl2303: add support for tx xon/xoff flow control
Support hardware-level Xon/Xoff flow control in transmit direction with pl2303.
I only know how to get the hardware to do IXON/!IXANY with ^S/^Q as control characters, so I preserve the old behaviour for all other cases.
--- drivers/usb/serial/pl2303.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/usb/serial/pl2303.c +15 -1
@@ -533,6 +533,17 @@ static int pl2303_set_line_request(struct usb_serial_port *port,return 0 ; } +static bool pl2303_termios_change (struct ktermios *a,struct ktermios *b) +{ +bool ixon_change; + + ixon_change = ((a->c_iflag ^ b->c_iflag) & (IXON |IXANY )) || + a->c_cc[VSTART ] != b->c_cc[VSTART ] || + a->c_cc[VSTOP ] != b->c_cc[VSTOP ]; + +return tty_termios_hw_change (a, b) || ixon_change; +} +static void pl2303_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios) {
@@ -544,7 +555,7 @@ static void pl2303_set_termios(struct tty_struct *tty,int ret;u8 control; -if (old_termios && !tty_termios_hw_change (&tty->termios, old_termios)) +if (old_termios && !pl2303_termios_change (&tty->termios, old_termios))return ; buf =kzalloc (7 ,GFP_KERNEL );
@@ -662,6 +673,9 @@ static void pl2303_set_termios(struct tty_struct *tty,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 ); }