svn commit: r260559 - head/sys/dev/usb/serial

Hans Petter Selasky hselasky at FreeBSD.org
Sun Jan 12 11:44:28 UTC 2014


Author: hselasky
Date: Sun Jan 12 11:44:28 2014
New Revision: 260559
URL: http://svnweb.freebsd.org/changeset/base/260559

Log:
  Don't do synchronous USB requests inside USB transfer callbacks. It is
  technically OK, but not recommended.
  
  MFC after:	1 weeks

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

Modified: head/sys/dev/usb/serial/umcs.c
==============================================================================
--- head/sys/dev/usb/serial/umcs.c	Sat Jan 11 23:10:59 2014	(r260558)
+++ head/sys/dev/usb/serial/umcs.c	Sun Jan 12 11:44:28 2014	(r260559)
@@ -121,8 +121,6 @@ struct umcs7840_softc_oneport {
 
 	uint8_t	sc_lcr;			/* local line control register */
 	uint8_t	sc_mcr;			/* local modem control register */
-	uint8_t	sc_lsr;			/* local line status register */
-	uint8_t	sc_msr;			/* local modem status register */
 };
 
 struct umcs7840_softc {
@@ -535,12 +533,7 @@ umcs7840_cfg_open(struct ucom_softc *uco
 	if (umcs7840_set_reg_sync(sc, umcs7840_port_registers[pn].reg_control, data))
 		return;
 
-	/* Read LSR & MSR */
-	if (umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_LSR, &sc->sc_ports[pn].sc_lsr))
-		return;
-	if (umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_MSR, &sc->sc_ports[pn].sc_msr))
-		return;
-	DPRINTF("Port %d has been opened, LSR=%02x MSR=%02x\n", pn, sc->sc_ports[pn].sc_lsr, sc->sc_ports[pn].sc_msr);
+	DPRINTF("Port %d has been opened\n", pn);
 }
 
 static void
@@ -748,9 +741,17 @@ static void
 umcs7840_cfg_get_status(struct ucom_softc *ucom, uint8_t *lsr, uint8_t *msr)
 {
 	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);
+	umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_MSR, &hw_msr);
+
+	*lsr = hw_lsr;
+	*msr = hw_msr;
 
-	*lsr = sc->sc_ports[ucom->sc_portno].sc_lsr;
-	*msr = sc->sc_ports[ucom->sc_portno].sc_msr;
 	DPRINTF("Port %d status: LSR=%02x MSR=%02x\n", ucom->sc_portno, *lsr, *msr);
 }
 
@@ -781,21 +782,11 @@ umcs7840_intr_callback(struct usb_xfer *
 				case MCS7840_UART_ISR_RXERR:
 				case MCS7840_UART_ISR_RXHASDATA:
 				case MCS7840_UART_ISR_RXTIMEOUT:
-					/* Read new LSR */
-					if (umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_LSR, &sc->sc_ports[pn].sc_lsr))
-						break;	/* Inner switch */
+				case MCS7840_UART_ISR_MSCHANGE:
 					ucom_status_change(&sc->sc_ucom[subunit]);
-					/* Inner switch */
 					break;
-				case MCS7840_UART_ISR_TXEMPTY:
+				default:
 					/* Do nothing */
-					break;	/* Inner switch */
-				case MCS7840_UART_ISR_MSCHANGE:
-					/* Read new MSR */
-					if (umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_MSR, &sc->sc_ports[pn].sc_msr))
-						break;	/* Inner switch */
-					DPRINTF("Port %d: new MSR %02x\n", pn, sc->sc_ports[pn].sc_msr);
-					ucom_status_change(&sc->sc_ucom[subunit]);
 					break;
 				}
 			}


More information about the svn-src-all mailing list