Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 May 2009 17:06:36 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r192820 - head/sys/dev/usb/serial
Message-ID:  <200905261706.n4QH6aAp066343@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Tue May 26 17:06:36 2009
New Revision: 192820
URL: http://svn.freebsd.org/changeset/base/192820

Log:
  Do not forcefully close the write transfer when closing the tty, it needs to
  run to completion and drain the tty queue.

Modified:
  head/sys/dev/usb/serial/usb_serial.c
  head/sys/dev/usb/serial/usb_serial.h

Modified: head/sys/dev/usb/serial/usb_serial.c
==============================================================================
--- head/sys/dev/usb/serial/usb_serial.c	Tue May 26 17:01:12 2009	(r192819)
+++ head/sys/dev/usb/serial/usb_serial.c	Tue May 26 17:06:36 2009	(r192820)
@@ -589,13 +589,9 @@ usb2_com_cfg_close(struct usb2_proc_msg 
 	DPRINTF("\n");
 
 	if (sc->sc_flag & UCOM_FLAG_LL_READY) {
-
-		sc->sc_flag &= ~(UCOM_FLAG_LL_READY |
-		    UCOM_FLAG_GP_DATA);
-
-		if (sc->sc_callback->usb2_com_cfg_close) {
+		sc->sc_flag &= ~UCOM_FLAG_LL_READY;
+		if (sc->sc_callback->usb2_com_cfg_close)
 			(sc->sc_callback->usb2_com_cfg_close) (sc);
-		}
 	} else {
 		/* already closed */
 	}
@@ -620,16 +616,11 @@ usb2_com_close(struct tty *tp)
 	    &sc->sc_close_task[0].hdr,
 	    &sc->sc_close_task[1].hdr);
 
-	sc->sc_flag &= ~(UCOM_FLAG_HL_READY |
-	    UCOM_FLAG_WR_START |
-	    UCOM_FLAG_RTS_IFLOW);
+	sc->sc_flag &= ~(UCOM_FLAG_HL_READY | UCOM_FLAG_RTS_IFLOW);
 
 	if (sc->sc_callback->usb2_com_stop_read) {
 		(sc->sc_callback->usb2_com_stop_read) (sc);
 	}
-	if (sc->sc_callback->usb2_com_stop_write) {
-		(sc->sc_callback->usb2_com_stop_write) (sc);
-	}
 }
 
 static int
@@ -1005,8 +996,6 @@ usb2_com_outwakeup(struct tty *tp)
 		/* The higher layer is not ready */
 		return;
 	}
-	sc->sc_flag |= UCOM_FLAG_WR_START;
-
 	usb2_com_start_transfers(sc);
 }
 
@@ -1028,9 +1017,8 @@ usb2_com_get_data(struct usb2_com_softc 
 
 	mtx_assert(sc->sc_mtx, MA_OWNED);
 
-	if ((!(sc->sc_flag & UCOM_FLAG_HL_READY)) ||
-	    (!(sc->sc_flag & UCOM_FLAG_GP_DATA)) ||
-	    (!(sc->sc_flag & UCOM_FLAG_WR_START))) {
+	if (tty_gone(tp) ||
+	    !(sc->sc_flag & UCOM_FLAG_GP_DATA)) {
 		actlen[0] = 0;
 		return (0);		/* multiport device polling */
 	}
@@ -1076,10 +1064,9 @@ usb2_com_put_data(struct usb2_com_softc 
 
 	mtx_assert(sc->sc_mtx, MA_OWNED);
 
-	if ((!(sc->sc_flag & UCOM_FLAG_HL_READY)) ||
-	    (!(sc->sc_flag & UCOM_FLAG_GP_DATA))) {
+	if (tty_gone(tp))
 		return;			/* multiport device polling */
-	}
+
 	if (len == 0)
 		return;			/* no data */
 

Modified: head/sys/dev/usb/serial/usb_serial.h
==============================================================================
--- head/sys/dev/usb/serial/usb_serial.h	Tue May 26 17:01:12 2009	(r192819)
+++ head/sys/dev/usb/serial/usb_serial.h	Tue May 26 17:06:36 2009	(r192820)
@@ -167,7 +167,6 @@ struct usb2_com_softc {
 #define	UCOM_FLAG_GONE		0x02	/* the device is gone */
 #define	UCOM_FLAG_ATTACHED	0x04	/* set if attached */
 #define	UCOM_FLAG_GP_DATA	0x08	/* set if get and put data is possible */
-#define	UCOM_FLAG_WR_START	0x10	/* set if write start was issued */
 #define	UCOM_FLAG_LL_READY	0x20	/* set if low layer is ready */
 #define	UCOM_FLAG_HL_READY	0x40	/* set if high layer is ready */
 	uint8_t	sc_lsr;



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