Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jul 2016 23:27:28 +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: r303347 - head/sys/dev/usb/serial
Message-ID:  <201607262327.u6QNRS9h014972@repo.freebsd.org>

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

Log:
  Translate modem status reg bits from ns16550 to SER_* values used by the
  tty layer.  Also, the line status reg bits are already ns16550 as expected
  by the ucom layer, so no need for translation or a local var to hold them.

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

Modified: head/sys/dev/usb/serial/umcs.c
==============================================================================
--- head/sys/dev/usb/serial/umcs.c	Tue Jul 26 22:26:49 2016	(r303346)
+++ head/sys/dev/usb/serial/umcs.c	Tue Jul 26 23:27:28 2016	(r303347)
@@ -743,15 +743,26 @@ umcs7840_cfg_get_status(struct ucom_soft
 {
 	struct umcs7840_softc *sc = ucom->sc_parent;
 	uint8_t pn = ucom->sc_portno;
-	uint8_t	hw_lsr = 0;	/* local line status register */
 	uint8_t	hw_msr = 0;	/* local modem status register */
 
-	/* Read LSR & MSR */
-	umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_LSR, &hw_lsr);
+	/*
+	 * Read status registers.  MSR bits need translation from ns16550 to
+	 * SER_* values.  LSR bits are ns16550 in hardware and ucom.
+	 */
+	umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_LSR, lsr);
 	umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_MSR, &hw_msr);
 
-	*lsr = hw_lsr;
-	*msr = hw_msr;
+	if (hw_msr & MCS7840_UART_MSR_NEGCTS)
+		*msr |= SER_CTS;
+
+	if (hw_msr & MCS7840_UART_MSR_NEGDCD)
+		*msr |= SER_DCD;
+
+	if (hw_msr & MCS7840_UART_MSR_NEGRI)
+		*msr |= SER_RI;
+
+	if (hw_msr & MCS7840_UART_MSR_NEGDSR)
+		*msr |= SER_DSR;
 
 	DPRINTF("Port %d status: LSR=%02x MSR=%02x\n", ucom->sc_portno, *lsr, *msr);
 }



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