You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/10/29 10:51:17 UTC

[incubator-nuttx] branch master updated: xtensa/esp32: Fix SPI master DMA RX buffer memcpy size error

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new a12a79f  xtensa/esp32: Fix SPI master DMA RX buffer memcpy size error
a12a79f is described below

commit a12a79fdb38abec252a52cd642ab6fb2041a0b9d
Author: Dong Heng <do...@espressif.com>
AuthorDate: Thu Oct 29 16:55:51 2020 +0800

    xtensa/esp32: Fix SPI master DMA RX buffer memcpy size error
---
 arch/xtensa/src/esp32/esp32_spi.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/xtensa/src/esp32/esp32_spi.c b/arch/xtensa/src/esp32/esp32_spi.c
index 9de633c..f1f71b3 100644
--- a/arch/xtensa/src/esp32/esp32_spi.c
+++ b/arch/xtensa/src/esp32/esp32_spi.c
@@ -865,7 +865,8 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
                                    FAR void *rxbuffer,
                                    uint32_t nwords)
 {
-  uint32_t bytes = nwords * (priv->nbits / 8);
+  const uint32_t total = nwords * (priv->nbits / 8);
+  uint32_t bytes = total;
   uint8_t *tp;
   uint8_t *rp;
   uint32_t n;
@@ -880,9 +881,9 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
 #ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
   if (esp32_ptr_extram(txbuffer))
     {
-      alloctp = xtensa_imm_malloc(bytes);
+      alloctp = xtensa_imm_malloc(total);
       DEBUGASSERT(alloctp != NULL);
-      memcpy(alloctp, txbuffer, bytes);
+      memcpy(alloctp, txbuffer, total);
       tp = alloctp;
     }
   else
@@ -894,7 +895,7 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
 #ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
   if (esp32_ptr_extram(rxbuffer))
     {
-      allocrp = xtensa_imm_malloc(bytes);
+      allocrp = xtensa_imm_malloc(total);
       DEBUGASSERT(allocrp != NULL);
       rp = allocrp;
     }
@@ -966,7 +967,7 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
 #ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM
   if (esp32_ptr_extram(rxbuffer))
     {
-      memcpy(rxbuffer, allocrp, bytes);
+      memcpy(rxbuffer, allocrp, total);
       xtensa_imm_free(allocrp);
     }
 #endif