[PATCH] mmc: core: allow detection of locked cards

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Daniel Kucera <linux-mmc@xxxxxxxxx>

Signed-off-by: Daniel Kucera <linux-mmc@xxxxxxxxx>
---
 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





[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux