From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] commands: mmc: write_reliability: bail out early if already set
Date: Wed, 9 Oct 2024 17:01:59 +0200 [thread overview]
Message-ID: <20241009150159.2597633-1-m.grzeschik@pengutronix.de> (raw)
Some cards may have HS_CTRL_REL set as 0. This is obsolete
per-spec, but seems to indicate that write reliability was
factory-set. Therefore, just bail out early before checking the
parm.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
commands/mmc.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/commands/mmc.c b/commands/mmc.c
index 718558f18b..dafc3a755f 100644
--- a/commands/mmc.c
+++ b/commands/mmc.c
@@ -138,6 +138,7 @@ static int do_mmc_write_reliability(int argc, char *argv[])
const char *devpath;
struct mci *mci;
u8 *ext_csd;
+ int ret;
if (argc - optind != 1) {
printf("Usage: mmc write_reliability /dev/mmcX\n");
@@ -166,6 +167,15 @@ static int do_mmc_write_reliability(int argc, char *argv[])
goto error;
}
+ /* Some cards may have HS_CTRL_REL set as 0. This is obsolete
+ * per-spec, but seems to indicate that write reliability was
+ * factory-set. Therefore, just bail out early here
+ */
+ if ((ext_csd[EXT_CSD_WR_REL_SET] & 0x1f) == 0x1f) {
+ printf("reliable write already set\n");
+ goto out;
+ }
+
if (!(ext_csd[EXT_CSD_WR_REL_PARAM] & EXT_CSD_HS_CTRL_REL)) {
printf("Device doesn't support WR_REL_SET writes\n");
goto error;
@@ -175,16 +185,13 @@ static int do_mmc_write_reliability(int argc, char *argv[])
* Host has one opportunity to write all of the bits. Separate writes to
* individual bits are not permitted so set all bits for now.
*/
- if ((ext_csd[EXT_CSD_WR_REL_SET] & 0x1f) != 0x1f) {
- int ret;
-
- ret = mci_switch(mci, EXT_CSD_WR_REL_SET, 0x1f);
- if (ret) {
- printf("Failure to write to EXT_CSD_WR_REL_SET\n");
- goto error;
- }
+ ret = mci_switch(mci, EXT_CSD_WR_REL_SET, 0x1f);
+ if (ret) {
+ printf("Failure to write to EXT_CSD_WR_REL_SET\n");
+ goto error;
}
+out:
dma_free(ext_csd);
return COMMAND_SUCCESS;
--
2.39.5
next reply other threads:[~2024-10-09 15:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 15:01 Michael Grzeschik [this message]
2024-10-14 11:22 ` Sascha Hauer
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=20241009150159.2597633-1-m.grzeschik@pengutronix.de \
--to=m.grzeschik@pengutronix.de \
--cc=barebox@lists.infradead.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