From: Daniel Kucera <linux-mmc@danman.eu>
To: linux-mmc@vger.kernel.org, ulf.hansson@linaro.org
Subject: Re: [PATCH v3] mmc: core: allow detection of locked cards
Date: Sat, 01 Jun 2024 23:43:01 +0200 [thread overview]
Message-ID: <8e03fa17dd41180f53fede6897ab1bf8@danman.eu> (raw)
In-Reply-To: <20240523132016.599343-1-linux-mmc@danman.eu>
On 2024-05-23 15:20, linux-mmc@danman.eu wrote:
> 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 | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 1c8148cdd..ae821df7d 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -928,8 +928,19 @@ 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.
> */
Any feedback please?
D.
next prev parent reply other threads:[~2024-06-01 21:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 13:20 [PATCH v3] mmc: core: allow detection of locked cards linux-mmc
2024-06-01 21:43 ` Daniel Kucera [this message]
2024-06-02 5:26 ` Avri Altman
2024-06-02 12:37 ` Daniel Kucera
2024-06-02 12:59 ` Avri Altman
2024-06-06 8:17 ` Daniel Kucera
2024-06-06 8:39 ` Avri Altman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8e03fa17dd41180f53fede6897ab1bf8@danman.eu \
--to=linux-mmc@danman.eu \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox