* [PATCH] i2c: mxs: Better error handling
@ 2013-07-03 8:59 Alexandre Belloni
[not found] ` <1372841962-26310-1-git-send-email-alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2013-07-03 8:59 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, marex-ynQEQJNshbs,
Alexandre Belloni
This patch fixes two error handling cases in mxs_i2c_xfer_msg():
- in PIO mode, mxs_i2c_pio_setup_xfer() may return an error but i2c->cmd_err
will not be set so mxs_i2c_xfer_msg() fails silently.
- in DMA mode, mxs_i2c_dma_setup_xfer() may return an error and have
i2c->cmd_err set to -ENXIO. In that case, we want to go through the
MXS_I2C_CTRL1_CLR_GOT_A_NAK before returning.
Signed-off-by: Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
drivers/i2c/busses/i2c-mxs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 2039f23..92f22b0 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -502,7 +502,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
INIT_COMPLETION(i2c->cmd_complete);
ret = mxs_i2c_dma_setup_xfer(adap, msg, flags);
if (ret)
- return ret;
+ goto exit;
ret = wait_for_completion_timeout(&i2c->cmd_complete,
msecs_to_jiffies(1000));
@@ -510,6 +510,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
goto timeout;
}
+exit:
if (i2c->cmd_err == -ENXIO) {
/*
* If the transfer fails with a NAK from the slave the
@@ -519,7 +520,8 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
i2c->regs + MXS_I2C_CTRL1_SET);
}
- ret = i2c->cmd_err;
+ if (i2c->cmd_err)
+ ret = i2c->cmd_err;
dev_dbg(i2c->dev, "Done with err=%d\n", ret);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <1372841962-26310-1-git-send-email-alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>]
* Re: [PATCH] i2c: mxs: Better error handling [not found] ` <1372841962-26310-1-git-send-email-alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> @ 2013-08-15 10:03 ` Wolfram Sang 2013-08-15 11:09 ` Alexandre Belloni 0 siblings, 1 reply; 3+ messages in thread From: Wolfram Sang @ 2013-08-15 10:03 UTC (permalink / raw) To: Alexandre Belloni Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, marex-ynQEQJNshbs [-- Attachment #1: Type: text/plain, Size: 745 bytes --] On Wed, Jul 03, 2013 at 10:59:22AM +0200, Alexandre Belloni wrote: > This patch fixes two error handling cases in mxs_i2c_xfer_msg(): > > - in PIO mode, mxs_i2c_pio_setup_xfer() may return an error but i2c->cmd_err > will not be set so mxs_i2c_xfer_msg() fails silently. > > - in DMA mode, mxs_i2c_dma_setup_xfer() may return an error and have > i2c->cmd_err set to -ENXIO. In that case, we want to go through the > MXS_I2C_CTRL1_CLR_GOT_A_NAK before returning. A short explanation why we want that would be perfect. > > Signed-off-by: Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> I'd like to postpone this until I applied Marek's PIO rework. Could you respin after that? [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: mxs: Better error handling 2013-08-15 10:03 ` Wolfram Sang @ 2013-08-15 11:09 ` Alexandre Belloni 0 siblings, 0 replies; 3+ messages in thread From: Alexandre Belloni @ 2013-08-15 11:09 UTC (permalink / raw) To: Wolfram Sang; +Cc: linux-i2c, linux-kernel, marex -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi Wolfram, On 15/08/2013 12:03, Wolfram Sang wrote: > On Wed, Jul 03, 2013 at 10:59:22AM +0200, Alexandre Belloni wrote: >> This patch fixes two error handling cases in mxs_i2c_xfer_msg(): >> >> - in PIO mode, mxs_i2c_pio_setup_xfer() may return an error but i2c->cmd_err >> will not be set so mxs_i2c_xfer_msg() fails silently. >> >> - in DMA mode, mxs_i2c_dma_setup_xfer() may return an error and have >> i2c->cmd_err set to -ENXIO. In that case, we want to go through the >> MXS_I2C_CTRL1_CLR_GOT_A_NAK before returning. > > A short explanation why we want that would be perfect. > >> >> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> > > I'd like to postpone this until I applied Marek's PIO rework. Could you > respin after that? > Actually, this patch won't be needed after Marek's PIO rework. You can drop it now. - -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBCAAGBQJSDLb1AAoJEKbNnwlvZCyzBOoQAL5NbGfmv2toVVcOHIkGpe0X L+4NqviBObeP2Kh/JWPm8zfuLhIHTU+MNGxFpL5JLzGh+5NVqEA5M7bQjwxmZxPS OCEgzKwMzrTbxM3mOAxALO3LtEOUa6xBzzcKbaeWq48m2yA2KRt9niEqvN+cAHVl rqFyrcv54AUOfdMS923bBNqMpTdpCmdy164msFV+yQqljd4Igg0T54KqmHmw2+4m asfJtDAa674sGizZdB0bSZTo0pGhD2TJEdqU17rsDa/PruFgI8/lw4LOXtpL017M zwx7miO6gkUymEiyOtfufOBkEUSfPmOPd/BcasgAs8loo01IPttn2vMWAV+Pku+D XzbvFvSrlHiMQze6GCejv3W5dMySyDMnWma5ZGJ9DXkzE677UK7i7ehZSxn4huVn w5JNgXfCsOexjTRmtoUad652kQl/GKDL5DdJr75wcZzp/6RfyGz3fu4mfUYiqFue vW/Xbkswc334v2ueuQsdzlEEFfGaiddlsyHHfEEOsdO7djoGRXBoUxI+S1bDFdLO WXCLRO11Ju0IXiTQ9uBBSibP0nSmu9W6/s1Ufp1F3OWqAj+H7CEZpqjg4hQkMIh+ 997svOMknIuJzLhvBQbGj8FJ1FQhNDRaF49tFrpBhZaXp3a+a1rS31kZaoTx2etT 35VZG9zLAOGkfCPU3JEu =bjCC -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-15 11:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03 8:59 [PATCH] i2c: mxs: Better error handling Alexandre Belloni
[not found] ` <1372841962-26310-1-git-send-email-alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2013-08-15 10:03 ` Wolfram Sang
2013-08-15 11:09 ` Alexandre Belloni
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox