summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2010-08-18 22:53:11 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2010-08-18 22:53:11 +0000
commitb407bdc832ffad927fb9076fe4e4c4b539e80c3a (patch)
treeec2e12a4daad5fec13d02b89cd9b537e12a2517f /sys
parent3ef35d99986ac820fc572f7f106892e31b0c4516 (diff)
* the detach and drain functions do the same waiting for channels to
complete outstanding requests, so use uaudio_drain in uaudio_detach. * the channel alt index can still be -1 at detach. check for this.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/uaudio.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c
index 4c83bb068c4..5753b33c408 100644
--- a/sys/dev/usb/uaudio.c
+++ b/sys/dev/usb/uaudio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uaudio.c,v 1.87 2010/07/31 02:52:16 jakemsr Exp $ */
+/* $OpenBSD: uaudio.c,v 1.88 2010/08/18 22:53:10 jakemsr Exp $ */
/* $NetBSD: uaudio.c,v 1.90 2004/10/29 17:12:53 kent Exp $ */
/*
@@ -591,20 +591,18 @@ int
uaudio_detach(struct device *self, int flags)
{
struct uaudio_softc *sc = (struct uaudio_softc *)self;
- struct chan *pchan = &sc->sc_playchan;
- struct chan *rchan = &sc->sc_recchan;
- int ms, rv = 0;
+ int rv = 0;
/*
- * sc_alts may be NULL if uaudio_identify_as() failed
+ * sc_alts may be NULL if uaudio_identify_as() failed, in
+ * which case uaudio_attach() didn't finish and there's
+ * nothing to detach.
*/
if (sc->sc_alts == NULL)
- return rv;
+ return (rv);
/* Wait for outstanding requests to complete. */
- ms = max(sc->sc_alts[pchan->altidx].sc_busy ? pchan->reqms : 0,
- sc->sc_alts[rchan->altidx].sc_busy ? rchan->reqms : 0);
- usbd_delay_ms(sc->sc_udev, UAUDIO_NCHANBUFS * ms);
+ uaudio_drain(sc);
if (sc->sc_audiodev != NULL)
rv = config_detach(sc->sc_audiodev, flags);
@@ -2237,11 +2235,13 @@ uaudio_drain(void *addr)
struct uaudio_softc *sc = addr;
struct chan *pchan = &sc->sc_playchan;
struct chan *rchan = &sc->sc_recchan;
- int ms;
+ int ms = 0;
/* Wait for outstanding requests to complete. */
- ms = max(sc->sc_alts[pchan->altidx].sc_busy ? pchan->reqms : 0,
- sc->sc_alts[rchan->altidx].sc_busy ? rchan->reqms : 0);
+ if (pchan->altidx != -1 && sc->sc_alts[pchan->altidx].sc_busy)
+ ms = max(ms, pchan->reqms);
+ if (rchan->altidx != -1 && sc->sc_alts[rchan->altidx].sc_busy)
+ ms = max(ms, rchan->reqms);
usbd_delay_ms(sc->sc_udev, UAUDIO_NCHANBUFS * ms);
return (0);