Don't start asynchronous transfer when no tx data is provided.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4457
Signed-off-by: Timur Maksimov <gessingate@gmail.com>
---
hw/misc/i2c-echo.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/misc/i2c-echo.c b/hw/misc/i2c-echo.c
index 54d07db6fa..c02098cb70 100644
--- a/hw/misc/i2c-echo.c
+++ b/hw/misc/i2c-echo.c
@@ -90,9 +90,11 @@ static int i2c_echo_event(I2CSlave *s, enum i2c_event event)
break;
case I2C_FINISH:
- state->pos = 0;
- state->state = I2C_ECHO_STATE_START_SEND;
- i2c_bus_master(state->bus, state->bh);
+ if (state->pos > 0) {
+ state->pos = 0;
+ state->state = I2C_ECHO_STATE_START_SEND;
+ i2c_bus_master(state->bus, state->bh);
+ }
trace_i2c_echo_event(DEVICE(s)->canonical_path, "I2C_FINISH");
break;
---
base-commit: d73149283205645625bfa9fe029cfb68e4c4a9ae
change-id: 20261022-i2c-echo-quick-fix-3d716d5b642a
--
Timur Maksimov <gessingate@gmail.com>