mmc-utils: lsmmc: Fix emmc capacity calculation

When the device capacity is larger than 2GB, it shouldn't use c_size but
instead it follows a different calculation using the SEC_COUNT field of
the ext-csd[215:212] - see eMMC spec JESD84-B51 paragraph 7.3.12.

This bug was already in lsmmc when it got merged into mmc-utils, hence
the fixes tag.

Fixes: 4af1749d2350 (mmc-utils: Merge the lsmmc tool into mmc-utils)
Signed-off-by: wanggang26 <>
Signed-off-by: Avri Altman <>
Signed-off-by: Ulf Hansson <>
diff --git a/lsmmc.c b/lsmmc.c
index c984d9a..9596722 100644
--- a/lsmmc.c
+++ b/lsmmc.c
@@ -1826,6 +1826,9 @@
 	int block_len = 1 << read_bl_len;
 	unsigned long long memory_capacity;
+	if (c_size == 0xfff)
+		return;
 	printf("\tC_SIZE: 0x%03x\n", c_size);
 	printf("\tC_SIZE_MULT: 0x%01x\n", c_size_mult);