-/* $OpenBSD: if_iwn.c,v 1.200 2018/02/01 11:21:34 stsp Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.201 2018/02/25 12:40:06 stsp Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
}
if (ic->ic_state == IEEE80211_S_SCAN) {
- if (nstate == IEEE80211_S_SCAN)
- return 0;
+ if (nstate == IEEE80211_S_SCAN) {
+ if (sc->sc_flags & IWN_FLAG_SCANNING)
+ return 0;
+ } else
+ sc->sc_flags &= ~IWN_FLAG_SCANNING;
/* Turn LED off when leaving scan state. */
iwn_set_led(sc, IWN_LED_LINK, 1, 0);
}
if (error == 0)
break;
}
- ieee80211_end_scan(ifp);
+ sc->sc_flags &= ~IWN_FLAG_SCANNING;
sc->sc_flags &= ~IWN_FLAG_BGSCAN;
+ ieee80211_end_scan(ifp);
break;
}
case IWN5000_CALIBRATION_RESULT:
hdr->len = htole16(buflen);
DPRINTF(("sending scan command nchan=%d\n", hdr->nchan));
- if (bgscan)
- sc->sc_flags |= IWN_FLAG_BGSCAN;
error = iwn_cmd(sc, IWN_CMD_SCAN, buf, buflen, 1);
- if (bgscan && error)
- sc->sc_flags &= ~IWN_FLAG_BGSCAN;
+ if (error == 0) {
+ sc->sc_flags |= IWN_FLAG_SCANNING;
+ if (bgscan)
+ sc->sc_flags |= IWN_FLAG_BGSCAN;
+ }
free(buf, M_DEVBUF, IWN_SCAN_MAXSZ);
return error;
}
/* XXX Cannot wait for status response in interrupt context. */
DELAY(100);
+ sc->sc_flags &= ~IWN_FLAG_SCANNING;
sc->sc_flags &= ~IWN_FLAG_BGSCAN;
}
struct iwn_softc *sc = ic->ic_softc;
int error;
+ if (sc->sc_flags & IWN_FLAG_SCANNING)
+ return 0;
+
error = iwn_scan(sc, IEEE80211_CHAN_2GHZ, 1);
if (error)
printf("%s: could not initiate background scan\n",
-/* $OpenBSD: if_iwnvar.h,v 1.33 2017/12/14 14:21:11 stsp Exp $ */
+/* $OpenBSD: if_iwnvar.h,v 1.34 2018/02/25 12:40:06 stsp Exp $ */
/*-
* Copyright (c) 2007, 2008
#define IWN_FLAG_ENH_SENS (1 << 7)
#define IWN_FLAG_ADV_BT_COEX (1 << 8)
#define IWN_FLAG_BGSCAN (1 << 9)
+#define IWN_FLAG_SCANNING (1 << 10)
uint8_t hw_type;