Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Add detach support.



details:   https://anonhg.NetBSD.org/src/rev/1fce916e8b9d
branches:  trunk
changeset: 482621:1fce916e8b9d
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Thu Feb 17 15:58:32 2000 +0000

description:
Add detach support.
Light cleanup.

diffstat:

 sys/dev/ic/awi.c               |  62 ++++++++++++++++++-----------------------
 sys/dev/ic/awivar.h            |   3 +-
 sys/dev/pcmcia/if_awi_pcmcia.c |  41 ++++++++++++++-------------
 3 files changed, 50 insertions(+), 56 deletions(-)

diffs (222 lines):

diff -r f452e01c4f38 -r 1fce916e8b9d sys/dev/ic/awi.c
--- a/sys/dev/ic/awi.c  Thu Feb 17 14:11:24 2000 +0000
+++ b/sys/dev/ic/awi.c  Thu Feb 17 15:58:32 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awi.c,v 1.8 1999/11/09 14:58:07 sommerfeld Exp $ */
+/* $NetBSD: awi.c,v 1.9 2000/02/17 15:58:33 sommerfeld Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -202,9 +202,6 @@
 void awi_hexdump __P((char *tag, u_int8_t *data, int len));
 void awi_card_hexdump __P((struct awi_softc *, char *tag, u_int32_t offset, int len));
 
-int awi_drop_output __P((struct ifnet *, struct mbuf *,
-    struct sockaddr *, struct rtentry *));
-void awi_drop_input __P((struct ifnet *, struct mbuf *));
 struct mbuf *awi_output_kludge __P((struct awi_softc *, struct mbuf *));
 void awi_set_timer __P((struct awi_softc *));
 void awi_restart_scan __P((struct awi_softc *));
@@ -1864,51 +1861,31 @@
        
 }
 
-int awi_activate (self, act)
+int
+awi_activate (self, act)
        struct device *self;
        enum devact act;
 {
+       struct awi_softc *sc = (struct awi_softc *)self;
+       struct ifnet *ifp = sc->sc_ifp;
        int s = splnet();
-       panic("awi_activate");
-       
-#if 0
+       int rv = 0;
+
        switch (act) {
+
        case DVACT_ACTIVATE:
                rv = EOPNOTSUPP;
                break;
 
        case DVACT_DEACTIVATE:
-#ifdef notyet
-               /* First, kill off the interface. */
-               if_detach(sc->sc_ethercom.ec_if);
-#endif
-
-               /* Now disable the interface. */
-               awidisable(sc);
+               awi_disable(sc);
+               if_deactivate(ifp);
                break;
        }
-#endif
-       splx(s);
-       
-}
 
-int
-awi_drop_output (ifp, m0, dst, rt0)
-       struct ifnet *ifp;
-       struct mbuf *m0;
-       struct sockaddr *dst;
-       struct rtentry *rt0;
-{
-       m_freem(m0);
-       return 0;
-}
+       splx(s);
 
-void
-awi_drop_input (ifp, m0)
-       struct ifnet *ifp;
-       struct mbuf *m0;
-{
-       m_freem(m0);
+       return rv;
 }
 
 int awi_attach (sc, macaddr)
@@ -1954,6 +1931,21 @@
        return 0;
 }
 
+int
+awi_detach (sc)
+       struct awi_softc *sc;
+{
+       struct ifnet *ifp = sc->sc_ifp;
+       
+#if NBPFILTER > 0
+       bpfdetach(ifp);
+#endif
+       ether_ifdetach(ifp);
+       if_detach(ifp);
+       return 0;
+}
+
+
 void
 awi_zero (sc, from, to)
        struct awi_softc *sc;
diff -r f452e01c4f38 -r 1fce916e8b9d sys/dev/ic/awivar.h
--- a/sys/dev/ic/awivar.h       Thu Feb 17 14:11:24 2000 +0000
+++ b/sys/dev/ic/awivar.h       Thu Feb 17 15:58:32 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awivar.h,v 1.4 1999/11/09 14:58:07 sommerfeld Exp $ */
+/* $NetBSD: awivar.h,v 1.5 2000/02/17 15:58:34 sommerfeld Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -147,6 +147,7 @@
 
 extern int awi_activate __P((struct device *, enum devact));
 extern int awi_attach __P((struct awi_softc *, u_int8_t *macaddr));
+extern int awi_detach __P((struct awi_softc *));
 
 #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
 #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
diff -r f452e01c4f38 -r 1fce916e8b9d sys/dev/pcmcia/if_awi_pcmcia.c
--- a/sys/dev/pcmcia/if_awi_pcmcia.c    Thu Feb 17 14:11:24 2000 +0000
+++ b/sys/dev/pcmcia/if_awi_pcmcia.c    Thu Feb 17 15:58:32 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_awi_pcmcia.c,v 1.11 2000/02/12 19:58:35 chopps Exp $ */
+/* $NetBSD: if_awi_pcmcia.c,v 1.12 2000/02/17 15:58:32 sommerfeld Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -107,7 +107,9 @@
 
        /* PCMCIA-specific goo */
        struct pcmcia_io_handle sc_pcioh;       /* PCMCIA i/o space info */
+       struct pcmcia_mem_handle sc_memh;       /* PCMCIA mem space info */
        int sc_io_window;                       /* our i/o window */
+       int sc_mem_window;                      /* our memory window */
        struct pcmcia_function *sc_pf;          /* our PCMCIA function */
 };
 
@@ -115,8 +117,9 @@
     struct pcmcia_attach_args *, struct pcmcia_config_entry *));
 
 struct cfattach awi_pcmcia_ca = {
-       sizeof(struct awi_pcmcia_softc), awi_pcmcia_match, awi_pcmcia_attach,
-       awi_pcmcia_detach, /* awi_activate */ 0
+       sizeof(struct awi_pcmcia_softc),
+       awi_pcmcia_match, awi_pcmcia_attach,
+       awi_pcmcia_detach, awi_activate
 };
 
 #if __NetBSD_Version__ <= 104120000
@@ -273,6 +276,7 @@
  fail_io_unmap:
        fail++;
        pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
+       psc->sc_io_window = -1;
 
  fail_io_free:
        fail++;
@@ -294,11 +298,12 @@
        struct awi_pcmcia_product *app;
        struct pcmcia_attach_args *pa = aux;
        struct pcmcia_config_entry *cfe;
-       struct pcmcia_mem_handle memh;
        struct awi_pcmcia_get_enaddr_args pgea;
        bus_addr_t memoff;
-       int memwin, rv;
+       int rv;
 
+       psc->sc_mem_window = -1;
+       psc->sc_io_window = -1;
 #if 0
        int i, j;
 
@@ -354,18 +359,18 @@
        sc->sc_state = AWI_ST_SELFTEST;
        printf(": %s\n", app->app_name);
 
-       if (pcmcia_mem_alloc(psc->sc_pf, AM79C930_MEM_SIZE, &memh) != 0) {
+       if (pcmcia_mem_alloc(psc->sc_pf, AM79C930_MEM_SIZE, &psc->sc_memh) != 0) {
                printf("%s: unable to allocate memory space; using i/o only\n",
                    sc->sc_dev.dv_xname);
        } else if (pcmcia_mem_map(psc->sc_pf,
            PCMCIA_WIDTH_MEM8|PCMCIA_MEM_COMMON, AM79C930_MEM_BASE,
-           AM79C930_MEM_SIZE, &memh, &memoff, &memwin)) {
+           AM79C930_MEM_SIZE, &psc->sc_memh, &memoff, &psc->sc_mem_window)) {
                printf("%s: unable to map memory space; using i/o only\n",
                    sc->sc_dev.dv_xname);
-               pcmcia_mem_free(psc->sc_pf, &memh);
+               pcmcia_mem_free(psc->sc_pf, &psc->sc_memh);
        } else {
-               sc->sc_chip.sc_memt = memh.memt;
-               sc->sc_chip.sc_memh = memh.memh;
+               sc->sc_chip.sc_memt = psc->sc_memh.memt;
+               sc->sc_chip.sc_memh = psc->sc_memh.memh;
                am79c930_chip_init(&sc->sc_chip, 1);
        }
 
@@ -418,16 +423,12 @@
        /* Free our i/o space. */
        pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
 
-#ifdef notyet
-       /*
-        * Our softc is about to go away, so drop our reference
-        * to the ifnet.
-        */
-       if_delref(psc->sc_awi.sc_ethercom.ec_if);
-       return (0);
-#else
-       return (EBUSY);
-#endif
+       if (psc->sc_mem_window != -1) {
+               pcmcia_mem_unmap (psc->sc_pf, psc->sc_mem_window);
+               pcmcia_mem_free (psc->sc_pf, &psc->sc_memh);
+       }
+       
+       return awi_detach(&psc->sc_awi);
 }
 
 /*



Home | Main Index | Thread Index | Old Index