PERFORCE change 131312 for review

Hans Petter Selasky hselasky at FreeBSD.org
Thu Dec 20 10:24:49 PST 2007


http://perforce.freebsd.org/chv.cgi?CH=131312

Change 131312 by hselasky at hselasky_laptop001 on 2007/12/20 18:24:11

	
	This commit is device side related.
	
	Add automagic handling of USB CDC descriptors with regard to
	the interface numbers.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/usb_template.c#5 edit

Differences ...

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

@@ -44,22 +44,40 @@
 #include <dev/usb/usb.h>
 #include <dev/usb/usb_subr.h>
 #include <dev/usb/usb_template.h>
+#include <dev/usb/usb_cdc.h>
 
 static void
 usbd_make_raw_desc(struct usbd_temp_setup *temp,
     const uint8_t *raw)
 {
 	void *dst;
+	uint8_t len;
 
 	/*
          * The first byte of any USB descriptor gives the length.
          */
 	if (raw) {
+		len = raw[0];
 		if (temp->buf) {
 			dst = USBD_ADD_BYTES(temp->buf, temp->size);
-			bcopy(raw, dst, raw[0]);
+			bcopy(raw, dst, len);
+
+			/* check if we have got a CDC union descriptor */
+
+			if ((raw[0] >= sizeof(usb_cdc_union_descriptor_t)) &&
+			    (raw[1] == UDESC_CS_INTERFACE) &&
+			    (raw[2] == UDESCSUB_CDC_UNION)) {
+				usb_cdc_union_descriptor_t *ud = (void *)dst;
+
+				/* update the interface numbers */
+
+				ud->bMasterInterface +=
+				    temp->bInterfaceNumber;
+				ud->bSlaveInterface[0] +=
+				    temp->bInterfaceNumber;
+			}
 		}
-		temp->size += raw[0];
+		temp->size += len;
 	}
 	return;
 }


More information about the p4-projects mailing list