From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Fabiano Rosas <farosas@suse.de>,
peterx@redhat.com, qemu-arm@nongnu.org
Subject: [PATCH for-12.0 2/6] hw/gpio/zaurus: Move VMSTATE_VALIDATE() check into post_load_errp()
Date: Fri, 20 Nov 2026 07:49:19 -0500 [thread overview]
Message-ID: <20261120124923.1656220-3-peterx@redhat.com> (raw)
In-Reply-To: <20261120124923.1656220-1-peterx@redhat.com>
To pave way for removing VMSTATE_VALIDATE(), remove the use in this file by
moving it into the post_load_errp().
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org
Signed-off-by: Peter Xu <peterx@redhat.com>
---
hw/gpio/zaurus.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/hw/gpio/zaurus.c b/hw/gpio/zaurus.c
index 3cf626a550..a60f4d4393 100644
--- a/hw/gpio/zaurus.c
+++ b/hw/gpio/zaurus.c
@@ -23,6 +23,7 @@
#include "qemu/module.h"
#include "qemu/log.h"
#include "qom/object.h"
+#include "qapi/error.h"
/* SCOOP devices */
@@ -188,12 +189,24 @@ static void scoop_init(Object *obj)
sysbus_init_mmio(sbd, &s->iomem);
}
-static int scoop_post_load(void *opaque, int version_id)
+static bool vmstate_scoop_validate(ScoopInfo *s)
+{
+ return !(s->prev_level & 0xffff0000) &&
+ !(s->gpio_level & 0xffff0000) &&
+ !(s->gpio_dir & 0xffff0000);
+}
+
+static bool scoop_post_load(void *opaque, int version_id, Error **errp)
{
ScoopInfo *s = (ScoopInfo *) opaque;
int i;
uint32_t level;
+ if (!vmstate_scoop_validate(s)) {
+ error_setg(errp, "irq levels are not 16-bits");
+ return false;
+ }
+
level = s->gpio_level & s->gpio_dir;
for (i = 0; i < 16; i++) {
@@ -202,7 +215,7 @@ static int scoop_post_load(void *opaque, int version_id)
s->prev_level = level;
- return 0;
+ return true;
}
static bool is_version_0(void *opaque, int version_id)
@@ -210,27 +223,17 @@ static bool is_version_0(void *opaque, int version_id)
return version_id == 0;
}
-static bool vmstate_scoop_validate(void *opaque, int version_id)
-{
- ScoopInfo *s = opaque;
-
- return !(s->prev_level & 0xffff0000) &&
- !(s->gpio_level & 0xffff0000) &&
- !(s->gpio_dir & 0xffff0000);
-}
-
static const VMStateDescription vmstate_scoop_regs = {
.name = "scoop",
.version_id = 1,
.minimum_version_id = 0,
- .post_load = scoop_post_load,
+ .post_load_errp = scoop_post_load,
.fields = (const VMStateField[]) {
VMSTATE_UINT16(status, ScoopInfo),
VMSTATE_UINT16(power, ScoopInfo),
VMSTATE_UINT32(gpio_level, ScoopInfo),
VMSTATE_UINT32(gpio_dir, ScoopInfo),
VMSTATE_UINT32(prev_level, ScoopInfo),
- VMSTATE_VALIDATE("irq levels are 16 bit", vmstate_scoop_validate),
VMSTATE_UINT16(mcr, ScoopInfo),
VMSTATE_UINT16(cdr, ScoopInfo),
VMSTATE_UINT16(ccr, ScoopInfo),
--
2.56.0
next prev parent reply other threads:[~2026-11-20 12:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:49 [PATCH for-12.0 0/6] migration: Remove VMSTATE_VALIDATE() and VMS_MUST_EXIST Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 1/6] pcie/aer: Remove the usage of VMSTATE_VALIDATE() Peter Xu
2026-11-20 12:49 ` Peter Xu [this message]
2026-11-20 12:49 ` [PATCH for-12.0 3/6] hpet: Move VMSTATE_VALIDATE() check into post_load Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 4/6] arm/machine: Move all VMSTATE_VALIDATE() usages " Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 5/6] rust: Replace vmstate_validate with post_load Peter Xu
2026-11-20 14:25 ` Zhao Liu
2026-11-20 15:43 ` Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 6/6] migration: Drop VMSTATE_VALIDATE() and VMS_MUST_EXIST Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120124923.1656220-3-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.