On Wed, Jun 16, 2021 at 06:14:11PM +0200, Philippe Mathieu-Daudé wrote: > Instead of using the confuse i2c_send_recv(), rewrite to directly > call i2c_recv() & i2c_send(), resulting in code easire to review. > > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > hw/i2c/ppc4xx_i2c.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/hw/i2c/ppc4xx_i2c.c b/hw/i2c/ppc4xx_i2c.c > index f4c5bc12d36..b3d3da56e38 100644 > --- a/hw/i2c/ppc4xx_i2c.c > +++ b/hw/i2c/ppc4xx_i2c.c > @@ -240,11 +240,14 @@ static void ppc4xx_i2c_writeb(void *opaque, hwaddr > addr, uint64_t value, > i2c->sts &= ~IIC_STS_ERR; > } > } > - if (!(i2c->sts & IIC_STS_ERR) && > - i2c_send_recv(i2c->bus, &i2c->mdata[i], !recv)) { > - i2c->sts |= IIC_STS_ERR; > - i2c->extsts |= IIC_EXTSTS_XFRA; > - break; > + if (!(i2c->sts & IIC_STS_ERR)) { > + if (recv) { > + i2c->mdata[i] = i2c_recv(i2c->bus); > + } else if (i2c_send(i2c->bus, i2c->mdata[i])) {
In the previous patch you checked < 0, it would be nice to be consistent. -corey > + i2c->sts |= IIC_STS_ERR; > + i2c->extsts |= IIC_EXTSTS_XFRA; > + break; > + } > } > if (value & IIC_CNTL_RPST || !(value & IIC_CNTL_CHT)) { > i2c_end_transfer(i2c->bus); > -- > 2.31.1 >