summaryrefslogtreecommitdiffstats
path: root/sys/dev/rtwn
diff options
context:
space:
mode:
authoravos <avos@FreeBSD.org>2016-01-26 16:50:59 +0000
committeravos <avos@FreeBSD.org>2016-01-26 16:50:59 +0000
commit7068dcff871523b9644b64bb3e56eabd80acedf5 (patch)
tree27b835342b5efdfff984301f638875536ed7ed33 /sys/dev/rtwn
parentbe53d5f660ed4d28616fc734e38ec55324ebc93e (diff)
downloadFreeBSD-src-7068dcff871523b9644b64bb3e56eabd80acedf5.zip
FreeBSD-src-7068dcff871523b9644b64bb3e56eabd80acedf5.tar.gz
rtwn: do not start vap when initialization fails
- Start vap(s) (via ieee80211_start_all()) only when initialization succeeds; stop the first vap otherwise (via ieee80211_stop()); - Do not try to stop a device multiple times (move (sc->sc_flags & RTWN_RUNNING) check to urtwn_stop_locked()). Tested by: kevlo Reviewed by: kevlo Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D5058
Diffstat (limited to 'sys/dev/rtwn')
-rw-r--r--sys/dev/rtwn/if_rtwn.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c
index f6a5949..0d817fb 100644
--- a/sys/dev/rtwn/if_rtwn.c
+++ b/sys/dev/rtwn/if_rtwn.c
@@ -185,7 +185,7 @@ static void rtwn_iq_calib_write_results(struct rtwn_softc *, uint16_t[2],
static void rtwn_iq_calib(struct rtwn_softc *);
static void rtwn_lc_calib(struct rtwn_softc *);
static void rtwn_temp_calib(struct rtwn_softc *);
-static void rtwn_init_locked(struct rtwn_softc *);
+static int rtwn_init(struct rtwn_softc *);
static void rtwn_stop_locked(struct rtwn_softc *);
static void rtwn_stop(struct rtwn_softc *);
static void rtwn_intr(void *);
@@ -1845,19 +1845,15 @@ static void
rtwn_parent(struct ieee80211com *ic)
{
struct rtwn_softc *sc = ic->ic_softc;
- int startall = 0;
+ struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
- RTWN_LOCK(sc);
- if (ic->ic_nrunning> 0) {
- if (!(sc->sc_flags & RTWN_RUNNING)) {
- rtwn_init_locked(sc);
- startall = 1;
- }
- } else if (sc->sc_flags & RTWN_RUNNING)
- rtwn_stop_locked(sc);
- RTWN_UNLOCK(sc);
- if (startall)
- ieee80211_start_all(ic);
+ if (ic->ic_nrunning > 0) {
+ if (rtwn_init(sc) == 0)
+ ieee80211_start_all(ic);
+ else
+ ieee80211_stop(vap);
+ } else
+ rtwn_stop(sc);
}
static void
@@ -3218,8 +3214,8 @@ rtwn_temp_calib(struct rtwn_softc *sc)
}
}
-static void
-rtwn_init_locked(struct rtwn_softc *sc)
+static int
+rtwn_init(struct rtwn_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
@@ -3227,7 +3223,13 @@ rtwn_init_locked(struct rtwn_softc *sc)
uint8_t macaddr[IEEE80211_ADDR_LEN];
int i, error;
- RTWN_LOCK_ASSERT(sc);
+ RTWN_LOCK(sc);
+
+ if (sc->sc_flags & RTWN_RUNNING) {
+ RTWN_UNLOCK(sc);
+ return 0;
+ }
+ sc->sc_flags |= RTWN_RUNNING;
/* Init firmware commands ring. */
sc->fwcur = 0;
@@ -3347,13 +3349,15 @@ rtwn_init_locked(struct rtwn_softc *sc)
/* Enable interrupts. */
rtwn_write_4(sc, R92C_HIMR, RTWN_INT_ENABLE);
- sc->sc_flags |= RTWN_RUNNING;
-
callout_reset(&sc->watchdog_to, hz, rtwn_watchdog, sc);
- return;
fail:
- rtwn_stop_locked(sc);
+ if (error != 0)
+ rtwn_stop_locked(sc);
+
+ RTWN_UNLOCK(sc);
+
+ return error;
}
static void
@@ -3364,6 +3368,9 @@ rtwn_stop_locked(struct rtwn_softc *sc)
RTWN_LOCK_ASSERT(sc);
+ if (!(sc->sc_flags & RTWN_RUNNING))
+ return;
+
sc->sc_tx_timer = 0;
callout_stop(&sc->watchdog_to);
callout_stop(&sc->calib_to);
OpenPOWER on IntegriCloud