Module Name: src
Committed By: dyoung
Date: Thu Nov 12 19:29:00 UTC 2009
Modified Files:
src/sys/dev/ic: an.c anvar.h
Log Message:
Simplify activation hook. Replace each use of sc_invalid by either
calling config_deactivate(9) or device_is_active(9).
To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/ic/an.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/anvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/an.c
diff -u src/sys/dev/ic/an.c:1.56 src/sys/dev/ic/an.c:1.57
--- src/sys/dev/ic/an.c:1.56 Tue May 12 14:25:17 2009
+++ src/sys/dev/ic/an.c Thu Nov 12 19:28:59 2009
@@ -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 <[email protected]>. 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;
+ struct an_softc *sc = device_private(self);
- s = splnet();
switch (act) {
- case DVACT_ACTIVATE:
- error = EOPNOTSUPP;
- break;
-
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;
}
Index: src/sys/dev/ic/anvar.h
diff -u src/sys/dev/ic/anvar.h:1.18 src/sys/dev/ic/anvar.h:1.19
--- src/sys/dev/ic/anvar.h:1.18 Tue May 12 14:25:17 2009
+++ src/sys/dev/ic/anvar.h Thu Nov 12 19:28:59 2009
@@ -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 <[email protected]>. All rights reserved.
@@ -114,7 +114,6 @@
enum ieee80211_state, int);
int sc_enabled;
- int sc_invalid;
int sc_attached;
int sc_bap_id;