* [PATCH] i2c: imx: retry on NAK
@ 2013-09-10 23:58 Luka Perkov
[not found] ` <1378857490-30968-1-git-send-email-luka-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Luka Perkov @ 2013-09-10 23:58 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA; +Cc: Wolfram Sang, Luka Perkov, Tim Harvey
From: Tim Harvey <tharvey-UMMOYl/HMS+akBO8gow8eQ@public.gmane.org>
In case of busy i2c try again to get ACK.
Signed-off-by: Tim Harvey <tharvey-UMMOYl/HMS+akBO8gow8eQ@public.gmane.org>
Tested-by: Luka Perkov <luka-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
---
drivers/i2c/busses/i2c-imx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index ccf4665..c64afe6 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -62,6 +62,7 @@
/* Default value */
#define IMX_I2C_BIT_RATE 100000 /* 100kHz */
+#define IMX_I2C_MAX_RETRIES 3 /* number of retries to attempt */
/* IMX I2C registers:
* the I2C register offset is different between SoCs,
@@ -298,7 +299,7 @@ static int i2c_imx_acked(struct imx_i2c_struct *i2c_imx)
{
if (imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR) & I2SR_RXAK) {
dev_dbg(&i2c_imx->adapter.dev, "<%s> No ACK\n", __func__);
- return -EIO; /* No ACK */
+ return -EAGAIN; /* try again */
}
dev_dbg(&i2c_imx->adapter.dev, "<%s> ACK received\n", __func__);
@@ -633,6 +634,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
i2c_imx->adapter.dev.parent = &pdev->dev;
i2c_imx->adapter.nr = pdev->id;
i2c_imx->adapter.dev.of_node = pdev->dev.of_node;
+ i2c_imx->adapter.retries = IMX_I2C_MAX_RETRIES;
i2c_imx->base = base;
/* Get I2C clock */
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: imx: retry on NAK
[not found] ` <1378857490-30968-1-git-send-email-luka-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
@ 2014-02-18 17:48 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2014-02-18 17:48 UTC (permalink / raw)
To: Luka Perkov; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Tim Harvey
[-- Attachment #1: Type: text/plain, Size: 570 bytes --]
On Wed, Sep 11, 2013 at 01:58:10AM +0200, Luka Perkov wrote:
> From: Tim Harvey <tharvey-UMMOYl/HMS+akBO8gow8eQ@public.gmane.org>
>
> In case of busy i2c try again to get ACK.
>
> Signed-off-by: Tim Harvey <tharvey-UMMOYl/HMS+akBO8gow8eQ@public.gmane.org>
> Tested-by: Luka Perkov <luka-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
-EAGAIN is for lost arbitration (see Documentation/i2c/fault-codes).
In that case, the core will try again. NACK needs to be reported, so the
caller can decide what to do in that case. -ENXIO would be the best
response here.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-18 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-10 23:58 [PATCH] i2c: imx: retry on NAK Luka Perkov
[not found] ` <1378857490-30968-1-git-send-email-luka-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2014-02-18 17:48 ` Wolfram Sang
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).