From 4d2c26338ac3ce78b2325730bfeb4884ba60bd77 Mon Sep 17 00:00:00 2001 From: Gary King Date: Thu, 15 Jul 2010 17:11:32 -0700 Subject: [PATCH] mmc: subtract boot sectors from disk size for eMMC 4.3+ devices the csd sector count reported by eMMC 4.3+ cards includes the boot partition size; subtract this from the size reported to the disk since the boot partition is inaccessible Change-Id: I601b83aa0159b7aa446409ea8c945b256dd0b5b1 Signed-off-by: Gary King --- drivers/mmc/core/mmc.c | 7 ++++++- include/linux/mmc/mmc.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2a7e43bc796d..868f511b3f2e 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -274,8 +274,13 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) ext_csd[EXT_CSD_SEC_CNT + 3] << 24; /* Cards with density > 2GiB are sector addressed */ - if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512) + if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512) { + unsigned boot_sectors; + /* size is in 256K chunks, i.e. 512 sectors each */ + boot_sectors = ext_csd[EXT_CSD_BOOT_SIZE_MULTI] * 512; + card->ext_csd.sectors -= boot_sectors; mmc_card_set_blockaddr(card); + } } switch (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK) { diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index ac26a685cca8..630ea24af1d8 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -283,6 +283,7 @@ struct _mmc_csd { #define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ #define EXT_CSD_TRIM_MULT 232 /* RO */ +#define EXT_CSD_BOOT_SIZE_MULTI 226 /* RO */ /* * EXT_CSD field definitions -- 2.34.1