diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2016-06-17 07:59:17 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2016-06-17 07:59:17 +0000 |
commit | 771b1ec768f93665464b623faa90530a595e6851 (patch) | |
tree | 9acdbe3330b1b1c2282618fb9c63ec1fbe72be71 | |
parent | fa9ae5df14e6da25616834fa53c1c234b7b8248f (diff) |
Replace tsleep/wakeup by usbd_ref_incr/decr/wait to wait for the kthread
to finish on close.
Tested and ok Patrick Keshishian
ok mpi
-rw-r--r-- | sys/dev/usb/utvfu.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uvideo.c | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/sys/dev/usb/utvfu.c b/sys/dev/usb/utvfu.c index e0952bae1b2..102774056b2 100644 --- a/sys/dev/usb/utvfu.c +++ b/sys/dev/usb/utvfu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utvfu.c,v 1.6 2016/06/13 19:52:21 mglocker Exp $ */ +/* $OpenBSD: utvfu.c,v 1.7 2016/06/17 07:59:16 mglocker Exp $ */ /* * Copyright (c) 2013 Lubomir Rintel * Copyright (c) 2013 Federico Simoncelli @@ -1169,7 +1169,7 @@ utvfu_as_close(struct utvfu_softc *sc) if (sc->sc_audio.iface.pipeh != NULL) { usbd_abort_pipe(sc->sc_audio.iface.pipeh); - tsleep(&sc->sc_flags, 0, "audioclose", hz/2+1); + usbd_ref_wait(sc->sc_udev); usbd_close_pipe(sc->sc_audio.iface.pipeh); sc->sc_audio.iface.pipeh = NULL; @@ -1239,6 +1239,7 @@ utvfu_as_bulk_thread(void *arg) DPRINTF(1, "%s %s\n", DEVNAME(sc), __func__); iface = &sc->sc_audio.iface; + usbd_ref_incr(sc->sc_udev); while (ISSET(sc->sc_flags, UTVFU_FLAG_AS_RUNNING)) { usbd_setup_xfer( iface->xfer, @@ -1267,7 +1268,7 @@ utvfu_as_bulk_thread(void *arg) } CLR(sc->sc_flags, UTVFU_FLAG_AS_RUNNING); - wakeup(&sc->sc_flags); + usbd_ref_decr(sc->sc_udev); DPRINTF(1, "%s %s: exiting\n", DEVNAME(sc), __func__); diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c index be21bc2dcf7..83a48ae1100 100644 --- a/sys/dev/usb/uvideo.c +++ b/sys/dev/usb/uvideo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvideo.c,v 1.191 2016/06/15 11:40:56 mpi Exp $ */ +/* $OpenBSD: uvideo.c,v 1.192 2016/06/17 07:59:16 mglocker Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> @@ -1835,7 +1835,7 @@ uvideo_vs_close(struct uvideo_softc *sc) { if (sc->sc_vs_cur->bulk_running == 1) { sc->sc_vs_cur->bulk_running = 0; - (void)tsleep(&sc->sc_vs_cur->bulk_running, 0, "vid_close", 0); + usbd_ref_wait(sc->sc_udev); } if (sc->sc_vs_cur->pipeh) { @@ -1910,6 +1910,7 @@ uvideo_vs_start_bulk_thread(void *arg) usbd_status error; int size; + usbd_ref_incr(sc->sc_udev); while (sc->sc_vs_cur->bulk_running) { size = UGETDW(sc->sc_desc_probe.dwMaxPayloadTransferSize); @@ -1934,7 +1935,7 @@ uvideo_vs_start_bulk_thread(void *arg) (void)sc->sc_decode_stream_header(sc, sc->sc_vs_cur->bxfer.buf, size); } - wakeup(&sc->sc_vs_cur->bulk_running); + usbd_ref_decr(sc->sc_udev); kthread_exit(0); } |