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 414d300e1aa71e217bf7c8fdc6cc36ea35da4aec
Author: rikaken2004 <[email protected]>
AuthorDate: Wed Sep 30 16:28:20 2026 +0800

    drivers/mmcsd/mmcsd_sdio.c: check RECVSETUP/SENDSETUP return on non-DMA 
paths
    
    The non-DMA data paths discard the return value of SDIO_RECVSETUP in
    mmcsd_readsingle() and mmcsd_readmultiple() and of SDIO_SENDSETUP in
    mmcsd_writesingle(), mmcsd_writemultiple() and the CMD56 read/write
    helpers, so when the lower half fails to set up the transfer the
    driver still issues CMD17/18/24/25/56 and the failure only surfaces
    later as an unrelated-looking transfer timeout. The DMA paths in the
    same functions all check SDIO_DMARECVSETUP/SDIO_DMASENDSETUP, cancel
    the transfer and propagate the error, so mirror that handling on the
    non-DMA paths.
    
    Signed-off-by: rikaken2004 <[email protected]>
---
 drivers/mmcsd/mmcsd_sdio.c | 56 ++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 49 insertions(+), 7 deletions(-)

diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c
index 6f2402128b0..eb99a246110 100644
--- a/drivers/mmcsd/mmcsd_sdio.c
+++ b/drivers/mmcsd/mmcsd_sdio.c
@@ -1662,7 +1662,13 @@ static ssize_t mmcsd_readsingle(FAR struct mmcsd_part_s 
*part,
   else
 #endif
     {
-      SDIO_RECVSETUP(priv->dev, buffer, priv->blocksize);
+      ret = SDIO_RECVSETUP(priv->dev, buffer, priv->blocksize);
+      if (ret != OK)
+        {
+          finfo("SDIO_RECVSETUP: error %d\n", ret);
+          SDIO_CANCEL(priv->dev);
+          return ret;
+        }
     }
 
   /* Send CMD17, READ_SINGLE_BLOCK: Read a block of the size selected
@@ -1818,7 +1824,13 @@ static ssize_t mmcsd_readmultiple(FAR struct 
mmcsd_part_s *part,
   else
 #endif
     {
-      SDIO_RECVSETUP(priv->dev, buffer, nbytes);
+      ret = SDIO_RECVSETUP(priv->dev, buffer, nbytes);
+      if (ret != OK)
+        {
+          finfo("SDIO_RECVSETUP: error %d\n", ret);
+          SDIO_CANCEL(priv->dev);
+          return ret;
+        }
     }
 
 #ifdef CONFIG_MMCSD_MMCSUPPORT
@@ -2013,7 +2025,13 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_part_s 
*part,
   else
 #endif
     {
-      SDIO_SENDSETUP(priv->dev, buffer, priv->blocksize);
+      ret = SDIO_SENDSETUP(priv->dev, buffer, priv->blocksize);
+      if (ret != OK)
+        {
+          finfo("SDIO_SENDSETUP: error %d\n", ret);
+          SDIO_CANCEL(priv->dev);
+          return ret;
+        }
     }
 
   /* If Controller needs DMA setup before write then only send CMD24 now. */
@@ -2265,7 +2283,13 @@ static ssize_t mmcsd_writemultiple(FAR struct 
mmcsd_part_s *part,
   else
 #endif
     {
-      SDIO_SENDSETUP(priv->dev, buffer, nbytes);
+      ret = SDIO_SENDSETUP(priv->dev, buffer, nbytes);
+      if (ret != OK)
+        {
+          ferr("SDIO_SENDSETUP: error %d\n", ret);
+          SDIO_CANCEL(priv->dev);
+          return ret;
+        }
     }
 
   /* If Controller needs DMA setup before write then only send CMD25 now. */
@@ -3428,7 +3452,13 @@ static int mmcsd_read_extcsd(FAR struct mmcsd_state_s 
*priv,
   else
 #endif
     {
-      SDIO_RECVSETUP(priv->dev, extcsd, 512);
+      ret = SDIO_RECVSETUP(priv->dev, extcsd, 512);
+      if (ret != OK)
+        {
+          ferr("SDIO_RECVSETUP: error %d\n", ret);
+          SDIO_CANCEL(priv->dev);
+          return ret;
+        }
     }
 
   /* Send CMD8 in data-transfer mode to obtain the
@@ -3565,7 +3595,13 @@ static int mmcsd_general_cmd_write(FAR struct 
mmcsd_state_s *priv,
   else
 #endif
     {
-      SDIO_SENDSETUP(priv->dev, buffer, priv->blocksize);
+      ret = SDIO_SENDSETUP(priv->dev, buffer, priv->blocksize);
+      if (ret != OK)
+        {
+          finfo("SDIO_SENDSETUP: error %d\n", ret);
+          SDIO_CANCEL(priv->dev);
+          return ret;
+        }
     }
 
   /* If Controller needs DMA setup before write then only send CMD24 now. */
@@ -3693,7 +3729,13 @@ static int mmcsd_general_cmd_read(FAR struct 
mmcsd_state_s *priv,
   else
 #endif
     {
-      SDIO_RECVSETUP(priv->dev, buffer, priv->blocksize);
+      ret = SDIO_RECVSETUP(priv->dev, buffer, priv->blocksize);
+      if (ret != OK)
+        {
+          finfo("SDIO_RECVSETUP: error %d\n", ret);
+          SDIO_CANCEL(priv->dev);
+          return ret;
+        }
     }
 
   /* Send CMD56: Read a sector size data and verify that good R1

Reply via email to