linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] i2c-mpc: generate START condition after STOP caused by read i2c_msg
@ 2009-05-19  5:22 Esben Haabendal
  2009-05-26 11:30 ` Esben Haabendal
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Esben Haabendal @ 2009-05-19  5:22 UTC (permalink / raw)
  To: linux-i2c, linuxppc-dev

This fixes MAL (arbitration lost) bug caused by illegal use of
RSTA (repeated START) after STOP condition generated after last byte
of reads. With this patch, it is possible to do an i2c_transfer() with
additional i2c_msg's following the I2C_M_RD messages.

It still needs to be resolved if it is possible to fix this issue
by removing the STOP condition after reads in a robust way.

Signed-off-by: Esben Haabendal <eha@doredevelopment.dk>
---
  drivers/i2c/busses/i2c-mpc.c |    9 +++++++--
  1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 4af5c09..0199f9a 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -456,17 +456,22 @@ static int mpc_xfer(struct i2c_adapter *adap, 
struct i2c_msg *msgs, int num)
  	}

  	for (i = 0; ret >= 0 && i < num; i++) {
+		int restart = i;
  		pmsg = &msgs[i];
  		dev_dbg(i2c->dev,
  			"Doing %s %d bytes to 0x%02x - %d of %d messages\n",
  			pmsg->flags & I2C_M_RD ? "read" : "write",
  			pmsg->len, pmsg->addr, i + 1, num);
+		if (i > 0 && ((pmsg - 1)->flags & I2C_M_RD))
+			restart = 0;
  		if (pmsg->flags & I2C_M_RD)
  			ret =
-			    mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
+			    mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len,
+				     restart);
  		else
  			ret =
-			    mpc_write(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
+			    mpc_write(i2c, pmsg->addr, pmsg->buf, pmsg->len,
+				      restart);
  	}
  	mpc_i2c_stop(i2c);
  	return (ret < 0) ? ret : num;
-- 
1.6.3.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-12-04  6:58 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-19  5:22 [PATCH v2] i2c-mpc: generate START condition after STOP caused by read i2c_msg Esben Haabendal
2009-05-26 11:30 ` Esben Haabendal
2009-05-26 21:33   ` Ben Dooks
2009-05-28 17:17     ` Wolfram Sang
2009-05-28 18:43       ` Joakim Tjernlund
2009-05-28 20:10       ` Esben Haabendal
2009-05-28 20:34         ` Peter Korsgaard
2009-05-28 20:41           ` Esben Haabendal
2009-05-28 21:08             ` Peter Korsgaard
2009-05-28 21:22               ` Esben Haabendal
2009-12-03 15:09     ` Michael Lawnick
2009-12-03 15:29       ` Ben Dooks
2009-12-03 15:49         ` Joakim Tjernlund
2009-12-04  6:58         ` Michael Lawnick
2009-12-03 15:42       ` Joakim Tjernlund
2009-05-28 19:31   ` Grant Likely
2009-05-28 20:15     ` Esben Haabendal
2009-06-02 22:25       ` Ben Dooks
2009-06-02 23:12 ` Grant Likely
2009-06-03  6:01   ` Grant Likely
2009-06-14 13:16 ` Ben Dooks
2009-06-14 14:04   ` Esben Haabendal

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).