Patchwork [1/6] wdt_i6300esb: port to vmstate

login
register
mail settings
Submitter Juan Quintela
Date Oct. 14, 2009, 11:39 p.m.
Message ID <8c0931e153fd03509a9d2be086fe38729b3f8b23.1255563369.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/36032/
State New
Headers show

Comments

Juan Quintela - Oct. 14, 2009, 11:39 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/wdt_i6300esb.c |   67 ++++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 44 deletions(-)
Richard W.M. Jones - Oct. 15, 2009, 8:39 a.m.
On Thu, Oct 15, 2009 at 01:39:57AM +0200, Juan Quintela wrote:
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hw/wdt_i6300esb.c |   67 ++++++++++++++++++----------------------------------
>  1 files changed, 23 insertions(+), 44 deletions(-)

As far as I understand the vmstate API, this looks like a
straightforward conversion, so ACK.

Rich.

Patch

diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c
index 3abaa87..ab8210b 100644
--- a/hw/wdt_i6300esb.c
+++ b/hw/wdt_i6300esb.c
@@ -369,48 +369,28 @@  static void i6300esb_map(PCIDevice *dev, int region_num,
     /* qemu_register_coalesced_mmio (addr, 0x10); ? */
 }

-static void i6300esb_save(QEMUFile *f, void *vp)
-{
-    I6300State *d = (I6300State *) vp;
-
-    pci_device_save(&d->dev, f);
-    qemu_put_be32(f, d->reboot_enabled);
-    qemu_put_be32(f, d->clock_scale);
-    qemu_put_be32(f, d->int_type);
-    qemu_put_be32(f, d->free_run);
-    qemu_put_be32(f, d->locked);
-    qemu_put_be32(f, d->enabled);
-    qemu_put_timer(f, d->timer);
-    qemu_put_be32(f, d->timer1_preload);
-    qemu_put_be32(f, d->timer2_preload);
-    qemu_put_be32(f, d->stage);
-    qemu_put_be32(f, d->unlock_state);
-    qemu_put_be32(f, d->previous_reboot_flag);
-}
-
-static int i6300esb_load(QEMUFile *f, void *vp, int version)
-{
-    I6300State *d = (I6300State *) vp;
-
-    if (version != sizeof (I6300State))
-        return -EINVAL;
-
-    pci_device_load(&d->dev, f);
-    d->reboot_enabled = qemu_get_be32(f);
-    d->clock_scale = qemu_get_be32(f);
-    d->int_type = qemu_get_be32(f);
-    d->free_run = qemu_get_be32(f);
-    d->locked = qemu_get_be32(f);
-    d->enabled = qemu_get_be32(f);
-    qemu_get_timer(f, d->timer);
-    d->timer1_preload = qemu_get_be32(f);
-    d->timer2_preload = qemu_get_be32(f);
-    d->stage = qemu_get_be32(f);
-    d->unlock_state = qemu_get_be32(f);
-    d->previous_reboot_flag = qemu_get_be32(f);
-
-    return 0;
-}
+static const VMStateDescription vmstate_i6300esb = {
+    .name = "i6300esb_wdt",
+    .version_id = sizeof(I6300State),
+    .minimum_version_id = sizeof(I6300State),
+    .minimum_version_id_old = sizeof(I6300State),
+    .fields      = (VMStateField []) {
+        VMSTATE_PCI_DEVICE(dev, I6300State),
+        VMSTATE_INT32(reboot_enabled, I6300State),
+        VMSTATE_INT32(clock_scale, I6300State),
+        VMSTATE_INT32(int_type, I6300State),
+        VMSTATE_INT32(free_run, I6300State),
+        VMSTATE_INT32(locked, I6300State),
+        VMSTATE_INT32(enabled, I6300State),
+        VMSTATE_TIMER(timer, I6300State),
+        VMSTATE_UINT32(timer1_preload, I6300State),
+        VMSTATE_UINT32(timer2_preload, I6300State),
+        VMSTATE_INT32(stage, I6300State),
+        VMSTATE_INT32(unlock_state, I6300State),
+        VMSTATE_INT32(previous_reboot_flag, I6300State),
+        VMSTATE_END_OF_LIST()
+    }
+};

 static int i6300esb_init(PCIDevice *dev)
 {
@@ -439,8 +419,7 @@  static int i6300esb_init(PCIDevice *dev)
     pci_register_bar(&d->dev, 0, 0x10,
                             PCI_ADDRESS_SPACE_MEM, i6300esb_map);

-    register_savevm("i6300esb_wdt", -1, sizeof(I6300State),
-                     i6300esb_save, i6300esb_load, d);
+    vmstate_register(-1, &vmstate_i6300esb, d);

     return 0;
 }