All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/5] USB: serial: cp210x: Added comments to CRTSCT flag code.
@ 2016-03-21 23:38 Konstantin Shkolnyy
  0 siblings, 0 replies; only message in thread
From: Konstantin Shkolnyy @ 2016-03-21 23:38 UTC (permalink / raw)
  To: johan; +Cc: linux-usb, linux-kernel, Konstantin Shkolnyy

Documented "magic numbers" used in the CRTSCT flag code in terms of
register bit names from the chip specification.

Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
---
 drivers/usb/serial/cp210x.c | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index ede5c52..b2321a7 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -790,7 +790,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
 
 	cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl,
 			sizeof(modem_ctl));
-	if (modem_ctl[0] & 0x08) {
+	if (modem_ctl[0] & 0x08) { /* if SERIAL_CTS_HANDSHAKE */
 		dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
 		cflag |= CRTSCTS;
 	} else {
@@ -952,17 +952,47 @@ static void cp210x_set_termios(struct tty_struct *tty,
 			__func__, modem_ctl[0], modem_ctl[4], modem_ctl[7]);
 
 		if (cflag & CRTSCTS) {
-			modem_ctl[0] &= ~0x7B;
+			modem_ctl[0] &= ~0x7B; /* keep reserved D2 and D7 */
+			/*
+			 * D1-D0 SERIAL_DTR_MASK     =01b: DTR is held active
+			 * D3 SERIAL_CTS_HANDSHAKE   =1: CTS is a handshake line
+			 * D4 SERIAL_DSR_HANDSHAKE   =0
+			 * D5 SERIAL_DCD_HANDSHAKE   =0
+			 * D6 SERIAL_DSR_SENSITIVITY =0
+			 */
 			modem_ctl[0] |= 0x09;
+			/*
+			 * D0 SERIAL_AUTO_TRANSMIT  =0
+			 * D1 SERIAL_AUTO_RECEIVE   =0
+			 * D2 SERIAL_ERROR_CHAR     =0
+			 * D3 SERIAL_NULL_STRIPPING =0
+			 * D4 SERIAL_BREAK_CHAR     =0
+			 * D7-D6 SERIAL_RTS_MASK =10b: RTS for rcv flow control
+			 */
 			modem_ctl[4] = 0x80;
 			dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
 		} else {
-			modem_ctl[0] &= ~0x7B;
+			modem_ctl[0] &= ~0x7B; /* keep reserved D2 and D7 */
+			/*
+			 * D1-D0 SERIAL_DTR_MASK     = 01b: DTR is held active
+			 * D3 SERIAL_CTS_HANDSHAKE   = 0: CTS is a status input.
+			 * D4 SERIAL_DSR_HANDSHAKE   = 0
+			 * D5 SERIAL_DCD_HANDSHAKE   = 0
+			 * D6 SERIAL_DSR_SENSITIVITY = 0
+			 */
 			modem_ctl[0] |= 0x01;
+			/*
+			 * D0 SERIAL_AUTO_TRANSMIT  = 0
+			 * D1 SERIAL_AUTO_RECEIVE   = 0
+			 * D2 SERIAL_ERROR_CHAR     = 0
+			 * D3 SERIAL_NULL_STRIPPING = 0
+			 * D4 SERIAL_BREAK_CHAR     = 0
+			 * D7-D6 SERIAL_RTS_MASK =01b: RTS is statically active
+			 */
 			modem_ctl[4] = 0x40;
 			dev_dbg(dev, "%s - flow control = NONE\n", __func__);
 		}
-		modem_ctl[7] = 0;
+		modem_ctl[7] = 0; /* SERIAL_XOFF_CONTINUE = 0 */
 
 		dev_dbg(dev, "%s - write modem controls = %02x .. .. .. %02x .. .. %02x\n",
 			__func__, modem_ctl[0], modem_ctl[4], modem_ctl[7]);
-- 
1.8.4.5

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

only message in thread, other threads:[~2016-03-21 23:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-21 23:38 [PATCH 3/5] USB: serial: cp210x: Added comments to CRTSCT flag code Konstantin Shkolnyy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.