From mboxrd@z Thu Jan 1 00:00:00 1970 From: linus.walleij@stericsson.com (Linus Walleij) Date: Thu, 27 Jan 2011 15:02:56 +0100 Subject: [PATCH] mmci: calculate remaining bytes at error correctly Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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 --- drivers/mmc/host/mmci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 2de12fe..1870e74 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -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 =3D readl(host->base + MMCIDATACNT) << 2; + remain =3D readl(host->base + MMCIDATACNT); success =3D 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 =3D ((success / data->blksz) - 1 * data->blksz); + host->data_xfered =3D ((success - 1) / data->blksz) * data->blksz; data->error =3D -EILSEQ; } else if (status & MCI_DATATIMEOUT) { host->data_xfered =3D success; --=20 1.7.3.2 I'll put it in the patch tracker for consideration... Thanks Linus Walleij