mci i.MX esdhc: use timeout loops
Too often I have waited to get a reaction from this driver when something goes wrong. Use timeout loops instead of inifinite polling loops. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
3eb9672818
commit
7cb73292e2
|
@ -238,6 +238,7 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
|
|||
u32 irqstat;
|
||||
struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
|
||||
struct fsl_esdhc *regs = host->regs;
|
||||
int ret;
|
||||
|
||||
esdhc_write32(®s->irqstat, -1);
|
||||
|
||||
|
@ -268,8 +269,12 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
|
|||
esdhc_write32(®s->xfertyp, xfertyp);
|
||||
|
||||
/* Wait for the command to complete */
|
||||
while (!(esdhc_read32(®s->irqstat) & IRQSTAT_CC))
|
||||
;
|
||||
ret = wait_on_timeout(100 * MSECOND,
|
||||
esdhc_read32(®s->irqstat) & IRQSTAT_CC);
|
||||
if (ret) {
|
||||
dev_err(host->dev, "timeout 1\n");
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
irqstat = esdhc_read32(®s->irqstat);
|
||||
esdhc_write32(®s->irqstat, irqstat);
|
||||
|
@ -321,12 +326,20 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
|
|||
esdhc_write32(®s->irqstat, -1);
|
||||
|
||||
/* Wait for the bus to be idle */
|
||||
while ((esdhc_read32(®s->prsstat) & PRSSTAT_CICHB) ||
|
||||
(esdhc_read32(®s->prsstat) & PRSSTAT_CIDHB))
|
||||
;
|
||||
ret = wait_on_timeout(100 * MSECOND,
|
||||
!(esdhc_read32(®s->prsstat) &
|
||||
(PRSSTAT_CICHB | PRSSTAT_CIDHB)));
|
||||
if (ret) {
|
||||
dev_err(host->dev, "timeout 2\n");
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
while (esdhc_read32(®s->prsstat) & PRSSTAT_DLA)
|
||||
;
|
||||
ret = wait_on_timeout(100 * MSECOND,
|
||||
!(esdhc_read32(®s->prsstat) & PRSSTAT_DLA));
|
||||
if (ret) {
|
||||
dev_err(host->dev, "timeout 3\n");
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue