Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Simplify activation hook. Replace each use of sc...



details:   https://anonhg.NetBSD.org/src/rev/e4cfdac4223f
branches:  trunk
changeset: 748985:e4cfdac4223f
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Thu Nov 12 19:28:59 2009 +0000

description:
Simplify activation hook.  Replace each use of sc_invalid by either
calling config_deactivate(9) or device_is_active(9).

diffstat:

 sys/dev/ic/an.c    |  39 ++++++++++++++-------------------------
 sys/dev/ic/anvar.h |   3 +--
 2 files changed, 15 insertions(+), 27 deletions(-)

diffs (131 lines):

diff -r eacb226d7be5 -r e4cfdac4223f sys/dev/ic/an.c
--- a/sys/dev/ic/an.c   Thu Nov 12 19:25:08 2009 +0000
+++ b/sys/dev/ic/an.c   Thu Nov 12 19:28:59 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: an.c,v 1.56 2009/05/12 14:25:17 cegger Exp $   */
+/*     $NetBSD: an.c,v 1.57 2009/11/12 19:28:59 dyoung Exp $   */
 /*
  * Copyright (c) 1997, 1998, 1999
  *     Bill Paul <wpaul%ctr.columbia.edu@localhost>.  All rights reserved.
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.56 2009/05/12 14:25:17 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.57 2009/11/12 19:28:59 dyoung Exp $");
 
 #include "bpfilter.h"
 
@@ -173,11 +173,10 @@
        int chan, chan_min, chan_max;
 
        s = splnet();
-       sc->sc_invalid = 0;
 
        an_wait(sc);
        if (an_reset(sc) != 0) {
-               sc->sc_invalid = 1;
+               config_deactivate(sc->sc_dev);
                splx(s);
                return 1;
        }
@@ -417,7 +416,6 @@
                return 0;
 
        s = splnet();
-       sc->sc_invalid = 1;
        an_stop(ifp, 1);
        ieee80211_ifdetach(ic);
        if_detach(ifp);
@@ -428,23 +426,15 @@
 int
 an_activate(device_t self, enum devact act)
 {
-       struct an_softc *sc = (struct an_softc *)self;
-       int s, error = 0;
-
-       s = splnet();
-       switch (act) {
-       case DVACT_ACTIVATE:
-               error = EOPNOTSUPP;
-               break;
+       struct an_softc *sc = device_private(self);
 
+       switch (act) {
        case DVACT_DEACTIVATE:
-               sc->sc_invalid = 1;
                if_deactivate(&sc->sc_if);
-               break;
+               return 0;
+       default:
+               return EOPNOTSUPP;
        }
-       splx(s);
-
-       return error;
 }
 
 int
@@ -455,8 +445,7 @@
        int i;
        u_int16_t status;
 
-       if (!sc->sc_enabled || sc->sc_invalid ||
-           !device_is_active(sc->sc_dev) ||
+       if (!sc->sc_enabled || !device_is_active(sc->sc_dev) ||
            (ifp->if_flags & IFF_RUNNING) == 0)
                return 0;
 
@@ -468,12 +457,12 @@
 
        /* maximum 10 loops per interrupt */
        for (i = 0; i < 10; i++) {
-               if (!sc->sc_enabled || sc->sc_invalid)
+               if (!sc->sc_enabled || !device_is_active(sc->sc_dev))
                        return 1;
                if (CSR_READ_2(sc, AN_SW0) != AN_MAGIC) {
                        DPRINTF(("an_intr: magic number changed: %x\n",
                            CSR_READ_2(sc, AN_SW0)));
-                       sc->sc_invalid = 1;
+                       config_deactivate(sc->sc_dev);
                        return 1;
                }
                status = CSR_READ_2(sc, AN_EVENT_STAT);
@@ -665,7 +654,7 @@
 
        s = splnet();
        ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1);
-       if (!sc->sc_invalid) {
+       if (device_is_active(sc->sc_dev)) {
                an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0);
                CSR_WRITE_2(sc, AN_INT_EN, 0);
                an_cmd(sc, AN_CMD_DISABLE, 0);
@@ -699,9 +688,9 @@
        u_int16_t len;
        int cur, fid;
 
-       if (!sc->sc_enabled || sc->sc_invalid) {
+       if (!sc->sc_enabled || !device_is_active(sc->sc_dev)) {
                DPRINTF(("an_start: noop: enabled %d invalid %d\n",
-                   sc->sc_enabled, sc->sc_invalid));
+                   sc->sc_enabled, !device_is_active(sc->sc_dev)));
                return;
        }
 
diff -r eacb226d7be5 -r e4cfdac4223f sys/dev/ic/anvar.h
--- a/sys/dev/ic/anvar.h        Thu Nov 12 19:25:08 2009 +0000
+++ b/sys/dev/ic/anvar.h        Thu Nov 12 19:28:59 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: anvar.h,v 1.18 2009/05/12 14:25:17 cegger Exp $        */
+/*     $NetBSD: anvar.h,v 1.19 2009/11/12 19:28:59 dyoung Exp $        */
 /*
  * Copyright (c) 1997, 1998, 1999
  *     Bill Paul <wpaul%ctr.columbia.edu@localhost>.  All rights reserved.
@@ -114,7 +114,6 @@
                                    enum ieee80211_state, int);
 
        int                     sc_enabled;
-       int                     sc_invalid;
        int                     sc_attached;
 
        int                     sc_bap_id;



Home | Main Index | Thread Index | Old Index