diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2009-10-10 17:48:21 +0200 |
---|---|---|
committer | Lars-Peter Clausen <lars@metafoo.de> | 2009-10-10 17:48:21 +0200 |
commit | f33961ae58a73cd03ffefecf1d714b2655289998 (patch) | |
tree | 9d2d02e7312556e67f0343e8cef787d7bb8d76e7 /drivers/mfd | |
parent | 7494c1bb09bc96533e4eab23fe4153f9a531caed (diff) |
glamo-mci: Wait for the mmc engine to become idle before signaling that a
request has been finished.
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/glamo/glamo-mci.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c index 9404f540fe4..a173bbaaea3 100644 --- a/drivers/mfd/glamo/glamo-mci.c +++ b/drivers/mfd/glamo/glamo-mci.c @@ -221,6 +221,20 @@ static int glamo_mci_set_card_clock(struct glamo_mci_host *host, int freq) return real_rate; } +static int glamo_mci_wait_idle(struct glamo_mci_host *host, + unsigned long timeout) +{ + uint16_t status; + do { + status = glamo_reg_read(host, GLAMO_REG_MMC_RB_STAT1); + } while (!(status & GLAMO_STAT1_MMC_IDLE) && jiffies < timeout); + + if (jiffies >= timeout) + return -ETIMEDOUT; + + return 0; +} + static void glamo_mci_request_done(struct glamo_mci_host *host, struct mmc_request *mrq) { @@ -233,12 +247,16 @@ static void glamo_mci_irq_worker(struct work_struct *work) { struct glamo_mci_host *host = container_of(work, struct glamo_mci_host, irq_work); + struct mmc_request *mrq; struct mmc_command *cmd; uint16_t status; + int res; + if (!host->mrq || !host->mrq->cmd) return; - cmd = host->mrq->cmd; + mrq = host->mrq; + cmd = mrq->cmd; #if 0 if (cmd->data->flags & MMC_DATA_READ) @@ -263,12 +281,15 @@ static void glamo_mci_irq_worker(struct work_struct *work) } /* issue STOP if we have been given one to use */ - if (host->mrq->stop) - glamo_mci_send_command(host, host->mrq->stop); + if (mrq->stop) + glamo_mci_send_command(host, mrq->stop); if (cmd->data->flags & MMC_DATA_READ) do_pio_read(host, cmd->data); + if (mrq->stop) + mrq->stop->error = glamo_mci_wait_idle(host, jiffies + HZ); + done: host->mrq = NULL; glamo_mci_request_done(host, cmd->mrq); @@ -634,6 +655,8 @@ static void glamo_mci_send_request(struct mmc_host *mmc, dev_dbg(&host->pdev->dev, "Waiting for payload data\n"); return; done: + if (!cmd->error) + cmd->error = glamo_mci_wait_idle(host, jiffies + 2 * HZ); glamo_mci_request_done(host, mrq); } |