mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
To: johan@kernel.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
Subject: [PATCH v5 3/3] USB: serial: cp210x: Cleaned up CRTSCTS flag code.
Date: Wed,  4 May 2016 16:57:11 -0500	[thread overview]
Message-ID: <1462399031-535-1-git-send-email-konstantin.shkolnyy@gmail.com> (raw)

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>
---
 drivers/usb/serial/cp210x.c | 32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index ba14dd4..2d43716 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -995,34 +995,22 @@ static void cp210x_set_termios(struct tty_struct *tty,
 		dev_dbg(dev, "%s - read ulControlHandshake=0x%08x, ulFlowReplace=0x%08x\n",
 			__func__, ctl_hs, flow_repl);
 
+		ctl_hs &= ~CP210X_SERIAL_DSR_HANDSHAKE;
+		ctl_hs &= ~CP210X_SERIAL_DCD_HANDSHAKE;
+		ctl_hs &= ~CP210X_SERIAL_DSR_SENSITIVITY;
+		ctl_hs &= ~CP210X_SERIAL_DTR_MASK;
+		ctl_hs |= CP210X_SERIAL_DTR_SHIFT(CP210X_SERIAL_DTR_ACTIVE);
 		if (cflag & CRTSCTS) {
-			ctl_hs &= ~(CP210X_SERIAL_DTR_MASK |
-					CP210X_SERIAL_CTS_HANDSHAKE |
-					CP210X_SERIAL_DSR_HANDSHAKE |
-					CP210X_SERIAL_DCD_HANDSHAKE |
-					CP210X_SERIAL_DSR_SENSITIVITY);
-			ctl_hs |= CP210X_SERIAL_DTR_SHIFT(
-					CP210X_SERIAL_DTR_ACTIVE);
 			ctl_hs |= CP210X_SERIAL_CTS_HANDSHAKE;
-			/*
-			 * FIXME: Why clear bits unrelated to flow control.
-			 * Why clear CP210X_SERIAL_XOFF_CONTINUE which is
-			 * never set
-			 */
-			flow_repl = 0;
+
+			flow_repl &= ~CP210X_SERIAL_RTS_MASK;
 			flow_repl |= CP210X_SERIAL_RTS_SHIFT(
 					CP210X_SERIAL_RTS_FLOW_CTL);
 			dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
 		} else {
-			ctl_hs &= ~(CP210X_SERIAL_DTR_MASK |
-					CP210X_SERIAL_CTS_HANDSHAKE |
-					CP210X_SERIAL_DSR_HANDSHAKE |
-					CP210X_SERIAL_DCD_HANDSHAKE |
-					CP210X_SERIAL_DSR_SENSITIVITY);
-			ctl_hs |= CP210X_SERIAL_DTR_SHIFT(
-					CP210X_SERIAL_DTR_ACTIVE);
-			/* FIXME: Why clear bits unrelated to flow control */
-			flow_repl &= 0xffffff00;
+			ctl_hs &= ~CP210X_SERIAL_CTS_HANDSHAKE;
+
+			flow_repl &= ~CP210X_SERIAL_RTS_MASK;
 			flow_repl |= CP210X_SERIAL_RTS_SHIFT(
 					CP210X_SERIAL_RTS_ACTIVE);
 			dev_dbg(dev, "%s - flow control = NONE\n", __func__);
-- 
1.8.4.5

                 reply	other threads:[~2016-05-04 21:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462399031-535-1-git-send-email-konstantin.shkolnyy@gmail.com \
    --to=konstantin.shkolnyy@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®