From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Mark Brown <broonie@kernel.org>
Cc: Magnus Damm <magnus.damm@gmail.com>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
linux-spi@vger.kernel.org, linux-sh@vger.kernel.org,
linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH 3/5] spi: sh-msiof: Improve transfer error handling
Date: Fri, 20 Jun 2014 12:16:18 +0200 [thread overview]
Message-ID: <1403259380-13634-4-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1403259380-13634-1-git-send-email-geert+renesas@glider.be>
- 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>
---
drivers/spi/spi-sh-msiof.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 8bfa97e03502..29dee0436a9a 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;
--
1.9.1
next prev parent reply other threads:[~2014-06-20 10:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 10:16 [PATCH 0/5] spi: sh-msiof: Add DMA support Geert Uytterhoeven
2014-06-20 10:16 ` [PATCH 1/5] spi: sh-msiof: Add more register documentation Geert Uytterhoeven
[not found] ` <1403259380-13634-2-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-06-21 10:18 ` Mark Brown
2014-06-20 10:16 ` Geert Uytterhoeven [this message]
2014-06-21 10:18 ` [PATCH 3/5] spi: sh-msiof: Improve transfer error handling Mark Brown
2014-06-20 10:16 ` [PATCH 4/5] spi: sh-msiof: Refactor sh_msiof_transfer_one() Geert Uytterhoeven
2014-06-21 10:18 ` Mark Brown
[not found] ` <1403259380-13634-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-06-20 10:16 ` [PATCH 2/5] spi: sh-msiof: Extract sh_msiof_spi_{start,stop}() helpers Geert Uytterhoeven
2014-06-21 10:18 ` Mark Brown
2014-06-20 10:16 ` [PATCH 5/5] spi: sh-msiof: Add DMA support Geert Uytterhoeven
2014-06-21 10:19 ` Mark Brown
[not found] ` <20140621101959.GM5099-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-06-22 8:06 ` Geert Uytterhoeven
2014-06-24 18:56 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403259380-13634-4-git-send-email-geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=broonie@kernel.org \
--cc=g.liakhovetski@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=magnus.damm@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).