Commit f5a106d9 authored by Linus Walleij's avatar Linus Walleij Committed by Russell King

ARM: 6642/1: mmci: calculate remaining bytes at error correctly

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: default avatarLinus Walleij <linus.walleij@stericsson.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent bffb276f
...@@ -283,13 +283,13 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, ...@@ -283,13 +283,13 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
u32 remain, success; u32 remain, success;
/* Calculate how far we are into the transfer */ /* 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; success = data->blksz * data->blocks - remain;
dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status); dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status);
if (status & MCI_DATACRCFAIL) { if (status & MCI_DATACRCFAIL) {
/* Last block was not successful */ /* 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; data->error = -EILSEQ;
} else if (status & MCI_DATATIMEOUT) { } else if (status & MCI_DATATIMEOUT) {
host->data_xfered = success; host->data_xfered = success;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment