JianyuWang0623 commented on code in PR #21513:
URL: https://github.com/apache/nuttx/pull/21513#discussion_r4503731999
##########
drivers/usbdev/usbdev_fs.c:
##########
@@ -236,11 +238,25 @@ static int usbdev_fs_submit_wrreq(FAR struct usbdev_ep_s
*ep,
****************************************************************************/
static int usbdev_fs_submit_rdreq(FAR struct usbdev_ep_s *ep,
- FAR struct usbdev_fs_req_s *container)
+ FAR struct usbdev_fs_req_s *container,
+ size_t want)
{
+ FAR struct usbdev_fs_ep_s *fs_ep = (FAR struct usbdev_fs_ep_s *)ep->fs;
FAR struct usbdev_req_s *req = container->req;
+ size_t pending = 0;
+ uint16_t i;
+
+ for (i = 0; i < fs_ep->reqnum; i++)
+ {
+ if (&fs_ep->reqbuffer[i] != container)
+ {
+ pending += fs_ep->reqbuffer[i].req->len;
+ }
+ }
- req->len = ep->maxpacket;
+ want = ALIGN_UP(want, ep->maxpacket);
+ req->len = want > pending ? MIN(want - pending, fs_ep->reqsize) :
Review Comment:
@casaroli Right, 0 means the descriptor packet size, not maxpacket. The
buffers are already that size, so I kept the code and fixed the commit message
and PR description.
--
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]