Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCH v2] mmc: core: allow detection of locked cards
@ 2024-05-23 11:13 linux-mmc
  2024-05-23 12:37 ` Daniel Kucera
  0 siblings, 1 reply; 2+ messages in thread
From: linux-mmc @ 2024-05-23 11:13 UTC (permalink / raw)
  To: linux-mmc, ulf.hansson; +Cc: Daniel Kucera

From: Daniel Kucera <linux-mmc@danman.eu>

Locked card will not reply to SEND_SCR or SD_STATUS commands
so it was failing to initialize previously. When skipped,
the card will get initialized and CMD42 can be sent using
ioctl to unlock the card or remove password protection.
Until unlocked, all read/write calls will timeout.

Signed-off-by: Daniel Kucera <linux-mmc@danman.eu>
---
 drivers/mmc/core/sd.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 1c8148cdd..0eebfea02 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -928,8 +928,20 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,
 	bool reinit)
 {
 	int err;
+	u32 card_status;
 
-	if (!reinit) {
+	err = mmc_send_status(card, &card_status);
+	if (err){
+		pr_err("%s: unable to get card status\n",
+			mmc_hostname(host));
+			return err;
+	}
+
+	if (card_status & R1_CARD_IS_LOCKED){
+		pr_warn("%s: card is locked\n", mmc_hostname(host));
+	}
+
+	if (!reinit && !(card_status & R1_CARD_IS_LOCKED)) {
 		/*
 		 * Fetch SCR from card.
 		 */
-- 
2.34.1


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

end of thread, other threads:[~2024-05-23 12:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23 11:13 [PATCH v2] mmc: core: allow detection of locked cards linux-mmc
2024-05-23 12:37 ` Daniel Kucera

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