A locked card will return an error for all reads/writes to the
block device, so prevent the block layer from coming up until
the card is unlocked.

Signed-off-by: Al Cooper <alcoop...@gmail.com>
---
 drivers/mmc/card/block.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 7b5424f..a4b909d 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -2377,6 +2377,16 @@ static int mmc_blk_probe(struct mmc_card *card)
        struct mmc_blk_data *md, *part_md;
        char cap_str[10];
 
+
+       /* if the card is locked, don't bring up the block layer because
+        * all reads and writes will fail.
+        */
+       if (mmc_card_locked(card)) {
+               pr_debug("%s: %s - Probe aborted because card is locked\n",
+                        mmc_hostname(card->host), __func__);
+               return -ENODEV;
+       }
+
        /*
         * Check that the card supports the command class(es) we need.
         */
-- 
1.8.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to