From f5a106d9e2a5d947e106c3caace373ded1a695ed Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 27 Jan 2011 17:44:34 +0100 Subject: 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: Linus Walleij Signed-off-by: Russell King --- drivers/mmc/host/mmci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 4b8dcd5b2a01..b6fd6dcb41e7 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 = 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; -- cgit v1.2.3 From ccff9b51825b7335889b780bdf7de84ca803e291 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 30 Jan 2011 21:03:50 +0000 Subject: ARM: mmci: complete the transaction on error When we encounter an error, make sure we complete the transaction otherwise we'll leave the request dangling. Acked-by: Linus Walleij Signed-off-by: Russell King --- drivers/mmc/host/mmci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index b6fd6dcb41e7..175a623a6a29 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -319,7 +319,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, if (status & MCI_DATABLOCKEND) dev_err(mmc_dev(host->mmc), "stray MCI_DATABLOCKEND interrupt\n"); - if (status & MCI_DATAEND) { + if (status & MCI_DATAEND || data->error) { mmci_stop_data(host); if (!data->error) -- cgit v1.2.3 From 613b152c63e35095a929f9bb80441cbe91ff5e80 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 30 Jan 2011 21:06:53 +0000 Subject: ARM: mmci: round down the bytes transferred on error We should not report incomplete blocks on error. Return the number of bytes successfully transferred, rounded down to the nearest block. Acked-by: Linus Walleij Signed-off-by: Russell King --- drivers/mmc/host/mmci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 175a623a6a29..2d6de3e03e2d 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -289,13 +290,13 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, 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 - 1) / data->blksz) * data->blksz; + host->data_xfered = round_down(success - 1, data->blksz); data->error = -EILSEQ; } else if (status & MCI_DATATIMEOUT) { - host->data_xfered = success; + host->data_xfered = round_down(success, data->blksz); data->error = -ETIMEDOUT; } else if (status & (MCI_TXUNDERRUN|MCI_RXOVERRUN)) { - host->data_xfered = success; + host->data_xfered = round_down(success, data->blksz); data->error = -EIO; } -- cgit v1.2.3