Source-Changes-HG archive

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

[src/trunk]: src/sys/dev implement if_detach code for ne/pcmcia.



details:   https://anonhg.NetBSD.org/src/rev/6b64aae12d56
branches:  trunk
changeset: 481582:6b64aae12d56
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Feb 02 10:00:06 2000 +0000

description:
implement if_detach code for ne/pcmcia.
XXX still incomplete, ne_pcmcia_detach() commented out for safery - please test

diffstat:

 sys/dev/ic/dp8390.c           |  31 ++++++++++++++++++++++++-------
 sys/dev/ic/dp8390var.h        |   4 +++-
 sys/dev/ic/ne2000.c           |   9 ++++++++-
 sys/dev/ic/ne2000var.h        |   3 ++-
 sys/dev/pcmcia/if_ne_pcmcia.c |  31 +++++++++++++++----------------
 5 files changed, 52 insertions(+), 26 deletions(-)

diffs (147 lines):

diff -r 2d4df778d80e -r 6b64aae12d56 sys/dev/ic/dp8390.c
--- a/sys/dev/ic/dp8390.c       Wed Feb 02 09:34:51 2000 +0000
+++ b/sys/dev/ic/dp8390.c       Wed Feb 02 10:00:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dp8390.c,v 1.27 1999/09/27 23:19:12 enami Exp $        */
+/*     $NetBSD: dp8390.c,v 1.28 2000/02/02 10:00:06 itojun Exp $       */
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -1296,15 +1296,32 @@
                break;
 
        case DVACT_DEACTIVATE:
-#ifdef notyet
-               /* First, kill off the interface. */
-               if_detach(sc->sc_ec.ec_if);
+               if_deactivate(&sc->sc_ec.ec_if);
+#if 0
+               dp8390_disable(sc);
 #endif
-
-               /* Now disable the interface. */
-               dp8390_disable(sc);
                break;
        }
        splx(s);
        return (rv);
 }
+
+int
+dp8390_detach(sc)
+       struct dp8390_softc *sc;
+{
+       struct ifnet *ifp = &sc->sc_ec.ec_if;
+
+       dp8390_disable(sc);
+
+#if NRND > 0
+       rnd_detach_source(&sc->rnd_source);
+#endif
+#if NBPFILTER > 0
+       bpfdetach(ifp);
+#endif
+       ether_ifdetach(ifp);
+       if_detach(ifp);
+
+       return (0);
+}
diff -r 2d4df778d80e -r 6b64aae12d56 sys/dev/ic/dp8390var.h
--- a/sys/dev/ic/dp8390var.h    Wed Feb 02 09:34:51 2000 +0000
+++ b/sys/dev/ic/dp8390var.h    Wed Feb 02 10:00:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dp8390var.h,v 1.11 1999/02/07 01:54:50 thorpej Exp $   */
+/*     $NetBSD: dp8390var.h,v 1.12 2000/02/02 10:00:06 itojun Exp $    */
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -153,3 +153,5 @@
 void   dp8390_disable __P((struct dp8390_softc *));
 
 int    dp8390_activate __P((struct device *, enum devact));
+
+int    dp8390_detach __P((struct dp8390_softc *));
diff -r 2d4df778d80e -r 6b64aae12d56 sys/dev/ic/ne2000.c
--- a/sys/dev/ic/ne2000.c       Wed Feb 02 09:34:51 2000 +0000
+++ b/sys/dev/ic/ne2000.c       Wed Feb 02 10:00:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ne2000.c,v 1.23 1999/09/27 23:19:12 enami Exp $        */
+/*     $NetBSD: ne2000.c,v 1.24 2000/02/02 10:00:06 itojun Exp $       */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -732,3 +732,10 @@
        if (!quiet && maxwait == 0)
                printf("ne2000_writemem: failed to complete\n");
 }
+
+int
+ne2000_detach(sc)
+       struct ne2000_softc *sc;
+{
+       return dp8390_detach(&sc->sc_dp8390);
+}
diff -r 2d4df778d80e -r 6b64aae12d56 sys/dev/ic/ne2000var.h
--- a/sys/dev/ic/ne2000var.h    Wed Feb 02 09:34:51 2000 +0000
+++ b/sys/dev/ic/ne2000var.h    Wed Feb 02 10:00:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ne2000var.h,v 1.6 1999/09/27 23:19:13 enami Exp $      */
+/*     $NetBSD: ne2000var.h,v 1.7 2000/02/02 10:00:06 itojun Exp $     */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -62,5 +62,6 @@
            int *, int, int));
 int    ne2000_detect __P((bus_space_tag_t, bus_space_handle_t,
            bus_space_tag_t, bus_space_handle_t));
+int    ne2000_detach __P((struct ne2000_softc *));
 
 #endif /* _DEV_IC_NE2000VAR_H_ */
diff -r 2d4df778d80e -r 6b64aae12d56 sys/dev/pcmcia/if_ne_pcmcia.c
--- a/sys/dev/pcmcia/if_ne_pcmcia.c     Wed Feb 02 09:34:51 2000 +0000
+++ b/sys/dev/pcmcia/if_ne_pcmcia.c     Wed Feb 02 10:00:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ne_pcmcia.c,v 1.48 2000/01/26 01:27:12 thorpej Exp $        */
+/*     $NetBSD: if_ne_pcmcia.c,v 1.49 2000/02/02 10:00:07 itojun Exp $ */
 
 /*
  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
@@ -617,24 +617,23 @@
        struct device *self;
        int flags;
 {
+#if 0
        struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)self;
-
-       /* Unmap our i/o windows. */
-       pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
-       pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
-
-       /* Free our i/o space. */
-       pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
+       int rv;
 
-#ifdef notyet
-       /*
-        * Our softc is about to go away, so drop our reference
-        * to the ifnet.
-        */
-       if_delref(psc->sc_ne2000.sc_dp8390.sc_ec.ec_if);
-       return (0);
+       rv = ne2000_detach(&psc->sc_ne2000);
+       if (rv == 0) {
+               /* Unmap our i/o windows. */
+               pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
+               pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
+
+               /* Free our i/o space. */
+               pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
+       }
+
+       return rv;
 #else
-       return (EBUSY);
+       return EBUSY;
 #endif
 }
 



Home | Main Index | Thread Index | Old Index