Source-Changes-HG archive

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

[src/trunk]: src/sys/dev For all network drivers that call ether_ifattach(), ...



details:   https://anonhg.NetBSD.org/src/rev/5072fd15d47b
branches:  trunk
changeset: 486844:5072fd15d47b
user:      jhawk <jhawk%NetBSD.org@localhost>
date:      Mon May 29 17:37:12 2000 +0000

description:
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
  Ensure that softc keeps state about whether the attach succeeded,
  and make the detach function return immediately if the attach did
  not complete.

diffstat:

 sys/dev/ic/awi.c         |   9 ++++++++-
 sys/dev/ic/awivar.h      |   5 +++--
 sys/dev/ic/dp8390.c      |   9 ++++++++-
 sys/dev/ic/dp8390var.h   |   4 +++-
 sys/dev/ic/elink3.c      |   9 ++++++++-
 sys/dev/ic/elink3var.h   |   5 ++++-
 sys/dev/ic/elinkxl.c     |   9 ++++++++-
 sys/dev/ic/elinkxlvar.h  |   3 ++-
 sys/dev/ic/i82557.c      |  10 +++++++++-
 sys/dev/ic/i82557var.h   |   3 ++-
 sys/dev/ic/mb86960.c     |  23 +++++++++++++++--------
 sys/dev/ic/mb86960var.h  |   6 ++++--
 sys/dev/ic/smc91cxx.c    |  28 ++++++++++++++++++----------
 sys/dev/ic/smc91cxxvar.h |   7 +++++--
 sys/dev/isa/if_ate.c     |   4 ++--
 sys/dev/isa/if_fmv.c     |   4 ++--
 sys/dev/isa/if_sm_isa.c  |   4 ++--
 sys/dev/pcmcia/if_ray.c  |  26 ++++++++++++++++++--------
 18 files changed, 121 insertions(+), 47 deletions(-)

diffs (truncated from 623 to 300 lines):

diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/awi.c
--- a/sys/dev/ic/awi.c  Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/awi.c  Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: awi.c,v 1.16 2000/03/27 12:58:01 onoe Exp $    */
+/*     $NetBSD: awi.c,v 1.17 2000/05/29 17:37:12 jhawk Exp $   */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -344,6 +344,9 @@
 
        /* ready to accept ioctl */
        awi_unlock(sc);
+
+       /* Attach is successful. */
+       sc->sc_attached = 1;
        return 0;
 }
 
@@ -355,6 +358,10 @@
        struct ifnet *ifp = sc->sc_ifp;
        int s;
 
+       /* Succeed if there is no work to do. */
+       if (!sc->sc_attached)
+               return (0);
+
        s = splnet();
        sc->sc_invalid = 1;
        awi_stop(sc);
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/awivar.h
--- a/sys/dev/ic/awivar.h       Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/awivar.h       Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awivar.h,v 1.7 2000/03/27 12:55:00 onoe Exp $ */
+/* $NetBSD: awivar.h,v 1.8 2000/05/29 17:37:12 jhawk Exp $ */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -111,7 +111,8 @@
                                sc_start_bss:1,
                                sc_rawbpf:1,
                                sc_no_bssid:1,
-                               sc_active_scan:1;
+                               sc_active_scan:1,
+                               sc_attached:1;  /* attach has succeeded */
        int                     sc_sleep_cnt;
 
        int                     sc_mgt_timer;
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/dp8390.c
--- a/sys/dev/ic/dp8390.c       Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/dp8390.c       Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dp8390.c,v 1.36 2000/05/12 16:44:19 thorpej Exp $      */
+/*     $NetBSD: dp8390.c,v 1.37 2000/05/29 17:37:12 jhawk Exp $        */
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -160,6 +160,9 @@
        printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,
            ether_sprintf(sc->sc_enaddr));
 
+       /* The attach is successful. */
+       sc->sc_flags |= DP8390_ATTACHED;
+
        rv = 0;
 out:
        return (rv);
@@ -1332,6 +1335,10 @@
 {
        struct ifnet *ifp = &sc->sc_ec.ec_if;
 
+       /* Succeed now if there's no work to do. */
+       if ((sc->sc_flags & DP8390_ATTACHED) == 0)
+               return (0);
+
        /* dp8390_disable() checks sc->sc_enabled */
        dp8390_disable(sc);
 
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/dp8390var.h
--- a/sys/dev/ic/dp8390var.h    Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/dp8390var.h    Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dp8390var.h,v 1.18 2000/03/22 20:58:28 ws Exp $        */
+/*     $NetBSD: dp8390var.h,v 1.19 2000/05/29 17:37:12 jhawk Exp $     */
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -132,6 +132,8 @@
  */
 #define        DP8390_DO_AX88190_WORKAROUND    0x0020
 
+#define DP8390_ATTACHED                        0x0040  /* attach has succeeded */
+
 /*
  * NIC register access macros
  */
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/elink3.c
--- a/sys/dev/ic/elink3.c       Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/elink3.c       Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elink3.c,v 1.80 2000/05/07 14:03:25 martin Exp $       */
+/*     $NetBSD: elink3.c,v 1.81 2000/05/29 17:37:12 jhawk Exp $        */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -528,6 +528,9 @@
 
        ep_reset_cmd(sc, ELINK_COMMAND, RX_RESET);
        ep_reset_cmd(sc, ELINK_COMMAND, TX_RESET);
+
+       /* The attach is successful. */
+       sc->sc_flags |= ELINK_FLAGS_ATTACHED;
        return (0);
 }
 
@@ -2158,6 +2161,10 @@
        struct ep_softc *sc = (struct ep_softc *)self;
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 
+       /* Succeed now if there's no work to do. */
+       if ((sc->sc_flags & ELINK_FLAGS_ATTACHED) == 0)
+               return (0);
+
        epdisable(sc);
 
        callout_stop(&sc->sc_mii_callout);
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/elink3var.h
--- a/sys/dev/ic/elink3var.h    Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/elink3var.h    Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elink3var.h,v 1.25 2000/03/23 07:01:30 thorpej Exp $   */
+/*     $NetBSD: elink3var.h,v 1.26 2000/05/29 17:37:12 jhawk Exp $     */
 
 /*
  * Copyright (c) 1994 Herb Peyerl <hpeyerl%beer.org@localhost>
@@ -51,6 +51,7 @@
        bus_space_handle_t sc_ioh;      /* bus i/o handle               */
        bus_space_tag_t sc_memt;        /* RoadRunner only              */
        bus_space_handle_t sc_memh;     /* RoadRunner only              */
+       u_int32_t sc_flags;             /* misc. flags                  */
 #define MAX_MBS        8                       /* # of mbufs we keep around    */
        struct mbuf *mb[MAX_MBS];       /* spare mbuf storage.          */
        int     next_mb;                /* Which mbuf to use next.      */
@@ -78,6 +79,7 @@
 #define        ELINK_FLAGS_USEFIFOBUFFER               0x08000 /* RoadRunner only */
 #define        ELINK_FLAGS_USESHAREDMEM                0x10000 /* RoadRunner only */
 #define        ELINK_FLAGS_FORCENOWAIT         0x20000 /* RoadRunner only */
+#define ELINK_FLAGS_ATTACHED           0x40000 /* attach has succeeded */
 
        u_short ep_chipset;             /* Chipset family on this board */
 #define ELINK_CHIPSET_3C509            0x00    /* PIO: 3c509, 3c589 */
@@ -110,6 +112,7 @@
        int enabled;
 };
 
+
 u_int16_t epreadeeprom __P((bus_space_tag_t, bus_space_handle_t, int));
 int    epconfig __P((struct ep_softc *, u_short, u_int8_t *));
 
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/elinkxl.c
--- a/sys/dev/ic/elinkxl.c      Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/elinkxl.c      Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elinkxl.c,v 1.33 2000/05/12 16:44:19 thorpej Exp $     */
+/*     $NetBSD: elinkxl.c,v 1.34 2000/05/29 17:37:13 jhawk Exp $       */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -452,6 +452,9 @@
 
        /*  Establish callback to reset card when we reboot. */
        sc->sc_sdhook = shutdownhook_establish(ex_shutdown, sc);
+
+       /* The attach is successful. */
+       sc->ex_flags |= EX_FLAGS_ATTACHED;
        return;
 
  fail:
@@ -1561,6 +1564,10 @@
        struct ex_rxdesc *rxd;
        int i;
 
+       /* Succeed now if there's no work to do. */
+       if ((sc->ex_flags & EX_FLAGS_ATTACHED) == 0)
+               return (0);
+
        /* Unhook our tick handler. */
        callout_stop(&sc->ex_mii_callout);
 
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/elinkxlvar.h
--- a/sys/dev/ic/elinkxlvar.h   Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/elinkxlvar.h   Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elinkxlvar.h,v 1.5 2000/03/23 07:01:30 thorpej Exp $   */
+/*     $NetBSD: elinkxlvar.h,v 1.6 2000/05/29 17:37:13 jhawk Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -103,6 +103,7 @@
 #define EX_FLAGS_SNOOPING              0x0800
 #define EX_FLAGS_100MBIT               0x1000
 #define EX_FLAGS_POWERMGMT             0x2000
+#define EX_FLAGS_ATTACHED              0x4000  /* attach has succeeded */
 
        u_char  ex_bustype;             /* parent bus type (currently unused) */
 
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/i82557.c
--- a/sys/dev/ic/i82557.c       Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/i82557.c       Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i82557.c,v 1.33 2000/05/27 00:55:42 tsutsui Exp $      */
+/*     $NetBSD: i82557.c,v 1.34 2000/05/29 17:37:13 jhawk Exp $        */
 
 /*-
  * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -362,6 +362,10 @@
        if (sc->sc_powerhook == NULL) 
                printf("%s: WARNING: unable to establish power hook\n",
                    sc->sc_dev.dv_xname);
+
+       /* The attach is successful. */
+       sc->sc_flags |= FXPF_ATTACHED;
+
        return;
 
        /*
@@ -1958,6 +1962,10 @@
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
        int i;
 
+       /* Succeed now if there's no work to do. */
+       if ((sc->sc_flags & FXPF_ATTACHED) == 0)
+               return (0);
+
        /* Unhook our tick handler. */
        callout_stop(&sc->sc_callout);
 
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/i82557var.h
--- a/sys/dev/ic/i82557var.h    Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/i82557var.h    Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i82557var.h,v 1.15 2000/05/26 19:11:25 tsutsui Exp $   */
+/*     $NetBSD: i82557var.h,v 1.16 2000/05/29 17:37:13 jhawk Exp $     */
 
 /*-
  * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -197,6 +197,7 @@
 
 #define        FXPF_WANTINIT           0x01    /* want a re-init */
 #define        FXPF_MII                0x02    /* device uses MII */
+#define FXPF_ATTACHED          0x04    /* attach has succeeded */
 
        int     sc_txpending;           /* number of TX requests pending */
        int     sc_txdirty;             /* first dirty TX descriptor */
diff -r d3682f8f35a3 -r 5072fd15d47b sys/dev/ic/mb86960.c
--- a/sys/dev/ic/mb86960.c      Mon May 29 17:19:20 2000 +0000
+++ b/sys/dev/ic/mb86960.c      Mon May 29 17:37:12 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mb86960.c,v 1.39 2000/05/12 16:45:43 thorpej Exp $     */
+/*     $NetBSD: mb86960.c,v 1.40 2000/05/29 17:37:13 jhawk Exp $       */
 
 /*
  * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@@ -335,6 +335,9 @@
                    sc->sc_dev.dv_xname, buf, bbw, ram, txb, sbw);
        }
 #endif
+
+       /* The attach is successful. */
+       sc->sc_flags |= FE_FLAGS_ATTACHED;
 }
 
 /*
@@ -361,7 +364,7 @@
 {
        struct mb86960_softc *sc = ifp->if_softc;
 
-       if (sc->sc_enabled == 0) {
+       if ((sc->sc_flags & FE_FLAGS_ENABLED) == 0) {
                ifmr->ifm_active = IFM_ETHER | IFM_NONE;
                ifmr->ifm_status = 0;
                return;
@@ -1106,7 +1109,7 @@
        struct ifnet *ifp = &sc->sc_ec.ec_if;
        u_char tstat, rstat;
 
-       if (sc->sc_enabled == 0 ||
+       if ((sc->sc_flags & FE_FLAGS_ENABLED) == 0 ||
            (sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
                return (0);
 
@@ -1278,7 +1281,7 @@
 
        case SIOCADDMULTI:
        case SIOCDELMULTI:
-               if (sc->sc_enabled == 0) {
+               if ((sc->sc_flags & FE_FLAGS_ENABLED) == 0) {
                        error = EIO;
                        break;



Home | Main Index | Thread Index | Old Index