this make *hci use the dying flag in struct usbd_bus instead of one in
their own softc.  struct usbd_bus is required to be the first member of
*hci_softc.

the bus' dying flag is checked in usbd_is_dying(), which is used to
let the usb stack know if the hardware is a usable.

ok?

-- 
[email protected]
SDF Public Access UNIX System - http://sdf.lonestar.org

Index: pci/ohci_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/ohci_pci.c,v
retrieving revision 1.37
diff -u -p pci/ohci_pci.c
--- pci/ohci_pci.c      20 Oct 2010 20:34:19 -0000      1.37
+++ pci/ohci_pci.c      13 Dec 2010 20:17:56 -0000
@@ -162,7 +162,7 @@ ohci_pci_attach(struct device *parent, struct device *
        }
 
        /* Ignore interrupts for now */
-       sc->sc.sc_dying = 1;
+       sc->sc.sc_bus.dying = 1;
 
        config_defer(self, ohci_pci_attach_deferred);
 
@@ -180,7 +180,7 @@ ohci_pci_attach_deferred(struct device *self)
 
        s = splusb();
 
-       sc->sc.sc_dying = 0;
+       sc->sc.sc_bus.dying = 0;
        
        r = ohci_init(&sc->sc);
        if (r != USBD_NORMAL_COMPLETION) {
Index: pci/uhci_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/uhci_pci.c,v
retrieving revision 1.30
diff -u -p pci/uhci_pci.c
--- pci/uhci_pci.c      20 Oct 2010 20:34:19 -0000      1.30
+++ pci/uhci_pci.c      13 Dec 2010 20:17:56 -0000
@@ -182,7 +182,7 @@ uhci_pci_attach(struct device *parent, struct device *
        config_defer(self, uhci_pci_attach_deferred);
        
        /* Ignore interrupts for now */
-       sc->sc.sc_dying = 1;
+       sc->sc.sc_bus.dying = 1;
 
        splx(s);
 
@@ -203,7 +203,7 @@ uhci_pci_attach_deferred(struct device *self)
 
        s = splhardusb();
        
-       sc->sc.sc_dying = 0;
+       sc->sc.sc_bus.dying = 0;
        r = uhci_init(&sc->sc);
        if (r != USBD_NORMAL_COMPLETION) {
                printf("%s: init failed, error=%d\n", devname, r);
Index: usb/ehci.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ehci.c,v
retrieving revision 1.114
diff -u -p usb/ehci.c
--- usb/ehci.c  6 Dec 2010 06:09:08 -0000       1.114
+++ usb/ehci.c  13 Dec 2010 20:17:56 -0000
@@ -538,7 +538,7 @@ ehci_intr(void *v)
 {
        ehci_softc_t *sc = v;
 
-       if (sc == NULL || sc->sc_dying)
+       if (sc == NULL || sc->sc_bus.dying)
                return (0);
 
        /* If we get an interrupt while polling, then just ignore it. */
@@ -570,7 +570,7 @@ ehci_intr1(ehci_softc_t *sc)
 
        intrs = EHCI_STS_INTRS(EOREAD4(sc, EHCI_USBSTS));
        if (intrs == 0xffffffff) {
-               sc->sc_dying = 1;
+               sc->sc_bus.dying = 1;
                return (0);
        }
        if (!intrs)
@@ -588,7 +588,7 @@ ehci_intr1(ehci_softc_t *sc)
        if (eintrs & EHCI_STS_HSE) {
                printf("%s: unrecoverable error, controller halted\n",
                       sc->sc_bus.bdev.dv_xname);
-               sc->sc_dying = 1;
+               sc->sc_bus.dying = 1;
                sc->sc_bus.intr_context--;
                return (1);
        }
@@ -657,7 +657,7 @@ ehci_softintr(void *v)
        DPRINTFN(10,("%s: ehci_softintr (%d)\n", sc->sc_bus.bdev.dv_xname,
                     sc->sc_bus.intr_context));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return;
 
        sc->sc_bus.intr_context++;
@@ -990,7 +990,7 @@ ehci_waitintr(ehci_softc_t *sc, usbd_xfer_handle xfer)
        xfer->status = USBD_IN_PROGRESS;
        for (timo = xfer->timeout; timo >= 0; timo--) {
                usb_delay_ms(&sc->sc_bus, 1);
-               if (sc->sc_dying)
+               if (sc->sc_bus.dying)
                        break;
                intrs = EHCI_STS_INTRS(EOREAD4(sc, EHCI_USBSTS)) &
                        sc->sc_eintrs;
@@ -1165,7 +1165,7 @@ ehci_activate(struct device *self, int act)
        case DVACT_DEACTIVATE:
                if (sc->sc_child != NULL)
                        rv = config_deactivate(sc->sc_child);
-               sc->sc_dying = 1;
+               sc->sc_bus.dying = 1;
                break;
        }
        return (rv);
@@ -1493,7 +1493,7 @@ ehci_open(usbd_pipe_handle pipe)
        DPRINTFN(1, ("ehci_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
            pipe, addr, ed->bEndpointAddress, sc->sc_addr));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
        if (dev->myhsport) {
@@ -1740,7 +1740,7 @@ ehci_sync_hc(ehci_softc_t *sc)
        int s, error;
        int tries = 0;
 
-       if (sc->sc_dying) {
+       if (sc->sc_bus.dying) {
                DPRINTFN(2,("ehci_sync_hc: dying\n"));
                return;
        }
@@ -1941,7 +1941,7 @@ ehci_root_ctrl_start(usbd_xfer_handle xfer)
        usbd_status err;
        u_int32_t v;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -2240,7 +2240,7 @@ ehci_root_ctrl_start(usbd_xfer_handle xfer)
                        EOWRITE4(sc, port, v | EHCI_PS_PR);
                        /* Wait for reset to complete. */
                        usb_delay_ms(&sc->sc_bus, USB_PORT_ROOT_RESET_DELAY);
-                       if (sc->sc_dying) {
+                       if (sc->sc_bus.dying) {
                                err = USBD_IOERROR;
                                goto ret;
                        }
@@ -2249,7 +2249,7 @@ ehci_root_ctrl_start(usbd_xfer_handle xfer)
                        EOWRITE4(sc, port, v & ~EHCI_PS_PR);
                        /* Wait for HC to complete reset. */
                        usb_delay_ms(&sc->sc_bus, EHCI_PORT_RESET_COMPLETE);
-                       if (sc->sc_dying) {
+                       if (sc->sc_bus.dying) {
                                err = USBD_IOERROR;
                                goto ret;
                        }
@@ -2361,7 +2361,7 @@ ehci_root_intr_start(usbd_xfer_handle xfer)
        usbd_pipe_handle pipe = xfer->pipe;
        ehci_softc_t *sc = (ehci_softc_t *)pipe->device->bus;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
        sc->sc_intrxfer = xfer;
@@ -2785,7 +2785,7 @@ ehci_abort_xfer(usbd_xfer_handle xfer, usbd_status sta
 
        DPRINTF(("ehci_abort_xfer: xfer=%p pipe=%p\n", xfer, epipe));
 
-       if (sc->sc_dying) {
+       if (sc->sc_bus.dying) {
                /* If we're dying, just do the software part. */
                s = splusb();
                xfer->status = status;  /* make software ignore it */
@@ -2989,7 +2989,7 @@ ehci_abort_isoc_xfer(usbd_xfer_handle xfer, usbd_statu
 
        DPRINTF(("ehci_abort_isoc_xfer: xfer %p pipe %p\n", xfer, epipe));
 
-       if (sc->sc_dying) {
+       if (sc->sc_bus.dying) {
                s = splusb();
                xfer->status = status;
                timeout_del(&xfer->timeout_handle);
@@ -3059,7 +3059,7 @@ ehci_timeout(void *addr)
                usbd_dump_pipe(exfer->xfer.pipe);
 #endif
 
-       if (sc->sc_dying) {
+       if (sc->sc_bus.dying) {
                ehci_abort_xfer(&exfer->xfer, USBD_TIMEOUT);
                return;
        }
@@ -3098,7 +3098,7 @@ ehci_intrlist_timeout(void *arg)
        ehci_softc_t *sc = arg;
        int s;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return;
 
        s = splusb();
@@ -3129,7 +3129,7 @@ ehci_device_ctrl_start(usbd_xfer_handle xfer)
        ehci_softc_t *sc = (ehci_softc_t *)xfer->pipe->device->bus;
        usbd_status err;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -3381,7 +3381,7 @@ ehci_device_bulk_start(usbd_xfer_handle xfer)
        DPRINTFN(2, ("ehci_device_bulk_start: xfer=%p len=%u flags=%d\n",
            xfer, xfer->length, xfer->flags));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -3561,7 +3561,7 @@ ehci_device_intr_start(usbd_xfer_handle xfer)
        DPRINTFN(2, ("ehci_device_intr_start: xfer=%p len=%u flags=%d\n",
            xfer, xfer->length, xfer->flags));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -3774,7 +3774,7 @@ ehci_device_isoc_start(usbd_xfer_handle xfer)
        DPRINTFN(2, ("ehci_device_isoc_start: xfer %p len %u flags %d\n",
            xfer, xfer->length, xfer->flags));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
        /*
Index: usb/ehcivar.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/ehcivar.h,v
retrieving revision 1.20
diff -u -p usb/ehcivar.h
--- usb/ehcivar.h       29 Sep 2010 20:06:38 -0000      1.20
+++ usb/ehcivar.h       13 Dec 2010 20:17:57 -0000
@@ -164,8 +164,6 @@ typedef struct ehci_softc {
        struct timeout sc_tmo_intrlist;
 
        struct device *sc_child;                /* /dev/usb# device */
-
-       char sc_dying;
 } ehci_softc_t;
 
 #define EREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (a))
Index: usb/ohci.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ohci.c,v
retrieving revision 1.102
diff -u -p usb/ohci.c
--- usb/ohci.c  6 Dec 2010 06:09:08 -0000       1.102
+++ usb/ohci.c  13 Dec 2010 20:17:56 -0000
@@ -390,7 +390,7 @@ ohci_activate(struct device *self, int act)
        case DVACT_DEACTIVATE:
                if (sc->sc_child != NULL)
                        rv = config_deactivate(sc->sc_child);
-               sc->sc_dying = 1;
+               sc->sc_bus.dying = 1;
                break;
        }
        return (rv);
@@ -1071,7 +1071,7 @@ ohci_intr(void *p)
 {
        ohci_softc_t *sc = p;
 
-       if (sc == NULL || sc->sc_dying)
+       if (sc == NULL || sc->sc_bus.dying)
                return (0);
 
        /* If we get an interrupt while polling, then just ignore it. */
@@ -1123,7 +1123,7 @@ ohci_intr1(ohci_softc_t *sc)
        }
 
        if (intrs == 0xffffffff) {
-               sc->sc_dying = 1;
+               sc->sc_bus.dying = 1;
                return (0);
        }
 
@@ -1214,7 +1214,7 @@ ohci_rhsc_enable(void *v_sc)
        ohci_softc_t *sc = v_sc;
        int s;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return;
 
        s = splhardusb();
@@ -1297,7 +1297,7 @@ ohci_softintr(void *v)
 
        DPRINTFN(10,("ohci_softintr: enter\n"));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return;
 
        sc->sc_bus.intr_context++;
@@ -1593,7 +1593,7 @@ ohci_waitintr(ohci_softc_t *sc, usbd_xfer_handle xfer)
        xfer->status = USBD_IN_PROGRESS;
        for (timo = xfer->timeout; timo >= 0; timo--) {
                usb_delay_ms(&sc->sc_bus, 1);
-               if (sc->sc_dying)
+               if (sc->sc_bus.dying)
                        break;
                intrs = OREAD4(sc, OHCI_INTERRUPT_STATUS) & sc->sc_eintrs;
                DPRINTFN(15,("ohci_waitintr: 0x%04x\n", intrs));
@@ -1894,7 +1894,7 @@ ohci_timeout(void *addr)
 
        DPRINTF(("ohci_timeout: oxfer=%p\n", oxfer));
 
-       if (sc->sc_dying) {
+       if (sc->sc_bus.dying) {
                ohci_abort_xfer(&oxfer->xfer, USBD_TIMEOUT);
                return;
        }
@@ -2018,7 +2018,7 @@ ohci_open(usbd_pipe_handle pipe)
        DPRINTFN(1, ("ohci_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
                     pipe, addr, ed->bEndpointAddress, sc->sc_addr));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
        std = NULL;
@@ -2180,7 +2180,7 @@ ohci_abort_xfer(usbd_xfer_handle xfer, usbd_status sta
        DPRINTF(("ohci_abort_xfer: xfer=%p pipe=%p sed=%p\n", xfer, opipe,
                 sed));
 
-       if (sc->sc_dying) {
+       if (sc->sc_bus.dying) {
                /* If we're dying, just do the software part. */
                s = splusb();
                xfer->status = status;  /* make software ignore it */
@@ -2376,7 +2376,7 @@ ohci_root_ctrl_start(usbd_xfer_handle xfer)
        usbd_status err;
        u_int32_t v;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -2639,7 +2639,7 @@ ohci_root_ctrl_start(usbd_xfer_handle xfer)
                        for (i = 0; i < 5; i++) {
                                usb_delay_ms(&sc->sc_bus,
                                             USB_PORT_ROOT_RESET_DELAY);
-                               if (sc->sc_dying) {
+                               if (sc->sc_bus.dying) {
                                        err = USBD_IOERROR;
                                        goto ret;
                                }
@@ -2711,7 +2711,7 @@ ohci_root_intr_start(usbd_xfer_handle xfer)
        usbd_pipe_handle pipe = xfer->pipe;
        ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
        sc->sc_intrxfer = xfer;
@@ -2768,7 +2768,7 @@ ohci_device_ctrl_start(usbd_xfer_handle xfer)
        ohci_softc_t *sc = (ohci_softc_t *)xfer->pipe->device->bus;
        usbd_status err;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -2851,7 +2851,7 @@ ohci_device_bulk_start(usbd_xfer_handle xfer)
        int s, isread, endpt;
        usbd_status err;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -2989,7 +2989,7 @@ ohci_device_intr_start(usbd_xfer_handle xfer)
        ohci_soft_td_t *data, *tail;
        int s, len, isread, endpt;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
        DPRINTFN(3, ("ohci_device_intr_transfer: xfer=%p len=%u "
@@ -3214,7 +3214,7 @@ ohci_device_isoc_enter(usbd_xfer_handle xfer)
                    "nframes=%d\n",
                    iso->inuse, iso->next, xfer, xfer->nframes));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return;
 
        if (iso->next == -1) {
@@ -3326,7 +3326,7 @@ ohci_device_isoc_start(usbd_xfer_handle xfer)
 
        DPRINTFN(5,("ohci_device_isoc_start: xfer=%p\n", xfer));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
Index: usb/ohcivar.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/ohcivar.h,v
retrieving revision 1.30
diff -u -p usb/ohcivar.h
--- usb/ohcivar.h       7 Sep 2010 16:21:46 -0000       1.30
+++ usb/ohcivar.h       13 Dec 2010 20:17:57 -0000
@@ -128,8 +128,6 @@ typedef struct ohci_softc {
        struct timeout sc_tmo_rhsc;
 
        struct device *sc_child;
-
-       char sc_dying;
 } ohci_softc_t;
 
 struct ohci_xfer {
Index: usb/uhci.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uhci.c,v
retrieving revision 1.88
diff -u -p usb/uhci.c
--- usb/uhci.c  6 Dec 2010 06:09:08 -0000       1.88
+++ usb/uhci.c  13 Dec 2010 20:17:57 -0000
@@ -929,7 +929,7 @@ uhci_poll_hub(void *addr)
 
        DPRINTFN(20, ("uhci_poll_hub\n"));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return;
 
        timeout_del(&sc->sc_poll_handle);
@@ -1137,7 +1137,7 @@ uhci_intr(void *arg)
 {
        uhci_softc_t *sc = arg;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (0);
        if (sc->sc_bus.use_polling)
                return (0);
@@ -1154,7 +1154,7 @@ uhci_intr1(uhci_softc_t *sc)
        if (status == 0)        /* The interrupt was not for us. */
                return (0);
        if (status == 0xffffffff) {
-               sc->sc_dying = 1;
+               sc->sc_bus.dying = 1;
                return (0);
        }
 
@@ -1193,14 +1193,14 @@ uhci_intr1(uhci_softc_t *sc)
        }
        if (status & UHCI_STS_HCH) {
                /* no acknowledge needed */
-               if (!sc->sc_dying) {
+               if (!sc->sc_bus.dying) {
                        printf("%s: host controller halted\n",
                            sc->sc_bus.bdev.dv_xname);
 #ifdef UHCI_DEBUG
                        uhci_dump_all(sc);
 #endif
                }
-               sc->sc_dying = 1;
+               sc->sc_bus.dying = 1;
        }
 
        if (!ack)
@@ -1224,7 +1224,7 @@ uhci_softintr(void *v)
        DPRINTFN(10,("%s: uhci_softintr (%d)\n", sc->sc_bus.bdev.dv_xname,
                     sc->sc_bus.intr_context));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return;
 
        sc->sc_bus.intr_context++;
@@ -1452,7 +1452,7 @@ uhci_timeout(void *addr)
 
        DPRINTF(("uhci_timeout: uxfer=%p\n", uxfer));
 
-       if (sc->sc_dying) {
+       if (sc->sc_bus.dying) {
                uhci_abort_xfer(&uxfer->xfer, USBD_TIMEOUT);
                return;
        }
@@ -1788,7 +1788,7 @@ uhci_device_bulk_start(usbd_xfer_handle xfer)
        DPRINTFN(3, ("uhci_device_bulk_start: xfer=%p len=%u flags=%d ii=%p\n",
                     xfer, xfer->length, xfer->flags, ii));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -1885,7 +1885,7 @@ uhci_abort_xfer(usbd_xfer_handle xfer, usbd_status sta
 
        DPRINTFN(1,("uhci_abort_xfer: xfer=%p, status=%d\n", xfer, status));
 
-       if (sc->sc_dying) {
+       if (sc->sc_bus.dying) {
                /* If we're dying, just do the software part. */
                s = splusb();
                xfer->status = status;  /* make software ignore it */
@@ -1969,7 +1969,7 @@ uhci_device_ctrl_start(usbd_xfer_handle xfer)
        uhci_softc_t *sc = (uhci_softc_t *)xfer->pipe->device->bus;
        usbd_status err;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -2016,7 +2016,7 @@ uhci_device_intr_start(usbd_xfer_handle xfer)
        int isread, endpt;
        int i, s;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
        DPRINTFN(3,("uhci_device_intr_start: xfer=%p len=%u flags=%d\n",
@@ -2308,7 +2308,7 @@ uhci_device_isoc_enter(usbd_xfer_handle xfer)
                    "nframes=%d\n",
                    iso->inuse, iso->next, xfer, xfer->nframes));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return;
 
        if (xfer->status == USBD_IN_PROGRESS) {
@@ -2374,7 +2374,7 @@ uhci_device_isoc_start(usbd_xfer_handle xfer)
 
        DPRINTFN(5,("uhci_device_isoc_start: xfer=%p\n", xfer));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -3095,7 +3095,7 @@ uhci_root_ctrl_start(usbd_xfer_handle xfer)
        usb_port_status_t ps;
        usbd_status err;
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
 #ifdef DIAGNOSTIC
@@ -3474,7 +3474,7 @@ uhci_root_intr_start(usbd_xfer_handle xfer)
        DPRINTFN(3, ("uhci_root_intr_start: xfer=%p len=%u flags=%d\n",
                     xfer, xfer->length, xfer->flags));
 
-       if (sc->sc_dying)
+       if (sc->sc_bus.dying)
                return (USBD_IOERROR);
 
        sc->sc_ival = mstohz(xfer->pipe->endpoint->edesc->bInterval);
Index: usb/uhcivar.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/uhcivar.h,v
retrieving revision 1.23
diff -u -p usb/uhcivar.h
--- usb/uhcivar.h       7 Sep 2010 16:21:46 -0000       1.23
+++ usb/uhcivar.h       13 Dec 2010 20:17:57 -0000
@@ -159,7 +159,6 @@ typedef struct uhci_softc {
 
        char sc_isreset;
        char sc_suspend;
-       char sc_dying;
 
        LIST_HEAD(, uhci_intr_info) sc_intrhead;

Reply via email to