Skip to content

Commit

Permalink
ARM: 6642/1: mmci: calculate remaining bytes at error correctly
Browse files Browse the repository at this point in the history
The MMCIDATACNT register contain the number of byte left at error
not the number of words, so loose the << 2 thing. Further if CRC
fails on the first block, we may end up with a negative number
of transferred bytes which is not good, and the formula was in
wrong order.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Linus Walleij authored and Russell King committed Jan 27, 2011
1 parent bffb276 commit f5a106d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/mmc/host/mmci.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
u32 remain, success;

/* Calculate how far we are into the transfer */
remain = readl(host->base + MMCIDATACNT) << 2;
remain = readl(host->base + MMCIDATACNT);
success = data->blksz * data->blocks - remain;

dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status);
if (status & MCI_DATACRCFAIL) {
/* Last block was not successful */
host->data_xfered = ((success / data->blksz) - 1 * data->blksz);
host->data_xfered = ((success - 1) / data->blksz) * data->blksz;
data->error = -EILSEQ;
} else if (status & MCI_DATATIMEOUT) {
host->data_xfered = success;
Expand Down

0 comments on commit f5a106d

Please sign in to comment.