[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv(
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send() |
Date: |
Wed, 16 Jun 2021 18:14:11 +0200 |
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é <f4bug@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])) {
+ 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
- Re: [PATCH v3 01/13] hw/input/lm832x: Move lm832x_key_event() declaration to "lm832x.h", (continued)
- [PATCH v3 02/13] hw/input/lm832x: Define TYPE_LM8323 in public header, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v3 03/13] hw/display/sm501: Simplify sm501_i2c_write() logic, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v3 04/13] hw/display/sm501: Replace i2c_send_recv() by i2c_recv() & i2c_send(), Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v3 05/13] hw/i2c/ppc4xx_i2c: Add reference to datasheet, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(),
Philippe Mathieu-Daudé <=
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), Richard Henderson, 2021/06/16
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), Corey Minyard, 2021/06/16
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), Philippe Mathieu-Daudé, 2021/06/16
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), BALATON Zoltan, 2021/06/16
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), Philippe Mathieu-Daudé, 2021/06/16
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), BALATON Zoltan, 2021/06/16
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), Corey Minyard, 2021/06/16
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), BALATON Zoltan, 2021/06/17
- Re: [PATCH v3 06/13] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send(), Philippe Mathieu-Daudé, 2021/06/18
[PATCH v3 07/13] hw/misc/auxbus: Fix MOT/classic I2C mode, Philippe Mathieu-Daudé, 2021/06/16