Skip to contentSkip to conversation

mmc: Correct computing the SD capacity

PATCH New Romain Izard 1 participant 1 message Nov 5, 2012 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: Correct computing the SD capacity

For high-capacity SD cards, the block size is not used to compute the effective card capacity. Since high capacity MMC cards do not use the same method, high-capacity SD cards must be adressed separately.

---
 drivers/mmc/mmc.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/mmc/mmc.c +4 -5
index 5ffd8c5..209a200 100644
@@ -976,19 +976,18 @@ static int mmc_startup(struct mmc *mmc)
 	else
 		mmc->write_bl_len = 1 << ((cmd.response[3] >> 22) & 0xf);
 
-	if (mmc->high_capacity) {
+	if (IS_SD(mmc) && mmc->high_capacity) {
 		csize = (mmc->csd[1] & 0x3f) << 16
 			| (mmc->csd[2] & 0xffff0000) >> 16;
-		cmult = 8;
+		mmc->capacity = (csize + 1) << 19;
 	} else {
 		csize = (mmc->csd[1] & 0x3ff) << 2
 			| (mmc->csd[2] & 0xc0000000) >> 30;
 		cmult = (mmc->csd[2] & 0x00038000) >> 15;
+		mmc->capacity = (csize + 1) << (cmult + 2);
+		mmc->capacity *= mmc->read_bl_len;
 	}
 
-	mmc->capacity = (csize + 1) << (cmult + 2);
-	mmc->capacity *= mmc->read_bl_len;
-
 	if (mmc->read_bl_len > 512)
 		mmc->read_bl_len = 512;
 
Signature · 1 line
1.7.10.4