Module Name:    src
Committed By:   martin
Date:           Mon Mar 17 21:21:57 UTC 2014

Modified Files:
        src/sys/dev/usb: umcs.c

Log Message:
Hack the detach path so we do it without error messages


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/umcs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/umcs.c
diff -u src/sys/dev/usb/umcs.c:1.3 src/sys/dev/usb/umcs.c:1.4
--- src/sys/dev/usb/umcs.c:1.3	Mon Mar 17 19:59:42 2014
+++ src/sys/dev/usb/umcs.c	Mon Mar 17 21:21:57 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: umcs.c,v 1.3 2014/03/17 19:59:42 martin Exp $ */
+/* $NetBSD: umcs.c,v 1.4 2014/03/17 21:21:57 martin Exp $ */
 /* $FreeBSD: head/sys/dev/usb/serial/umcs.c 260559 2014-01-12 11:44:28Z hselasky $ */
 
 /*-
@@ -41,7 +41,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.3 2014/03/17 19:59:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.4 2014/03/17 21:21:57 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -517,15 +517,7 @@ umcs7840_detach(device_t self, int flags
 	struct umcs7840_softc *sc = device_private(self);
 	int rv = 0, i;
 
-	/* detach children */
-	for (i = 0; i < sc->sc_numports; i++) {
-		if (sc->sc_ports[i].sc_port_ucom) {
-			rv = config_detach(sc->sc_ports[i].sc_port_ucom,
-			    flags);
-			if (rv)
-				break;
-		}
-	}
+	sc->sc_dying = true;
 
 	/* close interrupt pipe */
 	if (sc->sc_intr_pipe != NULL) {
@@ -545,6 +537,16 @@ umcs7840_detach(device_t self, int flags
 	if (sc->sc_change_wq != NULL)
 		workqueue_destroy(sc->sc_change_wq);
 
+	/* detach children */
+	for (i = 0; i < sc->sc_numports; i++) {
+		if (sc->sc_ports[i].sc_port_ucom) {
+			rv = config_detach(sc->sc_ports[i].sc_port_ucom,
+			    flags);
+			if (rv)
+				break;
+		}
+	}
+
 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
 			   sc->sc_dev);
 
@@ -587,6 +589,9 @@ umcs7840_get_status(void *self, int port
 	uint8_t	hw_lsr = 0;	/* local line status register */
 	uint8_t	hw_msr = 0;	/* local modem status register */
 
+	if (sc->sc_dying)
+		return;
+
 	/* Read LSR & MSR */
 	umcs7840_get_UART_reg(sc, pn, MCS7840_UART_REG_LSR, &hw_lsr);
 	umcs7840_get_UART_reg(sc, pn, MCS7840_UART_REG_MSR, &hw_msr);
@@ -853,6 +858,9 @@ umcs7840_port_close(void *self, int port
 
 	atomic_swap_32(&sc->sc_ports[portno].sc_port_changed, 0);
 
+	if (sc->sc_dying)
+		return;
+
 	umcs7840_set_UART_reg(sc, pn, MCS7840_UART_REG_MCR, 0);
 	umcs7840_set_UART_reg(sc, pn, MCS7840_UART_REG_IER, 0);
 
@@ -873,14 +881,12 @@ umcs7840_intr(usbd_xfer_handle xfer, usb
 	int actlen;
 	int subunit, found;
 
-	if (sc->sc_dying)
+	if (status == USBD_NOT_STARTED || status == USBD_CANCELLED
+	    || status == USBD_IOERROR)
 		return;
 
 	found = 0;
 	if (status != USBD_NORMAL_COMPLETION) {
-		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
-			return;
-
 		aprint_error_dev(sc->sc_dev,
 		    "umcs7840_intr: abnormal status: %s\n",
 		    usbd_errstr(status));

Reply via email to