summaryrefslogtreecommitdiff
path: root/sys/dev/usb/if_run.c
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2011-02-05 18:10:45 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2011-02-05 18:10:45 +0000
commit5297b10a7d9912ed9f44f8f75487936ae5e4ab1c (patch)
treea76052f893e68b5968f34384423e42fe16bbb649 /sys/dev/usb/if_run.c
parentd1d6ddc24641be41f6a4c4f0027877d244936dc2 (diff)
* use usb_ref_{incr,decr,wait}() to avoid detaching the driver while a
process is still using the hardware. * don't add timeout(9)s if the device is detached. * add checks to see if the device has been detached before running ioctls, timeouts, and tasks. * use usb_wait_task() to wait for tasks to complete. ok damien@
Diffstat (limited to 'sys/dev/usb/if_run.c')
-rw-r--r--sys/dev/usb/if_run.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/sys/dev/usb/if_run.c b/sys/dev/usb/if_run.c
index 5d4fe93a1c0..9622756109a 100644
--- a/sys/dev/usb/if_run.c
+++ b/sys/dev/usb/if_run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_run.c,v 1.85 2011/01/30 17:31:08 tedu Exp $ */
+/* $OpenBSD: if_run.c,v 1.86 2011/02/05 18:10:44 jakemsr Exp $ */
/*-
* Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -600,22 +600,8 @@ run_detach(struct device *self, int flags)
timeout_del(&sc->calib_to);
/* wait for all queued asynchronous commands to complete */
-#if 0
- while (sc->cmdq.queued > 0)
- tsleep(&sc->cmdq, 0, "cmdq", 0);
-#endif
- /* the async commands are run in a task */
usb_rem_wait_task(sc->sc_udev, &sc->sc_task);
- /* but the task might not have run if it did not start before
- * usbd_deactivate() was called, so wakeup now. we're
- * detaching, no need to try to run more commands.
- */
- if (sc->cmdq.queued > 0) {
- sc->cmdq.queued = 0;
- wakeup(&sc->cmdq);
- }
-
usbd_ref_wait(sc->sc_udev);
if (ifp->if_softc != NULL) {
@@ -1485,7 +1471,6 @@ run_task(void *arg)
ring->queued--;
ring->next = (ring->next + 1) % RUN_HOST_CMD_RING_COUNT;
}
- wakeup(ring);
splx(s);
}
@@ -3534,8 +3519,7 @@ run_stop(struct ifnet *ifp, int disable)
s = splusb();
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
/* wait for all queued asynchronous commands to complete */
- while (sc->cmdq.queued > 0)
- tsleep(&sc->cmdq, 0, "cmdq", 0);
+ usb_wait_task(sc->sc_udev, &sc->sc_task);
splx(s);
/* disable Tx/Rx */