summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2016-03-15 10:28:33 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2016-03-15 10:28:33 +0000
commitdbfdd20ef9ded7255ce71827e2566bd87166dcf5 (patch)
treeb646e6d0e1d9b4dd871290f902e0fe7333d634d1 /sys/dev/ic
parent9a022d6c836d0b970a4412f24d1a8797628016f0 (diff)
usbd_is_dying() can't be part of the common rtwn(4) driver code once we
merge code from urtwn(4). So timeouts must move back to the bus-specific part of the driver. ok mpi@
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/rtwn.c38
-rw-r--r--sys/dev/ic/rtwnvar.h11
2 files changed, 24 insertions, 25 deletions
diff --git a/sys/dev/ic/rtwn.c b/sys/dev/ic/rtwn.c
index 6e0a9e097c6..f1c51414c6b 100644
--- a/sys/dev/ic/rtwn.c
+++ b/sys/dev/ic/rtwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtwn.c,v 1.4 2016/03/11 14:06:37 stsp Exp $ */
+/* $OpenBSD: rtwn.c,v 1.5 2016/03/15 10:28:31 stsp Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -90,8 +90,6 @@ int rtwn_media_change(struct ifnet *);
int rtwn_ra_init(struct rtwn_softc *);
void rtwn_tsf_sync_enable(struct rtwn_softc *);
void rtwn_set_led(struct rtwn_softc *, int, int);
-void rtwn_calib_to(void *);
-void rtwn_next_scan(void *);
int rtwn_newstate(struct ieee80211com *, enum ieee80211_state, int);
void rtwn_updateedca(struct ieee80211com *);
int rtwn_set_key(struct ieee80211com *, struct ieee80211_node *,
@@ -150,9 +148,6 @@ rtwn_attach(struct device *pdev, struct rtwn_softc *sc)
sc->sc_pdev = pdev;
- timeout_set(&sc->calib_to, rtwn_calib_to, sc);
- timeout_set(&sc->scan_to, rtwn_next_scan, sc);
-
task_set(&sc->init_task, rtwn_init_task, sc);
error = rtwn_read_chipid(sc);
@@ -251,10 +246,8 @@ rtwn_detach(struct rtwn_softc *sc, int flags)
s = splnet();
- if (timeout_initialized(&sc->scan_to))
- timeout_del(&sc->scan_to);
- if (timeout_initialized(&sc->calib_to))
- timeout_del(&sc->calib_to);
+ sc->sc_ops.cancel_scan(sc->sc_ops.cookie);
+ sc->sc_ops.cancel_calib(sc->sc_ops.cookie);
task_del(systq, &sc->init_task);
@@ -678,9 +671,8 @@ rtwn_set_led(struct rtwn_softc *sc, int led, int on)
}
void
-rtwn_calib_to(void *arg)
+rtwn_calib(struct rtwn_softc *sc)
{
- struct rtwn_softc *sc = arg;
struct r92c_fw_cmd_rssi cmd;
if (sc->avg_pwdb != -1) {
@@ -695,15 +687,19 @@ rtwn_calib_to(void *arg)
/* Do temperature compensation. */
rtwn_temp_calib(sc);
- timeout_add_sec(&sc->calib_to, 2);
+ sc->sc_ops.next_calib(sc->sc_ops.cookie);
}
void
-rtwn_next_scan(void *arg)
+rtwn_next_scan(struct rtwn_softc *sc)
{
- struct rtwn_softc *sc = arg;
+ struct ieee80211com *ic = &sc->sc_ic;
+ int s;
- sc->sc_ops.next_scan(sc->sc_ops.cookie);
+ s = splnet();
+ if (ic->ic_state == IEEE80211_S_SCAN)
+ ieee80211_next_scan(&ic->ic_if);
+ splx(s);
}
int
@@ -725,7 +721,7 @@ rtwn_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
if (ostate == IEEE80211_S_RUN) {
/* Stop calibration. */
- timeout_del(&sc->calib_to);
+ sc->sc_ops.cancel_calib(sc->sc_ops.cookie);
/* Turn link LED off. */
rtwn_set_led(sc, RTWN_LED_LINK, 0);
@@ -781,7 +777,7 @@ rtwn_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
rtwn_write_1(sc, R92C_TXPAUSE,
rtwn_read_1(sc, R92C_TXPAUSE) | 0x0f);
rtwn_set_chan(sc, ic->ic_bss->ni_chan, NULL);
- timeout_add_msec(&sc->scan_to, 200);
+ sc->sc_ops.next_scan(sc->sc_ops.cookie);
break;
case IEEE80211_S_AUTH:
@@ -859,7 +855,7 @@ rtwn_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
sc->thcal_state = 0;
sc->thcal_lctemp = 0;
/* Start periodic calibration. */
- timeout_add_sec(&sc->calib_to, 2);
+ sc->sc_ops.next_calib(sc->sc_ops.cookie);
break;
}
(void)sc->sc_newstate(ic, nstate, arg);
@@ -2556,8 +2552,8 @@ rtwn_stop(struct ifnet *ifp)
s = splnet();
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
- timeout_del(&sc->scan_to);
- timeout_del(&sc->calib_to);
+ sc->sc_ops.cancel_scan(sc->sc_ops.cookie);
+ sc->sc_ops.cancel_calib(sc->sc_ops.cookie);
task_del(systq, &sc->init_task);
diff --git a/sys/dev/ic/rtwnvar.h b/sys/dev/ic/rtwnvar.h
index a4fef8b811b..fedfa8cca0b 100644
--- a/sys/dev/ic/rtwnvar.h
+++ b/sys/dev/ic/rtwnvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtwnvar.h,v 1.3 2016/03/11 14:06:37 stsp Exp $ */
+/* $OpenBSD: rtwnvar.h,v 1.4 2016/03/15 10:28:31 stsp Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -27,13 +27,16 @@ struct rtwn_ops {
void (*write_1)(void *, uint16_t, uint8_t);
void (*write_2)(void *, uint16_t, uint16_t);
void (*write_4)(void *, uint16_t, uint32_t);
- void (*next_scan)(void *);
int (*tx)(void *, struct mbuf *, struct ieee80211_node *);
int (*dma_init)(void *);
void (*enable_intr)(void *);
void (*disable_intr)(void *);
void (*stop)(void *);
int (*is_oactive)(void *);
+ void (*next_calib)(void *);
+ void (*cancel_calib)(void *);
+ void (*next_scan)(void *);
+ void (*cancel_scan)(void *);
};
struct rtwn_softc {
@@ -44,8 +47,6 @@ struct rtwn_softc {
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
- struct timeout scan_to;
- struct timeout calib_to;
struct task init_task;
int ac2idx[EDCA_NUM_AC];
u_int sc_flags;
@@ -81,3 +82,5 @@ int rtwn_detach(struct rtwn_softc *, int);
int rtwn_activate(struct rtwn_softc *, int);
int8_t rtwn_get_rssi(struct rtwn_softc *, int, void *);
void rtwn_update_avgrssi(struct rtwn_softc *, int, int8_t);
+void rtwn_calib(struct rtwn_softc *);
+void rtwn_next_scan(struct rtwn_softc *);