PetteriAimonen commented on a change in pull request #3162:
URL: https://github.com/apache/incubator-nuttx/pull/3162#discussion_r600452513



##########
File path: arch/arm/src/stm32/stm32_otgfsdev.c
##########
@@ -1587,22 +1587,46 @@ static inline void stm32_ep0out_receive(FAR struct 
stm32_ep_s *privep,
 
   if (priv->ep0state == EP0STATE_SETUP_OUT)
     {
-      /* Read the data into our special buffer for SETUP data */
+      if (priv->ep0datlen < CONFIG_USBDEV_SETUP_MAXDATASIZE)
+        {
+          /* Read the data into our special buffer for SETUP data */
 
-      int readlen = MIN(CONFIG_USBDEV_SETUP_MAXDATASIZE, bcnt);
-      stm32_rxfifo_read(privep, priv->ep0data, readlen);
+          int bufspace = CONFIG_USBDEV_SETUP_MAXDATASIZE - priv->ep0datlen;
+          int readlen = MIN(bufspace, bcnt);
+          stm32_rxfifo_read(privep, priv->ep0data, readlen);
+          priv->ep0datlen += readlen;
+          bcnt -= readlen;
+        }
 
       /* Do we have to discard any excess bytes? */
 
-      stm32_rxfifo_discard(privep,  bcnt - readlen);
+      if (bcnt > 0)
+        {
+          stm32_rxfifo_discard(privep,  bcnt);
+          priv->ep0datlen += bcnt;

Review comment:
       Yeah, I didn't notice that comment. Updated now.




-- 
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.

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


Reply via email to