Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jul 2008 11:50:33 GMT
From:      Weongyo Jeong <weongyo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 145322 for review
Message-ID:  <200807161150.m6GBoXPN039023@repoman.freebsd.org>

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

Change 145322 by weongyo@weongyo_ws on 2008/07/16 11:50:10

	restore code to handle UDESC_CONFIG type but we always get `actlen'
	of a USB transaction and set it.

Affected files ...

.. //depot/projects/ndisusb/sys/compat/ndis/subr_usbd.c#10 edit

Differences ...

==== //depot/projects/ndisusb/sys/compat/ndis/subr_usbd.c#10 (text+ko) ====

@@ -359,12 +359,43 @@
 	int actlen, i;
 	struct usb_attach_arg *uaa = device_get_ivars(dev);
 	struct usbd_urb_control_descriptor_request *ctldesc;
+	uint32_t len;
 	union usbd_urb *urb;
+	usb_config_descriptor_t cd, *cdp;
 	usbd_status status;
 
 	urb = usbd_geturb(ip);
 	ctldesc = &urb->uu_ctldesc;
-	if (ctldesc->ucd_desctype == UDESC_STRING) {
+	if (ctldesc->ucd_desctype == UDESC_CONFIG) {
+		/* Get the short config descriptor. */
+		status = usbd_get_config_desc(uaa->device, ctldesc->ucd_idx,
+		    &cd);
+		if (status != USBD_NORMAL_COMPLETION) {
+			ctldesc->ucd_trans_buflen = 0;
+			return usbd_usb2urb(status);
+		}
+		/* Get the full descriptor.  Try a few times for slow devices. */
+		len = MIN(ctldesc->ucd_trans_buflen, UGETW(cd.wTotalLength));
+		for (i = 0; i < 3; i++) {
+			status = usbd_get_desc_ndis(uaa->device,
+			    ctldesc->ucd_desctype, ctldesc->ucd_idx,
+			    len, ctldesc->ucd_trans_buf, &actlen);
+			if (status == USBD_NORMAL_COMPLETION)
+				break;
+			usbd_delay_ms(uaa->device, 200);
+		}
+		if (status != USBD_NORMAL_COMPLETION) {
+			ctldesc->ucd_trans_buflen = 0;
+			return usbd_usb2urb(status);
+		}
+
+		cdp = (usb_config_descriptor_t *)ctldesc->ucd_trans_buf;
+		if (cdp->bDescriptorType != UDESC_CONFIG) {
+			device_printf(dev, "bad desc %d\n",
+			    cdp->bDescriptorType);
+			status = USBD_INVAL;
+		}
+	} else if (ctldesc->ucd_desctype == UDESC_STRING) {
 		/* Try a few times for slow devices.  */
 		for (i = 0; i < 3; i++) {
 			status = usbd_get_string_desc(uaa->device,



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