diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-05-25 22:10:40 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-05-25 22:10:40 +0000 |
commit | 2f9e7c17ae5a9e7ada93021a9d1ed2ee9835d969 (patch) | |
tree | fa1aaf27248cfc57d4bc9c9f1f066b98e93d0191 /nuttx/drivers | |
parent | 5f1c79814968af20b104c8c1b58a7792611c31b5 (diff) |
Fix packet size calculation in CDC/ACM and PL2303 USB serial drivers
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4771 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/drivers')
-rw-r--r-- | nuttx/drivers/usbdev/cdcacm.c | 13 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/pl2303.c | 13 |
2 files changed, 22 insertions, 4 deletions
diff --git a/nuttx/drivers/usbdev/cdcacm.c b/nuttx/drivers/usbdev/cdcacm.c index 24903b504e..97c9d7c773 100644 --- a/nuttx/drivers/usbdev/cdcacm.c +++ b/nuttx/drivers/usbdev/cdcacm.c @@ -318,6 +318,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv) FAR struct usbdev_ep_s *ep; FAR struct usbdev_req_s *req; FAR struct cdcacm_req_s *reqcontainer; + uint16_t reqlen; irqstate_t flags; int len; int ret = OK; @@ -337,7 +338,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv) ep = priv->epbulkin; /* Loop until either (1) we run out or write requests, or (2) cdcacm_fillrequest() - * is unable to fill the request with data (i.e., untilthere is no more data + * is unable to fill the request with data (i.e., until there is no more data * to be sent). */ @@ -345,6 +346,14 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv) priv->serdev.xmit.head, priv->serdev.xmit.tail, priv->nwrq, sq_empty(&priv->reqlist)); + /* Get the maximum number of bytes that will fit into one bulk IN request */ + +#ifdef CONFIG_CDCACM_BULKREQLEN + reqlen = MAX(CONFIG_CDCACM_BULKREQLEN, ep->maxpacket); +#else + reqlen = ep->maxpacket; +#endif + while (!sq_empty(&priv->reqlist)) { /* Peek at the request in the container at the head of the list */ @@ -354,7 +363,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv) /* Fill the request with serial TX data */ - len = cdcacm_fillrequest(priv, req->buf, req->len); + len = cdcacm_fillrequest(priv, req->buf, reqlen); if (len > 0) { /* Remove the empty container from the request list */ diff --git a/nuttx/drivers/usbdev/pl2303.c b/nuttx/drivers/usbdev/pl2303.c index a1ba667f53..8bd94ddd07 100644 --- a/nuttx/drivers/usbdev/pl2303.c +++ b/nuttx/drivers/usbdev/pl2303.c @@ -567,6 +567,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) FAR struct usbdev_ep_s *ep; FAR struct usbdev_req_s *req; FAR struct pl2303_req_s *reqcontainer; + uint16_t reqlen; irqstate_t flags; int len; int ret = OK; @@ -586,7 +587,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) ep = priv->epbulkin; /* Loop until either (1) we run out or write requests, or (2) usbclass_fillrequest() - * is unable to fill the request with data (i.e., untilthere is no more data + * is unable to fill the request with data (i.e., until there is no more data * to be sent). */ @@ -594,6 +595,14 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) priv->serdev.xmit.head, priv->serdev.xmit.tail, priv->nwrq, sq_empty(&priv->reqlist)); + /* Get the maximum number of bytes that will fit into one bulk IN request */ + +#ifdef CONFIG_PL2303_BULKREQLEN + reqlen = MAX(CONFIG_CDCACM_BULKREQLEN, ep->maxpacket); +#else + reqlen = ep->maxpacket; +#endif + while (!sq_empty(&priv->reqlist)) { /* Peek at the request in the container at the head of the list */ @@ -603,7 +612,7 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) /* Fill the request with serial TX data */ - len = usbclass_fillrequest(priv, req->buf, req->len); + len = usbclass_fillrequest(priv, req->buf, reqlen); if (len > 0) { /* Remove the empty container from the request list */ |