Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jul 2016 23:42:42 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r303350 - head/sys/dev/usb/serial
Message-ID:  <201607262342.u6QNggsp022442@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Tue Jul 26 23:42:42 2016
New Revision: 303350
URL: https://svnweb.freebsd.org/changeset/base/303350

Log:
  Translate modem status reg bits from ns16550 to SER_* values used by the
  tty layer.
  
  Also annotate a switch case fall-through per style(9).

Modified:
  head/sys/dev/usb/serial/umct.c

Modified: head/sys/dev/usb/serial/umct.c
==============================================================================
--- head/sys/dev/usb/serial/umct.c	Tue Jul 26 23:40:25 2016	(r303349)
+++ head/sys/dev/usb/serial/umct.c	Tue Jul 26 23:42:42 2016	(r303350)
@@ -86,6 +86,15 @@ __FBSDID("$FreeBSD$");
 #define	UMCT_SET_MCR		10	/* Set Modem Control Register */
 #define	UMCT_SET_MCR_SIZE	1
 
+#define	UMCT_MSR_CTS_CHG	0x01
+#define	UMCT_MSR_DSR_CHG	0x02
+#define	UMCT_MSR_RI_CHG		0x04
+#define	UMCT_MSR_CD_CHG		0x08
+#define	UMCT_MSR_CTS		0x10
+#define	UMCT_MSR_RTS		0x20
+#define	UMCT_MSR_RI		0x40
+#define	UMCT_MSR_CD		0x80
+
 #define	UMCT_INTR_INTERVAL	100
 #define	UMCT_IFACE_INDEX	0
 #define	UMCT_CONFIG_INDEX	0
@@ -384,11 +393,23 @@ umct_intr_callback_sub(struct usb_xfer *
 		pc = usbd_xfer_get_frame(xfer, 0);
 		usbd_copy_out(pc, 0, buf, sizeof(buf));
 
-		sc->sc_msr = buf[0];
+		/*
+		 * MSR bits need translation from ns16550 to SER_* values.
+		 * LSR bits are ns16550 in hardware and ucom.
+		 */
+		sc->sc_msr = 0;
+		if (buf[0] & UMCT_MSR_CTS)
+			sc->sc_msr |= SER_CTS;
+		if (buf[0] & UMCT_MSR_CD)
+			sc->sc_msr |= SER_DCD;
+		if (buf[0] & UMCT_MSR_RI)
+			sc->sc_msr |= SER_RI;
+		if (buf[0] & UMCT_MSR_RTS)
+			sc->sc_msr |= SER_DSR;
 		sc->sc_lsr = buf[1];
 
 		ucom_status_change(&sc->sc_ucom);
-
+		/* FALLTHROUGH */
 	case USB_ST_SETUP:
 tr_setup:
 		usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607262342.u6QNggsp022442>