Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Hack the detach path so we do it without error m...



details:   https://anonhg.NetBSD.org/src/rev/3ea8edaa164f
branches:  trunk
changeset: 327820:3ea8edaa164f
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Mar 17 21:21:57 2014 +0000

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

diffstat:

 sys/dev/usb/umcs.c |  36 +++++++++++++++++++++---------------
 1 files changed, 21 insertions(+), 15 deletions(-)

diffs (89 lines):

diff -r aaedc932af4f -r 3ea8edaa164f sys/dev/usb/umcs.c
--- a/sys/dev/usb/umcs.c        Mon Mar 17 19:59:42 2014 +0000
+++ b/sys/dev/usb/umcs.c        Mon Mar 17 21:21:57 2014 +0000
@@ -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 @@
        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 @@
        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 @@
        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 @@
 
        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 @@
        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));



Home | Main Index | Thread Index | Old Index