mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: mmc: write_reliability: bail out early if already set
@ 2024-10-09 15:01 Michael Grzeschik
  2024-10-14 11:22 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Grzeschik @ 2024-10-09 15:01 UTC (permalink / raw)
  To: barebox

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




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

* Re: [PATCH] commands: mmc: write_reliability: bail out early if already set
  2024-10-09 15:01 [PATCH] commands: mmc: write_reliability: bail out early if already set Michael Grzeschik
@ 2024-10-14 11:22 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-10-14 11:22 UTC (permalink / raw)
  To: barebox, Michael Grzeschik


On Wed, 09 Oct 2024 17:01:59 +0200, Michael Grzeschik wrote:
> 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.
> 
> 

Applied, thanks!

[1/1] commands: mmc: write_reliability: bail out early if already set
      https://git.pengutronix.de/cgit/barebox/commit/?id=8a79662c1b46 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-10-14 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09 15:01 [PATCH] commands: mmc: write_reliability: bail out early if already set Michael Grzeschik
2024-10-14 11:22 ` Sascha Hauer

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