Thu Dec 8 22:04:56 2011 UTC ()
sync usb_subr.c and usbdivar.h with the branch entirely, and most of
usbdi.c as well.


(mrg)
diff -r1.180.6.1.2.3 -r1.180.6.1.2.4 src/sys/dev/usb/usb_subr.c
diff -r1.134.2.1.2.3 -r1.134.2.1.2.4 src/sys/dev/usb/usbdi.c
diff -r1.93.8.1.2.2 -r1.93.8.1.2.3 src/sys/dev/usb/usbdivar.h

cvs diff -r1.180.6.1.2.3 -r1.180.6.1.2.4 src/sys/dev/usb/usb_subr.c (expand / switch to context diff)
--- src/sys/dev/usb/usb_subr.c 2011/12/08 10:41:28 1.180.6.1.2.3
+++ src/sys/dev/usb/usb_subr.c 2011/12/08 22:04:56 1.180.6.1.2.4
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.180.6.1.2.3 2011/12/08 10:41:28 mrg Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.180.6.1.2.4 2011/12/08 22:04:56 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.180.6.1.2.3 2011/12/08 10:41:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.180.6.1.2.4 2011/12/08 22:04:56 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_usbverbose.h"
@@ -751,13 +751,6 @@
 		free(p, M_USB);
 		return (err);
 	}
-#if 1
-	if (dev->bus->methods->get_locks) {
-		dev->bus->methods->get_locks(dev->bus, &p->intr_lock, &p->lock);
-	} else {
-		p->intr_lock = p->lock = NULL;
-	}
-#endif
 	*pipe = p;
 	return (USBD_NORMAL_COMPLETION);
 }

cvs diff -r1.134.2.1.2.3 -r1.134.2.1.2.4 src/sys/dev/usb/usbdi.c (expand / switch to context diff)
--- src/sys/dev/usb/usbdi.c 2011/12/08 20:21:31 1.134.2.1.2.3
+++ src/sys/dev/usb/usbdi.c 2011/12/08 22:04:56 1.134.2.1.2.4
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.134.2.1.2.3 2011/12/08 20:21:31 mrg Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.134.2.1.2.4 2011/12/08 22:04:56 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.1.2.3 2011/12/08 20:21:31 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.1.2.4 2011/12/08 22:04:56 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_usb.h"
@@ -229,7 +229,6 @@
 usbd_status
 usbd_close_pipe(usbd_pipe_handle pipe)
 {
-	//int s;
 
 #ifdef DIAGNOSTIC
 	if (pipe == NULL) {
@@ -238,7 +237,6 @@
 	}
 #endif
 
-	//usbd_lock_pipe(pipe);
 	if (--pipe->refcnt != 0)
 		return (USBD_NORMAL_COMPLETION);
 	if (! SIMPLEQ_EMPTY(&pipe->queue))
@@ -246,7 +244,6 @@
 	LIST_REMOVE(pipe, next);
 	pipe->endpoint->refcnt--;
 	pipe->methods->close(pipe);
-	//usbd_lock_pipe(pipe);
 	if (pipe->intrxfer != NULL)
 		usbd_free_xfer(pipe->intrxfer);
 	free(pipe, M_USB);
@@ -319,8 +316,8 @@
 		if (pipe->device->bus->use_polling)
 			panic("usbd_transfer: not done");
 
-		if (pipe->lock)
-			cv_wait(&xfer->cv, pipe->lock);
+		if (pipe->device->bus->lock)
+			cv_wait(&xfer->cv, pipe->device->bus->lock);
 		else
 			tsleep(xfer, PRIBIO, "usbsyn", 0);
 	}
@@ -838,9 +835,11 @@
 
 	if (repeat) {
 		if (xfer->callback) {
-			if (pipe->lock) mutex_exit(pipe->lock);
+			if (pipe->device->bus->lock)
+				mutex_exit(pipe->device->bus->lock);
 			xfer->callback(xfer, xfer->priv, xfer->status);
-			if (pipe->lock) mutex_enter(pipe->lock);
+			if (pipe->device->bus->lock)
+				mutex_enter(pipe->device->bus->lock);
 		}
 		pipe->methods->done(xfer);
 	} else {
@@ -908,6 +907,8 @@
 {
 	usbd_xfer_handle xfer;
 	usbd_status err;
+
+	KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
 
 #ifdef DIAGNOSTIC
 	if (pipe == NULL) {

cvs diff -r1.93.8.1.2.2 -r1.93.8.1.2.3 src/sys/dev/usb/usbdivar.h (expand / switch to context diff)
--- src/sys/dev/usb/usbdivar.h 2011/12/08 10:41:28 1.93.8.1.2.2
+++ src/sys/dev/usb/usbdivar.h 2011/12/08 22:04:56 1.93.8.1.2.3
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdivar.h,v 1.93.8.1.2.2 2011/12/08 10:41:28 mrg Exp $	*/
+/*	$NetBSD: usbdivar.h,v 1.93.8.1.2.3 2011/12/08 22:04:56 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $	*/
 
 /*
@@ -215,9 +215,6 @@
 	char			repeat;
 	int			interval;
 
-	kmutex_t		*intr_lock;
-	kmutex_t		*lock;
-
 	/* Filled by HC driver. */
 	const struct usbd_pipe_methods *methods;
 };
@@ -304,8 +301,6 @@
 void		usb_needs_reattach(usbd_device_handle);
 void		usb_schedsoftintr(struct usbd_bus *);
 
-#define usbd_lock(m)	if (m) { s = -1; mutex_enter(m); } else s = splusb()
-#define usbd_unlock(m)	if (m) { s = -1; mutex_exit(m); } else splx(s)
 #define usbd_lock_pipe(p)	do { \
 	if ((p)->device->bus->lock) { \
 		s = -1; \