The current code does: if (write_cycle == 0) if (command == CFI_QUERY) break write_cycle += 1 last_command = command
if (write_cycle == 1) if (last_command == CFI_QUERY) if (command == READ_ARRAY write_cycle = 0 last_command = READ_ARRAY Simplify by not increasing the write_cycle on CFI_QUERY, the next command are processed as normal wcycle=0. This matches the hardware datasheet (we do not enter the WRITE state machine, thus no write cycle involved). Reviewed-by: Alistair Francis <alistair.fran...@wdc.com> Regression-tested-by: Laszlo Ersek <ler...@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> --- hw/block/pflash_cfi01.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index c32c67d01d..e097d9260d 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -491,7 +491,8 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, return; case 0x98: /* CFI query */ DPRINTF("%s: CFI query\n", __func__); - break; + pfl->cmd = cmd; + return; case 0xe8: /* Write to buffer */ DPRINTF("%s: Write to buffer\n", __func__); /* FIXME should save @offset, @width for case 1+ */ @@ -565,13 +566,6 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, goto mode_read_array; } break; - case 0x98: - if (cmd == 0xff) { - goto mode_read_array; - } else { - DPRINTF("%s: leaving query mode\n", __func__); - } - break; default: goto error_flash; } -- 2.20.1