public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: block: Use .card_busy() to detect busy state in card_busy_detect
@ 2021-06-07  9:18 Shawn Lin
  2021-06-07 13:28 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Shawn Lin @ 2021-06-07  9:18 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Shawn Lin

No need to send CMD13 if host driver supports .card_busy().

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

 drivers/mmc/core/block.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 88f4c215..23623a9 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -417,10 +417,17 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
 	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
 	int err = 0;
 	u32 status;
+	bool busy;
 
 	do {
 		bool done = time_after(jiffies, timeout);
 
+		if (card->host->ops->card_busy) {
+			busy = card->host->ops->card_busy(card->host);
+			status = busy ?	0 : R1_READY_FOR_DATA | R1_STATE_TRAN << 9;
+			goto cb;
+		}
+
 		err = __mmc_send_status(card, &status, 5);
 		if (err) {
 			dev_err(mmc_dev(card->host),
@@ -442,6 +449,7 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
 				 __func__, status);
 			return -ETIMEDOUT;
 		}
+cb:
 	} while (!mmc_ready_for_data(status));
 
 	return err;
-- 
2.7.4




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-08  7:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-07  9:18 [PATCH] mmc: block: Use .card_busy() to detect busy state in card_busy_detect Shawn Lin
2021-06-07 13:28 ` kernel test robot
2021-06-07 14:03 ` kernel test robot
2021-06-07 14:28 ` kernel test robot
2021-06-08  6:28 ` Christian Löhle
2021-06-08  6:58   ` Shawn Lin
2021-06-08  7:51     ` Christian Löhle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox