aboutsummaryrefslogtreecommitdiff
path: root/hw/block/m25p80.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2020-03-16 15:52:23 +0000
committerPeter Maydell <peter.maydell@linaro.org>2020-03-17 11:36:40 +0000
commitf3ee222f0c5f3681c28991313f76773e6cfed777 (patch)
tree7d4c1e4f5f551e37490f82408a5aab64d6eeb90e /hw/block/m25p80.c
parentccc46090f1dd45aa9e4995b8d4be112e4d9aa5db (diff)
downloadqemu-f3ee222f0c5f3681c28991313f76773e6cfed777.zip
qemu-f3ee222f0c5f3681c28991313f76773e6cfed777.tar.gz
qemu-f3ee222f0c5f3681c28991313f76773e6cfed777.tar.bz2
m25p80: Improve command handling for Jedec commands
When requesting JEDEC data using the JEDEC_READ command, the Linux kernel always requests 6 bytes. The current implementation only returns three bytes, and interprets the remaining three bytes as new commands. While this does not matter most of the time, it is at the very least confusing. To avoid the problem, always report up to 6 bytes of JEDEC data. Fill remaining data with 0. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/block/m25p80.c')
-rw-r--r--hw/block/m25p80.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 5ff8d27..53bf638 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -1040,8 +1040,11 @@ static void decode_new_cmd(Flash *s, uint32_t value)
for (i = 0; i < s->pi->id_len; i++) {
s->data[i] = s->pi->id[i];
}
+ for (; i < SPI_NOR_MAX_ID_LEN; i++) {
+ s->data[i] = 0;
+ }
- s->len = s->pi->id_len;
+ s->len = SPI_NOR_MAX_ID_LEN;
s->pos = 0;
s->state = STATE_READING_DATA;
break;