From 58af1b84da9f4d19845bd1eb38bb5e97ae310f87 Mon Sep 17 00:00:00 2001 From: Josef Karthauser Date: Sun, 7 Apr 2002 12:42:18 +0000 Subject: MFNetBSD: usbdi.c (1.93), usbdi.h (1.59) date: 2001/12/24 21:36:15; author: augustss; Add some more DIAGNOSTIC tests. Make usb_match_device() match on USB_PRODUCT_ANY. --- sys/dev/usb/usbdi.c | 23 +++++++++++++++++++++-- sys/dev/usb/usbdi.h | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'sys/dev/usb') diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index 9723e048bc39..0316bdc583b1 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$ */ /* @@ -765,6 +765,14 @@ 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) { printf("usbd_transfer_cb: pipe==0, xfer=%p\n", xfer); @@ -803,6 +811,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); } @@ -856,6 +865,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 +1129,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 = (const struct usb_devno *)((const char *)tbl + sz); } diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index ac6048f137d0..f5b345801791 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.h,v 1.56 2001/12/03 01:47:12 augustss Exp $ */ +/* $NetBSD: usbdi.h,v 1.57 2001/12/12 15:24:00 augustss Exp $ */ /* $FreeBSD$ */ /* @@ -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 */ -- cgit v1.2.3