casaroli commented on code in PR #21443:
URL: https://github.com/apache/nuttx/pull/21443#discussion_r4473336253


##########
drivers/usbhost/usbhost_composite.c:
##########
@@ -312,23 +300,59 @@ static int usbhost_copyinterface(uint8_t ifno, FAR const 
uint8_t *configdesc,
           return -EINVAL;
         }
 
-      /* Is this an interface descriptor? */
+      if (desc->type != USB_DESC_TYPE_INTERFACE)
+        {
+          offset += len;
+          continue;
+        }
+
+      ifdesc = (FAR struct usb_ifdesc_s *)&configdesc[offset];
+      if (ifdesc->ifno != ifno)

Review Comment:
   A CDC/ACM or FT232R data interface with a zero-endpoint alt 0 and bulk 
endpoints in alt 1 now fails with -EINVAL. usbhost_cfgdesc() takes the data 
interface only once (`(found & USBHOST_DATAIF_FOUND) == 0`, 
usbhost_cdcacm.c:1406, usbhost_ft232r.c:1494), so with alt 0 in the copy it 
ignores the bulk endpoints of alt 1. On master `ifdesc->neps != 0` skips alt 0 
and usbhost_cfgdesc() returns 0 (host test with the real functions, no device).
   
   Fix: in both drivers also accept a later alternate setting of the same 
interface: `((found & USBHOST_DATAIF_FOUND) == 0 || ifdesc->ifno == 
priv->dataif)`.



##########
arch/sim/src/sim/posix/sim_libusb.c:
##########
@@ -394,32 +405,101 @@ static int host_libusb_ep0outhandle(struct 
host_libusb_hostdev_s *dev,
       return LIBUSB_ERROR_NO_DEVICE;
     }
 
-  if ((ctrlreq->bRequestType & USB_TYPE_MASK) !=
-      USB_TYPE_STANDARD)
+  if ((ctrlreq->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD)
     {
-      return ret;
+      /* Class and vendor requests carry the payload of the class driver: a
+       * UVC camera is configured through SET_CUR requests on its video
+       * control interface, for instance.
+       */
+
+      ret = host_uninterruptible(libusb_control_transfer, dev->handle,
+                                 ctrlreq->bRequestType, ctrlreq->bRequest,
+                                 ctrlreq->wValue, ctrlreq->wIndex,
+                                 datareq->data, datareq->len, 0);

Review Comment:
   `libusb_control_transfer()` runs with timeout 0 in the caller under 
`priv->lock` and inside host_uninterruptible(), so a device that does not 
answer a class request stops the simulator for ever. Every other transfer in 
this file is submitted asynchronously.
   
   Fix: submit it as host_libusb_ep0inhandle() does, or give it a finite 
timeout.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to