Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jmcneill-usbmp]: src/sys/dev/usb convert the remaining wakeup(xfer)'s to...
details: https://anonhg.NetBSD.org/src/rev/6ee87d9a7760
branches: jmcneill-usbmp
changeset: 771786:6ee87d9a7760
user: mrg <mrg%NetBSD.org@localhost>
date: Thu Dec 08 03:10:09 2011 +0000
description:
convert the remaining wakeup(xfer)'s to use the xfer->cv.
utoppy - untested.
diffstat:
sys/dev/usb/usbdi.c | 10 +++++-----
sys/dev/usb/usbdi_util.c | 40 ++++++++++++++++++++++++++++------------
sys/dev/usb/utoppy.c | 22 +++++++++++++++-------
3 files changed, 48 insertions(+), 24 deletions(-)
diffs (199 lines):
diff -r 77b118da4970 -r 6ee87d9a7760 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c Thu Dec 08 02:51:07 2011 +0000
+++ b/sys/dev/usb/usbdi.c Thu Dec 08 03:10:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.134.2.2 2011/12/08 02:51:08 mrg Exp $ */
+/* $NetBSD: usbdi.c,v 1.134.2.3 2011/12/08 03:10:09 mrg Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.2 2011/12/08 02:51:08 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.3 2011/12/08 03:10:09 mrg Exp $");
#include "opt_compat_netbsd.h"
#include "opt_usb.h"
@@ -314,11 +314,11 @@
if (!xfer->done) {
if (pipe->device->bus->use_polling)
panic("usbd_transfer: not done");
- if (pipe->device->bus->lock) {
+
+ if (pipe->device->bus->lock)
cv_wait(&xfer->cv, pipe->device->bus->lock);
- } else {
+ else
tsleep(xfer, PRIBIO, "usbsyn", 0);
- }
}
usbd_unlock_pipe(pipe);
return (xfer->status);
diff -r 77b118da4970 -r 6ee87d9a7760 sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c Thu Dec 08 02:51:07 2011 +0000
+++ b/sys/dev/usb/usbdi_util.c Thu Dec 08 03:10:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.c,v 1.55 2010/11/03 22:34:24 dyoung Exp $ */
+/* $NetBSD: usbdi_util.c,v 1.55.12.1 2011/12/08 03:10:09 mrg Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.55 2010/11/03 22:34:24 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.55.12.1 2011/12/08 03:10:09 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -39,11 +39,13 @@
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/device.h>
+#include <sys/bus.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdivar.h>
#include <dev/usb/usbdi_util.h>
#ifdef USB_DEBUG
@@ -419,7 +421,11 @@
usbd_bulk_transfer_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
usbd_status status)
{
- wakeup(xfer);
+
+ if (xfer->pipe->device->bus->lock)
+ cv_broadcast(&xfer->cv);
+ else
+ wakeup(xfer);
}
usbd_status
@@ -433,14 +439,17 @@
usbd_setup_xfer(xfer, pipe, 0, buf, *size,
flags, timeout, usbd_bulk_transfer_cb);
DPRINTFN(1, ("usbd_bulk_transfer: start transfer %d bytes\n", *size));
- s = splusb(); /* don't want callback until tsleep() */
+ usbd_lock_pipe(pipe); /* don't want callback until tsleep() */
err = usbd_transfer(xfer);
if (err != USBD_IN_PROGRESS) {
- splx(s);
+ usbd_unlock_pipe(pipe);
return (err);
}
- error = tsleep(xfer, PZERO | PCATCH, lbl, 0);
- splx(s);
+ if (pipe->device->bus->lock)
+ error = cv_wait_sig(&xfer->cv, pipe->device->bus->lock);
+ else
+ error = tsleep(xfer, PZERO | PCATCH, lbl, 0);
+ usbd_unlock_pipe(pipe);
if (error) {
DPRINTF(("usbd_bulk_transfer: tsleep=%d\n", error));
usbd_abort_pipe(pipe);
@@ -461,7 +470,11 @@
usbd_intr_transfer_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
usbd_status status)
{
- wakeup(xfer);
+
+ if (xfer->pipe->device->bus->lock)
+ cv_broadcast(&xfer->cv);
+ else
+ wakeup(xfer);
}
usbd_status
@@ -475,14 +488,17 @@
usbd_setup_xfer(xfer, pipe, 0, buf, *size,
flags, timeout, usbd_intr_transfer_cb);
DPRINTFN(1, ("usbd_intr_transfer: start transfer %d bytes\n", *size));
- s = splusb(); /* don't want callback until tsleep() */
+ usbd_lock_pipe(pipe); /* don't want callback until tsleep() */
err = usbd_transfer(xfer);
if (err != USBD_IN_PROGRESS) {
- splx(s);
+ usbd_unlock_pipe(pipe);
return (err);
}
- error = tsleep(xfer, PZERO | PCATCH, lbl, 0);
- splx(s);
+ if (pipe->device->bus->lock)
+ error = cv_wait_sig(&xfer->cv, pipe->device->bus->lock);
+ else
+ error = tsleep(xfer, PZERO | PCATCH, lbl, 0);
+ usbd_unlock_pipe(pipe);
if (error) {
DPRINTF(("usbd_intr_transfer: tsleep=%d\n", error));
usbd_abort_pipe(pipe);
diff -r 77b118da4970 -r 6ee87d9a7760 sys/dev/usb/utoppy.c
--- a/sys/dev/usb/utoppy.c Thu Dec 08 02:51:07 2011 +0000
+++ b/sys/dev/usb/utoppy.c Thu Dec 08 03:10:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utoppy.c,v 1.15 2010/11/03 22:34:24 dyoung Exp $ */
+/* $NetBSD: utoppy.c,v 1.15.12.1 2011/12/08 03:10:09 mrg Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: utoppy.c,v 1.15 2010/11/03 22:34:24 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: utoppy.c,v 1.15.12.1 2011/12/08 03:10:09 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -43,9 +43,11 @@
#include <sys/uio.h>
#include <sys/conf.h>
#include <sys/vnode.h>
+#include <sys/bus.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdivar.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_quirks.h>
@@ -519,7 +521,10 @@
usbd_status status)
{
- wakeup(xfer);
+ if (xfer->pipe->device->bus->lock)
+ cv_broadcast(&xfer->cv);
+ else
+ wakeup(xfer);
}
static usbd_status
@@ -532,14 +537,17 @@
usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout,
utoppy_bulk_transfer_cb);
- s = splusb();
+ usbd_lock_pipe(pipe); /* don't want callback until tsleep() */
err = usbd_transfer(xfer);
if (err != USBD_IN_PROGRESS) {
- splx(s);
+ usbd_unlock_pipe(pipe);
return (err);
}
- error = tsleep((void *)xfer, PZERO, lbl, 0);
- splx(s);
+ if (pipe->device->bus->lock)
+ error = cv_wait_sig(&xfer->cv, pipe->device->bus->lock);
+ else
+ error = tsleep((void *)xfer, PZERO, lbl, 0);
+ usbd_unlock_pipe(pipe);
if (error) {
usbd_abort_pipe(pipe);
return (USBD_INTERRUPTED);
Home |
Main Index |
Thread Index |
Old Index