summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-sh-msiof.c
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2014-06-20 14:16:18 +0400
committerMark Brown <broonie@linaro.org>2014-06-21 14:17:36 +0400
commit75b82e23a4ea20a9e1a48695ff5e01761889dbb3 (patch)
tree0b9e314ebbb6aa46abd62e7cb5a81d278348a9ce /drivers/spi/spi-sh-msiof.c
parent76c02e71612533206cb062b875c9609bce83d23a (diff)
downloadlinux-75b82e23a4ea20a9e1a48695ff5e01761889dbb3.tar.xz
spi: sh-msiof: Improve transfer error handling
- Add a timeout when waiting for the transfer complete interrupt, - If sh_msiof_spi_stop() fails, there's no need to clear IER, as the interrupt handler has already done that, - Propagate transfer failures in sh_msiof_transfer_one(). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-sh-msiof.c')
-rw-r--r--drivers/spi/spi-sh-msiof.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 2cd5fcb86f71..e5894a65c797 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -575,11 +575,16 @@ static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
ret = sh_msiof_spi_start(p, rx_buf);
if (ret) {
dev_err(&p->pdev->dev, "failed to start hardware\n");
- goto err;
+ goto stop_ier;
}
/* wait for tx fifo to be emptied / rx fifo to be filled */
- wait_for_completion(&p->done);
+ ret = wait_for_completion_timeout(&p->done, HZ);
+ if (!ret) {
+ dev_err(&p->pdev->dev, "PIO timeout\n");
+ ret = -ETIMEDOUT;
+ goto stop_reset;
+ }
/* read rx fifo */
if (rx_buf)
@@ -591,12 +596,15 @@ static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
ret = sh_msiof_spi_stop(p, rx_buf);
if (ret) {
dev_err(&p->pdev->dev, "failed to shut down hardware\n");
- goto err;
+ return ret;
}
return words;
- err:
+stop_reset:
+ sh_msiof_reset_str(p);
+ sh_msiof_spi_stop(p, rx_buf);
+stop_ier:
sh_msiof_write(p, IER, 0);
return ret;
}
@@ -679,7 +687,7 @@ static int sh_msiof_transfer_one(struct spi_master *master,
rx_buf,
words, bits);
if (n < 0)
- break;
+ return n;
bytes_done += n * bytes_per_word;
words -= n;