From b7073a366b36a0fef7ed73474ef51a87afbff879 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Tue, 29 Oct 2019 10:03:18 -0600 Subject: [PATCH] drivers/mmcsd/mmcsd_sdio.c: Set wrbusy after success of all the operations. Any failure could leave wrbusy set when it should not be if the operation failed. --- drivers/mmcsd/mmcsd_sdio.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index 6a05f3abc04..8882fc49c35 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -1823,12 +1823,6 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv, SDIO_SENDSETUP(priv->dev, buffer, priv->blocksize); } - /* Flag that a write transfer is pending that we will have to check for - * write complete at the beginning of the next transfer. - */ - - priv->wrbusy = true; - /* If Controller needs DMA setup before write then only send CMD24 now. */ if ((priv->caps & SDIO_CAPS_DMABEFOREWRITE) != 0) @@ -1854,6 +1848,12 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv, return ret; } + /* Flag that a write transfer is pending that we will have to check for + * write complete at the beginning of the next transfer. + */ + + priv->wrbusy = true; + #if defined(CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE) /* Arm the write complete detection with timeout */ @@ -2026,12 +2026,6 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv, SDIO_SENDSETUP(priv->dev, buffer, nbytes); } - /* Flag that a write transfer is pending that we will have to check for - * write complete at the beginning of the next transfer. - */ - - priv->wrbusy = true; - /* If Controller needs DMA setup before write then only send CMD25 now. */ if ((priv->caps & SDIO_CAPS_DMABEFOREWRITE) != 0) @@ -2078,6 +2072,12 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv, return ret; } + /* Flag that a write transfer is pending that we will have to check for + * write complete at the beginning of the next transfer. + */ + + priv->wrbusy = true; + /* On success, return the number of blocks written */ return nblocks; @@ -3493,9 +3493,10 @@ static int mmcsd_removed(FAR struct mmcsd_state_s *priv) priv->capacity = 0; /* Capacity=0 sometimes means no media */ priv->blocksize = 0; - priv->mediachanged = false; - priv->type = MMCSD_CARDTYPE_UNKNOWN; priv->probed = false; + priv->mediachanged = false; + priv->wrbusy = false; + priv->type = MMCSD_CARDTYPE_UNKNOWN; priv->rca = 0; priv->selblocklen = 0;