Skip to content

Commit

Permalink
hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send()
Browse files Browse the repository at this point in the history
Instead of using the confuse i2c_send_recv(), rewrite to directly
call i2c_recv() & i2c_send(), resulting in code easier to review.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
  • Loading branch information
philmd authored and cminyard committed Jun 17, 2021
1 parent 9d25b3c commit c79976f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions hw/i2c/ppc4xx_i2c.c
Expand Up @@ -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]) < 0) {
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);
Expand Down

0 comments on commit c79976f

Please sign in to comment.