diff options
Diffstat (limited to 'sys/dev/usb/if_urtwn.c')
-rw-r--r-- | sys/dev/usb/if_urtwn.c | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/sys/dev/usb/if_urtwn.c b/sys/dev/usb/if_urtwn.c index 555b4754479..256e4a2a996 100644 --- a/sys/dev/usb/if_urtwn.c +++ b/sys/dev/usb/if_urtwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_urtwn.c,v 1.14 2011/02/05 18:10:44 jakemsr Exp $ */ +/* $OpenBSD: if_urtwn.c,v 1.15 2011/02/09 04:25:32 jakemsr Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -369,18 +369,14 @@ urtwn_detach(struct device *self, int flags) struct ifnet *ifp = &sc->sc_ic.ic_if; int s; - s = splusb(); + s = splnet(); + /* Wait for all async commands to complete. */ + urtwn_wait_async(sc); if (timeout_initialized(&sc->scan_to)) timeout_del(&sc->scan_to); if (timeout_initialized(&sc->calib_to)) timeout_del(&sc->calib_to); - - /* Wait for all async commands to complete. */ - usb_rem_wait_task(sc->sc_udev, &sc->sc_task); - - usbd_ref_wait(sc->sc_udev); - if (ifp->if_softc != NULL) { ieee80211_ifdetach(ifp); if_detach(ifp); @@ -596,6 +592,7 @@ urtwn_task(void *arg) ring->queued--; ring->next = (ring->next + 1) % URTWN_HOST_CMD_RING_COUNT; } + wakeup(ring); splx(s); } @@ -624,7 +621,8 @@ void urtwn_wait_async(struct urtwn_softc *sc) { /* Wait for all queued asynchronous commands to complete. */ - usb_wait_task(sc->sc_udev, &sc->sc_task); + while (sc->cmdq.queued > 0) + tsleep(&sc->cmdq, 0, "cmdq", 0); } int @@ -1063,15 +1061,8 @@ urtwn_calib_to(void *arg) { struct urtwn_softc *sc = arg; - if (usbd_is_dying(sc->sc_udev)) - return; - - usbd_ref_incr(sc->sc_udev); - /* Do it in a process context. */ urtwn_do_async(sc, urtwn_calib_cb, NULL, 0); - - usbd_ref_decr(sc->sc_udev); } /* ARGSUSED */ @@ -1092,8 +1083,7 @@ urtwn_calib_cb(struct urtwn_softc *sc, void *arg) /* Do temperature compensation. */ urtwn_temp_calib(sc); - if (!usbd_is_dying(sc->sc_udev)) - timeout_add_sec(&sc->calib_to, 2); + timeout_add_sec(&sc->calib_to, 2); } void @@ -1103,17 +1093,10 @@ urtwn_next_scan(void *arg) struct ieee80211com *ic = &sc->sc_ic; int s; - if (usbd_is_dying(sc->sc_udev)) - return; - - usbd_ref_incr(sc->sc_udev); - s = splnet(); if (ic->ic_state == IEEE80211_S_SCAN) ieee80211_next_scan(&ic->ic_if); splx(s); - - usbd_ref_decr(sc->sc_udev); } int @@ -1202,8 +1185,7 @@ urtwn_newstate_cb(struct urtwn_softc *sc, void *arg) urtwn_read_1(sc, R92C_TXPAUSE) | 0x0f); urtwn_set_chan(sc, ic->ic_bss->ni_chan, NULL); - if (!usbd_is_dying(sc->sc_udev)) - timeout_add_msec(&sc->scan_to, 200); + timeout_add_msec(&sc->scan_to, 200); break; case IEEE80211_S_AUTH: @@ -1281,8 +1263,7 @@ urtwn_newstate_cb(struct urtwn_softc *sc, void *arg) sc->thcal_state = 0; sc->thcal_lctemp = 0; /* Start periodic calibration. */ - if (!usbd_is_dying(sc->sc_udev)) - timeout_add_sec(&sc->calib_to, 2); + timeout_add_sec(&sc->calib_to, 2); break; } (void)sc->sc_newstate(ic, cmd->state, cmd->arg); @@ -1945,11 +1926,6 @@ urtwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifreq *ifr; int s, error = 0; - if (usbd_is_dying(sc->sc_udev)) - return ENXIO; - - usbd_ref_incr(sc->sc_udev); - s = splnet(); switch (cmd) { @@ -2002,9 +1978,6 @@ urtwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = 0; } splx(s); - - usbd_ref_decr(sc->sc_udev); - return (error); } |