]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/mmc/host/mmci.c
ARM: mmci: complete the transaction on error
[mv-sheeva.git] / drivers / mmc / host / mmci.c
index 2de12fe155da2a00d158c67fc138e25a002888a7..175a623a6a2959c72bb1f4f4146943bec846e0f4 100644 (file)
@@ -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;
@@ -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)
@@ -342,15 +342,15 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
 
        host->cmd = NULL;
 
-       cmd->resp[0] = readl(base + MMCIRESPONSE0);
-       cmd->resp[1] = readl(base + MMCIRESPONSE1);
-       cmd->resp[2] = readl(base + MMCIRESPONSE2);
-       cmd->resp[3] = readl(base + MMCIRESPONSE3);
-
        if (status & MCI_CMDTIMEOUT) {
                cmd->error = -ETIMEDOUT;
        } else if (status & MCI_CMDCRCFAIL && cmd->flags & MMC_RSP_CRC) {
                cmd->error = -EILSEQ;
+       } else {
+               cmd->resp[0] = readl(base + MMCIRESPONSE0);
+               cmd->resp[1] = readl(base + MMCIRESPONSE1);
+               cmd->resp[2] = readl(base + MMCIRESPONSE2);
+               cmd->resp[3] = readl(base + MMCIRESPONSE3);
        }
 
        if (!cmd->data || cmd->error) {