Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Support detach.



details:   https://anonhg.NetBSD.org/src/rev/0755774daa6c
branches:  trunk
changeset: 481590:0755774daa6c
user:      augustss <augustss%NetBSD.org@localhost>
date:      Wed Feb 02 11:42:29 2000 +0000

description:
Support detach.

diffstat:

 sys/dev/usb/if_aue.c |  77 ++++++++++++++++++++++++++++------------------
 sys/dev/usb/if_cue.c |  86 +++++++++++++++++++++++++++++----------------------
 2 files changed, 96 insertions(+), 67 deletions(-)

diffs (truncated from 348 to 300 lines):

diff -r 9349fc3e78e0 -r 0755774daa6c sys/dev/usb/if_aue.c
--- a/sys/dev/usb/if_aue.c      Wed Feb 02 11:41:56 2000 +0000
+++ b/sys/dev/usb/if_aue.c      Wed Feb 02 11:42:29 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_aue.c,v 1.17 2000/02/02 08:05:31 thorpej Exp $      */
+/*     $NetBSD: if_aue.c,v 1.18 2000/02/02 11:42:29 augustss Exp $     */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -879,44 +879,40 @@
 USB_DETACH(aue)
 {
        USB_DETACH_START(aue, sc);
-#if defined(__FreeBSD__)
-       struct ifnet            *ifp;
+       struct ifnet            *ifp = GET_IFP(sc);
        int                     s;
 
        DPRINTFN(2,("%s: %s: enter\n", USBDEVNAME(sc->aue_dev), __FUNCTION__));
 
        s = splusb();
 
-       ifp = &sc->arpcom.ac_if;
+       usb_untimeout(aue_tick, sc, sc->aue_stat_ch);
+
+       if (ifp->if_flags & IFF_RUNNING)
+               aue_stop(sc);
 
-       usb_untimeout(aue_tick, sc, sc->aue_stat_ch);
+#if defined(__NetBSD__)
+       mii_detach(&sc->aue_mii, MII_PHY_ANY, MII_OFFSET_ANY);
+       ifmedia_delete_instance(&sc->aue_mii.mii_media, IFM_INST_ANY);
+#if NBPFILTER > 0
+       bpfdetach(ifp);
+#endif
+       ether_ifdetach(ifp);
+#endif /* __NetBSD__ */
+
        if_detach(ifp);
 
-       if (sc->aue_ep[AUE_ENDPT_TX] != NULL)
-               usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_TX]);
-       if (sc->aue_ep[AUE_ENDPT_RX] != NULL)
-               usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_RX]);
-       if (sc->aue_ep[AUE_ENDPT_INTR] != NULL)
-               usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_INTR]);
+#ifdef DIAGNOSTIC
+       if (sc->aue_ep[AUE_ENDPT_TX] != NULL ||
+           sc->aue_ep[AUE_ENDPT_RX] != NULL ||
+           sc->aue_ep[AUE_ENDPT_INTR] != NULL)
+               printf("%s: detach has active endpoints\n",
+                      USBDEVNAME(sc->aue_dev));
+#endif
 
        splx(s);
 
        return (0);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
-       sc = sc;                /* XXX use sc */
-       /* XXX deallocate */
-
-#ifdef notyet
-       /*
-        * Our softc is about to go away, so drop our refernce
-        * to the ifnet.
-        */
-       if_delref(sc->aue_ec.ec_if);
-#else
-       return (0);
-#endif
-
-#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */
 }
 
 #if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -935,10 +931,7 @@
                break;
 
        case DVACT_DEACTIVATE:
-#ifdef notyet
-               /* First, kill off the interface. */
-               if_detach(sc->aue_ec.ec_if);
-#endif
+               if_deactivate(&sc->aue_ec.ec_if);
                sc->aue_dying = 1;
                break;
        }
@@ -1058,6 +1051,9 @@
 
        DPRINTFN(15,("%s: %s: enter\n", USBDEVNAME(sc->aue_dev),__FUNCTION__));
 
+       if (sc->aue_dying)
+               return;
+
        if (!(ifp->if_flags & IFF_RUNNING))
                return;
 
@@ -1134,6 +1130,9 @@
 
        DPRINTFN(10,("%s: %s: enter\n", USBDEVNAME(sc->aue_dev),__FUNCTION__));
 
+       if (sc->aue_dying)
+               return;
+
        if (!(ifp->if_flags & IFF_RUNNING))
                return;
 
@@ -1243,6 +1242,9 @@
        struct ifnet            *ifp = GET_IFP(sc);
        int                     s;
 
+       if (sc->aue_dying)
+               return;
+
        s = splimp();
 
        DPRINTFN(10,("%s: %s: enter status=%d\n", USBDEVNAME(sc->aue_dev),
@@ -1296,6 +1298,9 @@
        if (sc == NULL)
                return;
 
+       if (sc->aue_dying)
+               return;
+
        ifp = GET_IFP(sc);
        mii = GET_MII(sc);
        if (mii == NULL)
@@ -1380,6 +1385,9 @@
        DPRINTFN(5,("%s: %s: enter, link=%d\n", USBDEVNAME(sc->aue_dev),
                    __FUNCTION__, sc->aue_link));
 
+       if (sc->aue_dying)
+               return;
+
        if (!sc->aue_link)
                return;
 
@@ -1423,6 +1431,9 @@
 
        DPRINTFN(5,("%s: %s: enter\n", USBDEVNAME(sc->aue_dev), __FUNCTION__));
 
+       if (sc->aue_dying)
+               return;
+
        if (ifp->if_flags & IFF_RUNNING)
                return;
 
@@ -1547,6 +1558,9 @@
 
        DPRINTFN(5,("%s: %s: enter\n", USBDEVNAME(sc->aue_dev), __FUNCTION__));
 
+       if (sc->aue_dying)
+               return (0);
+
        sc->aue_link = 0;
        if (mii->mii_instance) {
                struct mii_softc        *miisc;
@@ -1591,6 +1605,9 @@
        struct mii_data         *mii;
        int                     s, error = 0;
 
+       if (sc->aue_dying)
+               return (EIO);
+
        s = splimp();
 
        switch(command) {
diff -r 9349fc3e78e0 -r 0755774daa6c sys/dev/usb/if_cue.c
--- a/sys/dev/usb/if_cue.c      Wed Feb 02 11:41:56 2000 +0000
+++ b/sys/dev/usb/if_cue.c      Wed Feb 02 11:42:29 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cue.c,v 1.3 2000/01/28 00:34:12 augustss Exp $      */
+/*     $NetBSD: if_cue.c,v 1.4 2000/02/02 11:49:55 augustss Exp $      */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -653,43 +653,36 @@
 USB_DETACH(cue)
 {
        USB_DETACH_START(cue, sc);
-#if defined(__FreeBSD__)
-       struct ifnet            *ifp;
+       struct ifnet            *ifp = GET_IFP(sc);
        int                     s;
 
        s = splusb();
 
-       sc = device_get_softc(dev);
-       ifp = &sc->arpcom.ac_if;
+       if (ifp->if_flags & IFF_RUNNING)
+               cue_stop(sc);
+
+       usb_untimeout(cue_tick, sc, sc->cue_stat_ch);
 
-       untimeout(cue_tick, sc, sc->cue_stat_ch);
+#if defined(__NetBSD__)
+#if NBPFILTER > 0
+       bpfdetach(ifp);
+#endif
+       ether_ifdetach(ifp);
+#endif /* __NetBSD__ */
+
        if_detach(ifp);
 
-       if (sc->cue_ep[CUE_ENDPT_TX] != NULL)
-               usbd_abort_pipe(sc->cue_ep[CUE_ENDPT_TX]);
-       if (sc->cue_ep[CUE_ENDPT_RX] != NULL)
-               usbd_abort_pipe(sc->cue_ep[CUE_ENDPT_RX]);
-       if (sc->cue_ep[CUE_ENDPT_INTR] != NULL)
-               usbd_abort_pipe(sc->cue_ep[CUE_ENDPT_INTR]);
+#ifdef DIAGNOSTIC
+       if (sc->cue_ep[CUE_ENDPT_TX] != NULL ||
+           sc->cue_ep[CUE_ENDPT_RX] != NULL ||
+           sc->cue_ep[CUE_ENDPT_INTR] != NULL)
+               printf("%s: detach has active endpoints\n",
+                      USBDEVNAME(sc->cue_dev));
+#endif
 
        splx(s);
 
        return (0);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
-       sc = sc;                /* XXX use sc */
-       /* XXX deallocate */
-
-#ifdef notyet
-       /*
-        * Our softc is about to go away, so drop our refernce
-        * to the ifnet.
-        */
-       if_delref(sc->cue_ec.ec_if);
-#else
-       return (0);
-#endif
-
-#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */
 }
 
 #if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -708,10 +701,8 @@
                break;
 
        case DVACT_DEACTIVATE:
-#ifdef notyet
-               /* First, kill off the interface. */
-               if_detach(sc->cue_ec.ec_if);
-#endif
+               /* Deactivate the interface. */
+               if_deactivate(&sc->cue_ec.ec_if);
                sc->cue_dying = 1;
                break;
        }
@@ -722,7 +713,8 @@
 /*
  * Initialize an RX descriptor and attach an MBUF cluster.
  */
-static int cue_newbuf(sc, c, m)
+static int
+cue_newbuf(sc, c, m)
        struct cue_softc        *sc;
        struct cue_chain        *c;
        struct mbuf             *m;
@@ -861,6 +853,9 @@
        DPRINTFN(10,("%s: %s: enter status=%d\n", USBDEVNAME(sc->cue_dev),
                     __FUNCTION__, status));
 
+       if (sc->cue_dying)
+               return;
+
        if (!(ifp->if_flags & IFF_RUNNING))
                return;
 
@@ -962,6 +957,9 @@
        struct ifnet            *ifp = GET_IFP(sc);
        int                     s;
 
+       if (sc->cue_dying)
+               return;
+
        s = splimp();
 
        DPRINTFN(10,("%s: %s: enter status=%d\n", USBDEVNAME(sc->cue_dev),
@@ -1009,12 +1007,13 @@
        struct ifnet            *ifp;
        int                     s;
 
-       s = splimp();
+       if (sc == NULL)
+               return;
 
-       if (sc == NULL) {
-               splx(s);
+       if (sc->cue_dying)
                return;
-       }
+
+       s = splimp();
 
        ifp = GET_IFP(sc);
 



Home | Main Index | Thread Index | Old Index