aboutsummaryrefslogtreecommitdiff
path: root/hw/i2c.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-09-29 22:48:28 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-05 09:32:37 -0500
commitbcbe8068b7385194b6055d8023de45dd4ccc286a (patch)
tree4d6f0fc74267060a2ec881cad1cc27508934d248 /hw/i2c.c
parent8d0eb050d64a3b2251dd71769f9a42d0f21b0433 (diff)
downloadqemu-bcbe8068b7385194b6055d8023de45dd4ccc286a.zip
qemu-bcbe8068b7385194b6055d8023de45dd4ccc286a.tar.gz
qemu-bcbe8068b7385194b6055d8023de45dd4ccc286a.tar.bz2
vmstate: port i2c_slave device
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/i2c.c')
-rw-r--r--hw/i2c.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/hw/i2c.c b/hw/i2c.c
index 1641cec..db9283d 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -142,19 +142,38 @@ void i2c_nack(i2c_bus *bus)
dev->info->event(dev, I2C_NACK);
}
-void i2c_slave_save(QEMUFile *f, i2c_slave *dev)
-{
- qemu_put_8s(f, &dev->address);
-}
-
-void i2c_slave_load(QEMUFile *f, i2c_slave *dev)
+static int i2c_slave_post_load(void *opaque, int version_id)
{
+ i2c_slave *dev = opaque;
i2c_bus *bus;
bus = FROM_QBUS(i2c_bus, qdev_get_parent_bus(&dev->qdev));
- qemu_get_8s(f, &dev->address);
if (bus->saved_address == dev->address) {
bus->current_dev = dev;
}
+ return 0;
+}
+
+static const VMStateDescription vmstate_i2c_slave = {
+ .name = "i2c_slave",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .post_load = i2c_slave_post_load,
+ .fields = (VMStateField []) {
+ VMSTATE_UINT8(address, i2c_slave),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+void i2c_slave_save(QEMUFile *f, i2c_slave *dev)
+{
+ vmstate_save_state(f, &vmstate_i2c_slave, dev);
+}
+
+void i2c_slave_load(QEMUFile *f, i2c_slave *dev)
+{
+ vmstate_load_state(f, &vmstate_i2c_slave, dev,
+ vmstate_i2c_slave.version_id);
}
static int i2c_slave_qdev_init(DeviceState *dev, DeviceInfo *base)