diff mbox

[v2,1/8] mmc: core: Move the sanity check of busy detection into mmc_poll_for_busy()

Message ID 1527475903-11208-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Lin May 28, 2018, 2:51 a.m. UTC
In preparation for reusing mmc_poll_for_busy() to avoid duplication
of code for polling busy.

No functional change intended.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

---

Changes in v2:
- remove goto label

 drivers/mmc/core/mmc_ops.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 42d6aa8..126fa65 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -447,7 +447,7 @@  int mmc_switch_status(struct mmc_card *card)
 }
 
 static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
-			bool send_status, bool retry_crc_err)
+			bool send_status, bool retry_crc_err, bool use_r1b_resp)
 {
 	struct mmc_host *host = card->host;
 	int err;
@@ -456,6 +456,11 @@  static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
 	bool expired = false;
 	bool busy = false;
 
+	/* If SPI or using HW busy detection, then we don't need to poll. */
+	if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) ||
+		mmc_host_is_spi(host))
+		return 0;
+
 	/* We have an unspecified cmd timeout, use the fallback value. */
 	if (!timeout_ms)
 		timeout_ms = MMC_OPS_TIMEOUT_MS;
@@ -570,17 +575,12 @@  int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
 	if (!use_busy_signal)
 		goto out;
 
-	/*If SPI or used HW busy detection above, then we don't need to poll. */
-	if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) ||
-		mmc_host_is_spi(host))
-		goto out_tim;
-
 	/* Let's try to poll to find out when the command is completed. */
-	err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err);
+	err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err,
+				use_r1b_resp);
 	if (err)
 		goto out;
 
-out_tim:
 	/* Switch to new timing before check switch status. */
 	if (timing)
 		mmc_set_timing(host, timing);