linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 3/3] USB: serial: cp210x: Cleaned up CRTSCTS flag code.
@ 2016-04-30 14:49 Konstantin Shkolnyy
  0 siblings, 0 replies; only message in thread
From: Konstantin Shkolnyy @ 2016-04-30 14:49 UTC (permalink / raw)
  To: johan; +Cc: linux-usb, linux-kernel, Konstantin Shkolnyy

The CRTSCTS flag code cleared (and inconsistently) bits unrelated to
CRTSCTS functionality. It was also harder than necessary to read.

Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
---
v3:
Regenerated the patches correctly against the latest usb-next branch.
v2
Improved CRTSCTS fix by feedback. Dropped get_termios error handling fix.

 drivers/usb/serial/cp210x.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 24955a7..aaa33b7 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -992,24 +992,21 @@ static void cp210x_set_termios(struct tty_struct *tty,
 		dev_dbg(dev, "%s - read ulControlHandshake=%08x ulFlowReplace=%08x\n",
 			__func__, ControlHandshake, FlowReplace);
 
+		ControlHandshake &= ~SERIAL_DSR_HANDSHAKE;
+		ControlHandshake &= ~SERIAL_DCD_HANDSHAKE;
+		ControlHandshake &= ~SERIAL_DSR_SENSITIVITY;
+		ControlHandshake &= ~SERIAL_DTR_MASK;
+		ControlHandshake |= SERIAL_DTR_ACTIVE;
 		if (cflag & CRTSCTS) {
-			ControlHandshake &= ~(SERIAL_DTR_MASK |
-				SERIAL_CTS_HANDSHAKE | SERIAL_DSR_HANDSHAKE |
-				SERIAL_DCD_HANDSHAKE | SERIAL_DSR_SENSITIVITY);
-			ControlHandshake |= SERIAL_DTR_ACTIVE;
 			ControlHandshake |= SERIAL_CTS_HANDSHAKE;
-			/* FIXME why clear bits unrelated to flow control */
-			/* FIXME why clear _XOFF_CONTINUE which is never set */
-			FlowReplace &= ~0xffffffff;
+
+			FlowReplace &= ~SERIAL_RTS_MASK;
 			FlowReplace |= SERIAL_RTS_FLOW_CTL;
 			dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
 		} else {
-			ControlHandshake &= ~(SERIAL_DTR_MASK |
-				SERIAL_CTS_HANDSHAKE | SERIAL_DSR_HANDSHAKE |
-				SERIAL_DCD_HANDSHAKE | SERIAL_DSR_SENSITIVITY);
-			ControlHandshake |= SERIAL_DTR_ACTIVE;
-			/* FIXME - why clear bits unrelated to flow control */
-			FlowReplace &= ~0xff;
+			ControlHandshake &= ~SERIAL_CTS_HANDSHAKE;
+
+			FlowReplace &= ~SERIAL_RTS_MASK;
 			FlowReplace |= SERIAL_RTS_ACTIVE;
 			dev_dbg(dev, "%s - flow control = NONE\n", __func__);
 		}
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-30 14:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-30 14:49 [PATCH v3 3/3] USB: serial: cp210x: Cleaned up CRTSCTS flag code Konstantin Shkolnyy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).