Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCH] mmc: core: allow detection of locked cards
@ 2024-05-21 21:04 linux-mmc
  2024-05-23  3:41 ` Avri Altman
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: linux-mmc @ 2024-05-21 21:04 UTC (permalink / raw)
  To: linux-mmc, ulf.hansson; +Cc: Daniel Kucera

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

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

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 1c8148cdd..b22c30348 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1475,9 +1475,22 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
 			goto free_card;
 	}
 
-	err = mmc_sd_setup_card(host, card, oldcard != NULL);
-	if (err)
-		goto free_card;
+        u32 card_status;
+
+        err = mmc_send_status(card, &card_status);
+        if (err){
+                pr_err("%s: unable to get card status\n",
+                        mmc_hostname(host));
+                goto free_card;
+        }
+
+        if (card_status & R1_CARD_IS_LOCKED){
+                pr_warn("%s: card is locked\n", mmc_hostname(host));
+        } else {
+                err = mmc_sd_setup_card(host, card, oldcard != NULL);
+                if (err)
+                        goto free_card;
+        }
 
 	/*
 	 * If the card has not been power cycled, it may still be using 1.8V
-- 
2.34.1


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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 21:04 [PATCH] mmc: core: allow detection of locked cards linux-mmc
2024-05-23  3:41 ` Avri Altman
2024-05-23  8:29 ` Christian Loehle
2024-05-23 13:17   ` Daniel Kucera
2024-05-23  8:30 ` Christian Loehle

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