Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Oct 2006 12:57:48 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 107681 for review
Message-ID:  <200610111257.k9BCvm0R092482@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=107681

Change 107681 by hselasky@hselasky_mini_itx on 2006/10/11 12:57:37

	Search endpoint descriptors from the beginning,
	and not the end. Add a definition for any endpoint, 
	any direction and any type.
	New feature: Using ".type = UE_BULK_INTR" in 
	"struct usbd_config" means that the config entry
	will match either a BULK or a INTERRUPT endpoint.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/usb.h#7 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#17 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb/usb.h#7 (text+ko) ====

@@ -290,7 +290,9 @@
 #define UE_SET_DIR(a,d)	((a) | (((d)&1) << 7))
 #define UE_DIR_IN	0x80
 #define UE_DIR_OUT	0x00
+#define UE_DIR_ANY	0xff /* for internal use only! */
 #define UE_ADDR		0x0f
+#define UE_ADDR_ANY	0xff /* for internal use only! */
 #define UE_GET_ADDR(a)	((a) & UE_ADDR)
 	uByte		bmAttributes;
 #define UE_XFERTYPE	0x03
@@ -298,6 +300,8 @@
 #define  UE_ISOCHRONOUS	0x01
 #define  UE_BULK	0x02
 #define  UE_INTERRUPT	0x03
+#define  UE_BULK_INTR	0xfe /* for internal use only! */
+#define  UE_TYPE_ANY	0xff /* for internal use only! */
 #define UE_GET_XFERTYPE(a)	((a) & UE_XFERTYPE)
 #define UE_ISO_TYPE	0x0c
 #define  UE_ISO_ASYNC	0x04

==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#17 (text+ko) ====

@@ -156,38 +156,51 @@
 	      const struct usbd_config *setup)
 {
 	struct usbd_pipe *pipe;
-	u_int8_t index = setup->index;
+	uint8_t index = setup->index;
+	uint8_t ea;
+	uint8_t at;
 
 	PRINTFN(8,("udev=%p iface_index=%d address=0x%x "
 		    "type=0x%x dir=0x%x index=%d\n",
 		    udev, iface_index, setup->endpoint,
 		    setup->type, setup->direction, setup->index));
 
-	pipe = &udev->pipes_end[0];
-	while(--pipe >= &udev->pipes[0])
-	{
-		if((pipe->edesc) &&
-		   (pipe->iface_index == iface_index) &&
-		   (((pipe->edesc->bEndpointAddress & (UE_DIR_IN|UE_DIR_OUT)) == setup->direction) || (setup->direction == 0xff)) &&
-		   (((pipe->edesc->bEndpointAddress & UE_ADDR) == setup->endpoint) || (setup->endpoint == 0xff)) &&
-		   (((pipe->edesc->bmAttributes & UE_XFERTYPE) == setup->type) || (setup->type == 0xff))
-		   )
-		{
-			if(!index--)
-			{
-				goto found;
-			}
+	/* NOTE: pipes should be searched from the beginning */
+
+	for (pipe = udev->pipes;
+	     ((pipe >= udev->pipes) && 
+	      (pipe < udev->pipes_end));
+	     pipe++) {
+
+	    if ((pipe->edesc == NULL) ||
+		(pipe->iface_index != iface_index)) {
+	        continue;
+	    }
+
+	    ea = pipe->edesc->bEndpointAddress;
+	    at = pipe->edesc->bmAttributes;
+
+	    if (((setup->direction == (ea & (UE_DIR_IN|UE_DIR_OUT))) ||
+		 (setup->direction == UE_DIR_ANY)) &&
+		((setup->endpoint == (ea & UE_ADDR)) ||
+		 (setup->endpoint == UE_ADDR_ANY)) &&
+		((setup->type == (at & UE_XFERTYPE)) ||
+		 (setup->type == UE_TYPE_ANY) ||
+		 ((setup->type == UE_BULK_INTR) && (at & 2)))) {
+
+	        if(!index--) {
+		    goto found;
 		}
+	    }
 	}
 
-	/* match against default pipe last, so that "any pipe", 
+	/* Match against default pipe last, so that "any pipe", 
 	 * "any address" and "any direction" returns the first 
-	 * pipe of the interface
+	 * pipe of the interface. "iface_index" and "direction"
+	 * is ignored:
 	 */
 	if((setup->endpoint == 0) &&
-	   (setup->type == 0))
-	  /* "iface_index" and "direction" is ignored */
-	{
+	   (setup->type == 0)) {
 		pipe = &udev->default_pipe;
 		goto found;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610111257.k9BCvm0R092482>