From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQPYl-0007FS-L2 for qemu-devel@nongnu.org; Sat, 28 May 2011 15:52:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QQPYk-0004wo-QO for qemu-devel@nongnu.org; Sat, 28 May 2011 15:52:31 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Sat, 28 May 2011 20:52:29 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] bitbang_i2c: Fix spurious slave read after NACK List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrzej Zaborowski Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, Marcus Comstedt On Sat, May 28, 2011 at 3:55 PM, Marcus Comstedt wrote: > After NACKing a read operation, a raising SCL should not trigger a new > read from the slave. =A0Introduce a new state which just waits for a stop > or start condition after NACK. > > Signed-off-by: Marcus Comstedt > --- > =A0hw/bitbang_i2c.c | =A0 =A05 ++++- > =A01 files changed, 4 insertions(+), 1 deletions(-) Seems like a simple change but I'm not familiar with the code or I2C details. Andrzej, care to take a look? > diff --git a/hw/bitbang_i2c.c b/hw/bitbang_i2c.c > index 4ee99a1..2937b5c 100644 > --- a/hw/bitbang_i2c.c > +++ b/hw/bitbang_i2c.c > @@ -38,7 +38,8 @@ typedef enum bitbang_i2c_state { > =A0 =A0 RECEIVING_BIT2, > =A0 =A0 RECEIVING_BIT1, > =A0 =A0 RECEIVING_BIT0, > - =A0 =A0SENDING_ACK > + =A0 =A0SENDING_ACK, > + =A0 =A0SENT_NACK > =A0} bitbang_i2c_state; > > =A0struct bitbang_i2c_interface { > @@ -115,6 +116,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int l= ine, int level) > =A0 =A0 } > =A0 =A0 switch (i2c->state) { > =A0 =A0 case STOPPED: > + =A0 =A0case SENT_NACK: > =A0 =A0 =A0 =A0 return bitbang_i2c_ret(i2c, 1); > > =A0 =A0 case SENDING_BIT7 ... SENDING_BIT0: > @@ -155,6 +157,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int l= ine, int level) > =A0 =A0 =A0 =A0 i2c->state =3D RECEIVING_BIT7; > =A0 =A0 =A0 =A0 if (data !=3D 0) { > =A0 =A0 =A0 =A0 =A0 =A0 DPRINTF("NACKED\n"); > + =A0 =A0 =A0 =A0 =A0 =A0i2c->state =3D SENT_NACK; > =A0 =A0 =A0 =A0 =A0 =A0 i2c_nack(i2c->bus); > =A0 =A0 =A0 =A0 } else { > =A0 =A0 =A0 =A0 =A0 =A0 DPRINTF("ACKED\n"); > -- > 1.7.4.1 > > >