This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 4c03d29e711bcf8f7117b951aebe5a9b16c46d12 Author: chao an <[email protected]> AuthorDate: Mon Oct 26 14:17:39 2026 +0800 drivers/usbhost/ft232r: Copy TX buffers in chunks Replace the byte-at-a-time copy from the UART TX ring to the FT232R USB bulk buffer with memcpy() over the current contiguous ring segment. The transmit worker limits each chunk by the UART head, the ring boundary, and the remaining USB packet capacity before advancing the tail. The existing write submission and uart_datasent() accounting are kept unchanged. This reduces per-byte overhead on the FT232R USB serial transmit path. Signed-off-by: chao an <[email protected]> --- drivers/usbhost/usbhost_ft232r.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/usbhost/usbhost_ft232r.c b/drivers/usbhost/usbhost_ft232r.c index 0c3e049d542..453407fc45a 100644 --- a/drivers/usbhost/usbhost_ft232r.c +++ b/drivers/usbhost/usbhost_ft232r.c @@ -974,8 +974,10 @@ static void usbhost_txdata_work(FAR void *arg) FAR struct uart_dev_s *uartdev; FAR struct uart_buffer_s *txbuf; ssize_t nwritten; + int txhead; int txndx; int txtail; + int ncopy; int ret; priv = (FAR struct usbhost_ft232r_s *)arg; @@ -1015,16 +1017,30 @@ static void usbhost_txdata_work(FAR void *arg) txndx = 0; while (txtail != txbuf->head && txndx < priv->pktsize) { - /* Copy the next byte */ + txhead = txbuf->head; + if (txtail < txhead) + { + ncopy = txhead - txtail; + } + else + { + ncopy = txbuf->size - txtail; + } + + if (ncopy > priv->pktsize - txndx) + { + ncopy = priv->pktsize - txndx; + } - priv->outbuf[txndx] = txbuf->buffer[txtail]; + memcpy(&priv->outbuf[txndx], &txbuf->buffer[txtail], ncopy); /* Increment counters and indices */ - txndx++; - if (++txtail >= txbuf->size) + txndx += ncopy; + txtail += ncopy; + if (txtail >= txbuf->size) { - txtail = 0; + txtail = 0; } }
