summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2015-10-03 16:21:06 +0000
committeradrian <adrian@FreeBSD.org>2015-10-03 16:21:06 +0000
commit4c06fae4b3c214c30ef1d2351b765ac7a3d1f4e1 (patch)
tree859e7b92f4f95f0a33158eb4f74fba613313aaa0
parent134cb4f8276cd3f33f5d941572de3c52ae3ef466 (diff)
downloadFreeBSD-src-4c06fae4b3c214c30ef1d2351b765ac7a3d1f4e1.zip
FreeBSD-src-4c06fae4b3c214c30ef1d2351b765ac7a3d1f4e1.tar.gz
rum(4): add error handling in initialization path
Tested: * Tested on WUSB54GC, STA mode. * rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528, STA mode Submitted by: <s3erios@gmail.com> Differential Revision: https://reviews.freebsd.org/D3622
-rw-r--r--sys/dev/usb/wlan/if_rum.c59
1 files changed, 32 insertions, 27 deletions
diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c
index 8823dfc..228d25b 100644
--- a/sys/dev/usb/wlan/if_rum.c
+++ b/sys/dev/usb/wlan/if_rum.c
@@ -216,7 +216,7 @@ static void rum_setpromisc(struct rum_softc *);
static const char *rum_get_rf(int);
static void rum_read_eeprom(struct rum_softc *);
static int rum_bbp_init(struct rum_softc *);
-static void rum_init(struct rum_softc *);
+static int rum_init(struct rum_softc *);
static void rum_stop(struct rum_softc *);
static void rum_load_microcode(struct rum_softc *, const uint8_t *,
size_t);
@@ -1373,24 +1373,22 @@ static void
rum_parent(struct ieee80211com *ic)
{
struct rum_softc *sc = ic->ic_softc;
- int startall = 0;
+ struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
RUM_LOCK(sc);
if (sc->sc_detached) {
RUM_UNLOCK(sc);
return;
}
+ RUM_UNLOCK(sc);
+
if (ic->ic_nrunning > 0) {
- if (!sc->sc_running) {
- rum_init(sc);
- startall = 1;
- } else
- rum_setpromisc(sc);
- } else if (sc->sc_running)
+ if (rum_init(sc) == 0)
+ ieee80211_start_all(ic);
+ else
+ ieee80211_stop(vap);
+ } else
rum_stop(sc);
- RUM_UNLOCK(sc);
- if (startall)
- ieee80211_start_all(ic);
}
static void
@@ -2043,18 +2041,19 @@ rum_bbp_init(struct rum_softc *sc)
return 0;
}
-static void
+static int
rum_init(struct rum_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
uint32_t tmp;
- usb_error_t error;
- int i, ntries;
-
- RUM_LOCK_ASSERT(sc);
+ int i, ntries, ret;
- rum_stop(sc);
+ RUM_LOCK(sc);
+ if (sc->sc_running) {
+ ret = 0;
+ goto end;
+ }
/* initialize MAC registers to default values */
for (i = 0; i < nitems(rum_def_mac); i++)
@@ -2075,11 +2074,12 @@ rum_init(struct rum_softc *sc)
if (ntries == 100) {
device_printf(sc->sc_dev,
"timeout waiting for BBP/RF to wakeup\n");
- goto fail;
+ ret = ETIMEDOUT;
+ goto end;
}
- if ((error = rum_bbp_init(sc)) != 0)
- goto fail;
+ if ((ret = rum_bbp_init(sc)) != 0)
+ goto end;
/* select default channel */
rum_select_band(sc, ic->ic_curchan);
@@ -2116,20 +2116,25 @@ rum_init(struct rum_softc *sc)
sc->sc_running = 1;
usbd_xfer_set_stall(sc->sc_xfer[RUM_BULK_WR]);
usbd_transfer_start(sc->sc_xfer[RUM_BULK_RD]);
- return;
-fail: rum_stop(sc);
-#undef N
+end: RUM_UNLOCK(sc);
+
+ if (ret != 0)
+ rum_stop(sc);
+
+ return ret;
}
static void
rum_stop(struct rum_softc *sc)
{
- RUM_LOCK_ASSERT(sc);
-
+ RUM_LOCK(sc);
+ if (!sc->sc_running) {
+ RUM_UNLOCK(sc);
+ return;
+ }
sc->sc_running = 0;
-
RUM_UNLOCK(sc);
/*
@@ -2139,7 +2144,6 @@ rum_stop(struct rum_softc *sc)
usbd_transfer_drain(sc->sc_xfer[RUM_BULK_RD]);
RUM_LOCK(sc);
-
rum_unsetup_tx_list(sc);
/* disable Rx */
@@ -2148,6 +2152,7 @@ rum_stop(struct rum_softc *sc)
/* reset ASIC */
rum_write(sc, RT2573_MAC_CSR1, RT2573_RESET_ASIC | RT2573_RESET_BBP);
rum_write(sc, RT2573_MAC_CSR1, 0);
+ RUM_UNLOCK(sc);
}
static void
OpenPOWER on IntegriCloud