summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authoraugustss <augustss@NetBSD.org>2001-12-24 21:36:15 +0000
committeraugustss <augustss@NetBSD.org>2001-12-24 21:36:15 +0000
commitbfc3660fb18aac86852ff1499f7ee2ecc21b98e6 (patch)
tree335a5ff690e63f997856204f096aa7ac4d1a4978 /sys/dev
parenta6703d1135155db209e98634661f0464f2dd98f3 (diff)
Add some more DIAGNOSTIC tests.
Make usb_match_device() match on USB_PRODUCT_ANY.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/usbdi.c24
-rw-r--r--sys/dev/usb/usbdi.h3
-rw-r--r--sys/dev/usb/usbdivar.h3
3 files changed, 25 insertions, 5 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index 30c31043e3b..fe70140ba96 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.92 2001/12/12 15:38:58 augustss Exp $ */
+/* $NetBSD: usbdi.c,v 1.93 2001/12/24 21:36:15 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.92 2001/12/12 15:38:58 augustss Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.93 2001/12/24 21:36:15 augustss Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -767,6 +767,13 @@ usb_transfer_complete(usbd_xfer_handle xfer)
DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
"actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
+#ifdef DIAGNOSTIC
+ if (xfer->busy_free != XFER_ONQU) {
+ printf("usb_transfer_complete: xfer=%p not busy 0x%08x\n",
+ xfer, xfer->busy_free);
+ return;
+ }
+#endif
#ifdef DIAGNOSTIC
if (pipe == NULL) {
@@ -806,6 +813,7 @@ usb_transfer_complete(usbd_xfer_handle xfer)
if (xfer != SIMPLEQ_FIRST(&pipe->queue))
printf("usb_transfer_complete: bad dequeue %p != %p\n",
xfer, SIMPLEQ_FIRST(&pipe->queue));
+ xfer->busy_free = XFER_BUSY;
#endif
SIMPLEQ_REMOVE_HEAD(&pipe->queue, xfer, next);
}
@@ -859,6 +867,14 @@ usb_insert_transfer(usbd_xfer_handle xfer)
DPRINTFN(5,("usb_insert_transfer: pipe=%p running=%d timeout=%d\n",
pipe, pipe->running, xfer->timeout));
+#ifdef DIAGNOSTIC
+ if (xfer->busy_free != XFER_BUSY) {
+ printf("usb_insert_transfer: xfer=%p not busy 0x%08x\n",
+ xfer, xfer->busy_free);
+ return (USBD_INVAL);
+ }
+ xfer->busy_free = XFER_ONQU;
+#endif
s = splusb();
SIMPLEQ_INSERT_TAIL(&pipe->queue, xfer, next);
if (pipe->running)
@@ -1112,7 +1128,9 @@ usb_match_device(const struct usb_devno *tbl, u_int nentries, u_int sz,
u_int16_t vendor, u_int16_t product)
{
while (nentries-- > 0) {
- if (tbl->ud_vendor == vendor && tbl->ud_product == product)
+ u_int16_t tproduct = tbl->ud_product;
+ if (tbl->ud_vendor == vendor &&
+ (tproduct == product || tproduct == USB_PRODUCT_ANY))
return (tbl);
tbl = (struct usb_devno *)((char *)tbl + sz);
}
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index b8f30b82291..1aa07fe5b13 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.h,v 1.58 2001/12/12 15:38:27 augustss Exp $ */
+/* $NetBSD: usbdi.h,v 1.59 2001/12/24 21:36:15 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@@ -201,6 +201,7 @@ const struct usb_devno *usb_match_device(const struct usb_devno *tbl,
u_int nentries, u_int sz, u_int16_t vendor, u_int16_t product);
#define usb_lookup(tbl, vendor, product) \
usb_match_device((const struct usb_devno *)(tbl), sizeof (tbl) / sizeof ((tbl)[0]), sizeof ((tbl)[0]), (vendor), (product))
+#define USB_PRODUCT_ANY 0xffff
/* NetBSD attachment information */
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index 85e8e9de42b..0ec3901220c 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdivar.h,v 1.67 2001/11/21 13:44:47 augustss Exp $ */
+/* $NetBSD: usbdivar.h,v 1.68 2001/12/24 21:36:16 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */
/*
@@ -197,6 +197,7 @@ struct usbd_xfer {
u_int32_t busy_free;
#define XFER_FREE 0x46524545
#define XFER_BUSY 0x42555357
+#define XFER_ONQU 0x504f5255
#endif
/* For control pipe */