aboutsummaryrefslogtreecommitdiff
path: root/hw/block/m25p80.c
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2023-03-07 16:53:18 +0100
committerCédric Le Goater <clg@kaod.org>2023-03-07 16:53:18 +0100
commit11aeb4b8c125d20181421fe2996d36285c5d62f7 (patch)
tree2aaab2ed0e0d5a767d912436e8fabc1c5ee43e53 /hw/block/m25p80.c
parent817fd33836e73812df2f1907612b57750fcb9491 (diff)
downloadqemu-11aeb4b8c125d20181421fe2996d36285c5d62f7.zip
qemu-11aeb4b8c125d20181421fe2996d36285c5d62f7.tar.gz
qemu-11aeb4b8c125d20181421fe2996d36285c5d62f7.tar.bz2
m25p80: Improve error when the backend file size does not match the device
Currently, when a block backend is attached to a m25p80 device and the associated file size does not match the flash model, QEMU complains with the error message "failed to read the initial flash content". This is confusing for the user. Instead, use helper blk_check_size_and_read_all() introduced by commit 06f1521795 ("pflash: Require backend size to match device, improve errors"). Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Peter Delevoryas <peter@pjd.dev> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20221115151000.2080833-1-clg@kaod.org> Signed-off-by: Cédric Le Goater <clg@kaod.org>
Diffstat (limited to 'hw/block/m25p80.c')
-rw-r--r--hw/block/m25p80.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 802d2eb..dc5ffbc 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "sysemu/block-backend.h"
+#include "hw/block/block.h"
#include "hw/qdev-properties.h"
#include "hw/qdev-properties-system.h"
#include "hw/ssi/ssi.h"
@@ -1615,8 +1616,7 @@ static void m25p80_realize(SSIPeripheral *ss, Error **errp)
trace_m25p80_binding(s);
s->storage = blk_blockalign(s->blk, s->size);
- if (blk_pread(s->blk, 0, s->size, s->storage, 0) < 0) {
- error_setg(errp, "failed to read the initial flash content");
+ if (!blk_check_size_and_read_all(s->blk, s->storage, s->size, errp)) {
return;
}
} else {