diff mbox series

[3/6] mmc-utils: ffu: Simplify ext_csd bytes parsing

Message ID 20230625103814.105-4-avri.altman@wdc.com (mailing list archive)
State New, archived
Headers show
Series mmc-utils: ffu: ffu of large images | expand

Commit Message

Avri Altman June 25, 2023, 10:38 a.m. UTC
The ext_csd register has this habbit of linking a contiguous set of
bytes into one meaningful double-word.  It does that where the least
significant value is in the lower index - hence little-endian.

Signed-off-by: Avri Altman <avri.altman@wdc.com>
---
 mmc_cmds.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/mmc_cmds.c b/mmc_cmds.c
index 8650c2f..adb72af 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -2880,10 +2880,7 @@  int do_ffu(int nargs, char **argv)
 	}
 
 	/* set CMD ARG */
-	arg = ext_csd[EXT_CSD_FFU_ARG_0] |
-		ext_csd[EXT_CSD_FFU_ARG_1] << 8 |
-		ext_csd[EXT_CSD_FFU_ARG_2] << 16 |
-		ext_csd[EXT_CSD_FFU_ARG_3] << 24;
+	arg = htole32(*((__u32 *)&ext_csd[EXT_CSD_FFU_ARG_0]));
 
 	/* prepare multi_cmd for FFU based on cmd to be used */
 
@@ -2952,10 +2949,7 @@  do_retry:
 	}
 
 	/* Test if we need to restart the download */
-	sect_done = ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG_0] |
-			ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG_1] << 8 |
-			ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG_2] << 16 |
-			ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG_3] << 24;
+	sect_done = htole32(*((__u32 *)&ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG_0]));
 	/* By spec, host should re-start download from the first sector if sect_done is 0 */
 	if (sect_done == 0) {
 		if (retry--) {