Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Dec 2007 18:24:48 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 131312 for review
Message-ID:  <200712201824.lBKIOm63030368@repoman.freebsd.org>

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

Change 131312 by hselasky@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;
 }



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