From daa6d3326cb1bdd44a704a001a27f860dca032ca Mon Sep 17 00:00:00 2001 From: thompsa Date: Tue, 26 May 2009 17:06:36 +0000 Subject: [PATCH] Do not forcefully close the write transfer when closing the tty, it needs to run to completion and drain the tty queue. --- sys/dev/usb/serial/usb_serial.c | 27 +++++++-------------------- sys/dev/usb/serial/usb_serial.h | 1 - 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c index 23d61f240540..99ec4d6b9927 100644 --- a/sys/dev/usb/serial/usb_serial.c +++ b/sys/dev/usb/serial/usb_serial.c @@ -589,13 +589,9 @@ usb2_com_cfg_close(struct usb2_proc_msg *_task) 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 *sc, struct usb2_page_cache *pc, 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 *sc, struct usb2_page_cache *pc, 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 */ diff --git a/sys/dev/usb/serial/usb_serial.h b/sys/dev/usb/serial/usb_serial.h index 7b5837a1bcc9..ddbb65b33e64 100644 --- a/sys/dev/usb/serial/usb_serial.h +++ b/sys/dev/usb/serial/usb_serial.h @@ -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;