PERFORCE change 145322 for review
Weongyo Jeong
weongyo at FreeBSD.org
Wed Jul 16 11:50:34 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=145322
Change 145322 by weongyo at 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,
More information about the p4-projects
mailing list