summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-09-29 22:48:27 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-05 09:32:37 -0500
commit0a269fb96fe41025cdf674640ac3603c6a434e4e (patch)
tree0c3ff194ebec74d8df80aae1de56dbcc50dc1523 /hw
parent91451b37da7b9a3c33673eb5b6363c8e5070a696 (diff)
downloadqemu-0a269fb96fe41025cdf674640ac3603c6a434e4e.tar.gz
qemu-0a269fb96fe41025cdf674640ac3603c6a434e4e.tar.bz2
qemu-0a269fb96fe41025cdf674640ac3603c6a434e4e.zip
vmstate: port i2c_bus device
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/i2c.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/hw/i2c.c b/hw/i2c.c
index 1033e00244..1641cec068 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -26,36 +26,43 @@ static struct BusInfo i2c_bus_info = {
}
};
-static void i2c_bus_save(QEMUFile *f, void *opaque)
+static void i2c_bus_pre_save(void *opaque)
{
- i2c_bus *bus = (i2c_bus *)opaque;
- bus->saved_address = bus->current_dev ? bus->current_dev->address : -1;
+ i2c_bus *bus = opaque;
- qemu_put_8s(f, &bus->saved_address);
+ bus->saved_address = bus->current_dev ? bus->current_dev->address : -1;
}
-static int i2c_bus_load(QEMUFile *f, void *opaque, int version_id)
+static int i2c_bus_post_load(void *opaque, int version_id)
{
- i2c_bus *bus = (i2c_bus *)opaque;
-
- if (version_id != 1)
- return -EINVAL;
+ i2c_bus *bus = opaque;
/* The bus is loaded before attached devices, so load and save the
current device id. Devices will check themselves as loaded. */
- qemu_get_8s(f, &bus->saved_address);
bus->current_dev = NULL;
-
return 0;
}
+static const VMStateDescription vmstate_i2c_bus = {
+ .name = "i2c_bus",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .pre_save = i2c_bus_pre_save,
+ .post_load = i2c_bus_post_load,
+ .fields = (VMStateField []) {
+ VMSTATE_UINT8(saved_address, i2c_bus),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
/* Create a new I2C bus. */
i2c_bus *i2c_init_bus(DeviceState *parent, const char *name)
{
i2c_bus *bus;
bus = FROM_QBUS(i2c_bus, qbus_create(&i2c_bus_info, parent, name));
- register_savevm("i2c_bus", -1, 1, i2c_bus_save, i2c_bus_load, bus);
+ vmstate_register(-1, &vmstate_i2c_bus, bus);
return bus;
}