summaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorRobin van der Gracht <robin@protonic.nl>2015-08-04 08:58:33 +0200
committerUlf Hansson <ulf.hansson@linaro.org>2015-08-27 14:50:47 +0200
commit22d7e85ff8e5826845e9a4fa34b4723e5a97ee9b (patch)
tree3fa82091ca4c1e538bfdeedaa8abc58d42a335a6 /drivers/mmc
parentmmc: tmio: Fix timeout value for command request (diff)
downloadlinux-22d7e85ff8e5826845e9a4fa34b4723e5a97ee9b.tar.xz
linux-22d7e85ff8e5826845e9a4fa34b4723e5a97ee9b.zip
mmc: core: Fixed bug in one erase-group budget TRIM
When requesting a trim for several bytes, everything up to the next erase-group is erased. This causes data corruption. Signed-off-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/core.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 083cade3ffc5..57edb2a9bb04 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2227,9 +2227,8 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
* and call mmc_do_erase() twice if necessary. This special case is
* identified by the card->eg_boundary flag.
*/
- if ((arg & MMC_TRIM_ARGS) && (card->eg_boundary) &&
- (from % card->erase_size)) {
- rem = card->erase_size - (from % card->erase_size);
+ rem = card->erase_size - (from % card->erase_size);
+ if ((arg & MMC_TRIM_ARGS) && (card->eg_boundary) && (nr > rem)) {
err = mmc_do_erase(card, from, from + rem - 1, arg);
from += rem;
if ((err) || (to <= from))