Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Aug 2008 21:49:21 GMT
From:      Ed Schouten <ed@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 148058 for review
Message-ID:  <200808212149.m7LLnLff025151@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=148058

Change 148058 by ed@ed_flippo on 2008/08/21 21:48:49

	Commit my ucom(4) changes as well. As I expected, hardware flow
	control wasn't properly fixed in the ucom(4) driver.

Affected files ...

.. //depot/projects/mpsafetty/sys/dev/usb/ucom.c#5 edit

Differences ...

==== //depot/projects/mpsafetty/sys/dev/usb/ucom.c#5 (text+ko) ====

@@ -128,6 +128,7 @@
 static tsw_open_t ucomtty_open;
 static tsw_close_t ucomtty_close;
 static tsw_outwakeup_t ucomtty_outwakeup;
+static tsw_inwakeup_t ucomtty_inwakeup;
 static tsw_ioctl_t ucomtty_ioctl;
 static tsw_param_t ucomtty_param;
 static tsw_modem_t ucomtty_modem;
@@ -138,6 +139,7 @@
 	.tsw_open	= ucomtty_open,
 	.tsw_close	= ucomtty_close,
 	.tsw_outwakeup	= ucomtty_outwakeup,
+	.tsw_inwakeup	= ucomtty_inwakeup,
 	.tsw_ioctl	= ucomtty_ioctl,
 	.tsw_param	= ucomtty_param,
 	.tsw_modem	= ucomtty_modem,
@@ -500,10 +502,6 @@
 		return (error);
 	}
 
-#if 0
-	ttsetwater(tp);
-#endif
-
 	if (t->c_cflag & CRTS_IFLOW) {
 		sc->sc_state |= UCS_RTS_IFLOW;
 	} else if (sc->sc_state & UCS_RTS_IFLOW) {
@@ -511,10 +509,6 @@
 		(void)ucomtty_modem(tp, SER_RTS, 0);
 	}
 
-#if 0
-	ttyldoptim(tp);
-#endif
-
 	uerr = ucomstartread(sc);
 	if (uerr != USBD_NORMAL_COMPLETION)
 		return (EIO);
@@ -554,24 +548,6 @@
 	if (sc->sc_oxfer == NULL)
 		return;
 
-	/* XXX: hardware flow control. We should use inwakeup here. */
-#if 0
-	if (tp->t_state & TS_TBLOCK) {
-		if (ISSET(sc->sc_mcr, SER_RTS) &&
-		    ISSET(sc->sc_state, UCS_RTS_IFLOW)) {
-			DPRINTF(("ucomtty_outwakeup: clear RTS\n"));
-			(void)ucomtty_modem(tp, 0, SER_RTS);
-		}
-	} else {
-		if (!ISSET(sc->sc_mcr, SER_RTS) &&
-		    tp->t_rawq.c_cc <= tp->t_ilowat &&
-		    ISSET(sc->sc_state, UCS_RTS_IFLOW)) {
-			DPRINTF(("ucomtty_outwakeup: set RTS\n"));
-			(void)ucomtty_modem(tp, SER_RTS, 0);
-		}
-	}
-#endif
-
 	if (sc->sc_state & UCS_TXBUSY)
 		return;
 
@@ -600,35 +576,22 @@
 	}
 }
 
-#if 0
 static void
-ucomstop(struct tty *tp, int flag)
+ucomtty_inwakeup(struct tty *tp)
 {
 	struct ucom_softc *sc = tty_softc(tp);
-	int s;
 
-	DPRINTF(("ucomstop: %d\n", flag));
+	DPRINTF(("ucomtty_inwakeup: sc = %p\n", sc));
 
-	if ((flag & FREAD) && (sc->sc_state & UCS_RXSTOP) == 0) {
-		DPRINTF(("ucomstop: read\n"));
-		ucomstopread(sc);
-		ucomstartread(sc);
-	}
+	if (sc->sc_dying)
+		return;
 
-	if (flag & FWRITE) {
-		DPRINTF(("ucomstop: write\n"));
-		if (ISSET(tp->t_state, TS_BUSY)) {
-			/* XXX do what? */
-			if (!ISSET(tp->t_state, TS_TTSTOP))
-				SET(tp->t_state, TS_FLUSH);
-		}
+	if (!ISSET(sc->sc_mcr, SER_RTS) &&
+	    ISSET(sc->sc_state, UCS_RTS_IFLOW)) {
+		DPRINTF(("ucomtty_outwakeup: set RTS\n"));
+		(void)ucomtty_modem(tp, SER_RTS, 0);
 	}
-
-	ucomtty_outwakeup(tp);
-
-	DPRINTF(("ucomstop: done\n"));
 }
-#endif
 
 static void
 ucomwritecb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status)
@@ -663,13 +626,6 @@
 	cc -= sc->sc_opkthdrlen;
 
 	sc->sc_state &= ~UCS_TXBUSY;
-#if 0
-	CLR(tp->t_state, TS_BUSY);
-	if (ISSET(tp->t_state, TS_FLUSH))
-		CLR(tp->t_state, TS_FLUSH);
-	else
-		ndflush(&tp->t_outq, cc);
-#endif
 	ucomtty_outwakeup(tp);
 }
 
@@ -744,9 +700,11 @@
 	while (cc > 0) {
 		DPRINTFN(7, ("ucomreadcb: char = 0x%02x\n", *cp));
 		if (ttydisc_rint(tp, *cp, 0) == -1) {
-			/* XXX what should we do? */
-			printf("%s: lost %d chars\n",
-			       device_get_nameunit(sc->sc_dev), cc);
+			if (ISSET(sc->sc_mcr, SER_RTS) &&
+			    ISSET(sc->sc_state, UCS_RTS_IFLOW)) {
+				DPRINTF(("ucomtty_outwakeup: clear RTS\n"));
+				(void)ucomtty_modem(tp, 0, SER_RTS);
+			}
 			break;
 		}
 		cc--;
@@ -760,12 +718,6 @@
 		printf("%s: read start failed\n", device_get_nameunit(sc->sc_dev));
 		/* XXX what should we dow now? */
 	}
-
-#if 0
-	if ((sc->sc_state & UCS_RTS_IFLOW) && !ISSET(sc->sc_mcr, SER_RTS)
-	    && !(tp->t_state & TS_TBLOCK))
-		ucomtty_modem(tp, SER_RTS, 0);
-#endif
 }
 
 static void



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