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;