qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] i2c: factor out VMSD to parent class


From: Peter A. G. Crosthwaite
Subject: [Qemu-devel] [PATCH] i2c: factor out VMSD to parent class
Date: Tue, 14 Aug 2012 18:09:47 +1000

Hi All. PMM raised a query on a recent series of mine (the SSI series) about
handling VMSD for devices which define state at multiple levels of the QOM
heirachy. Rather than complicate the discussion over in my series im trying to
start the discussion with an existing subsystem - i2c. This patch is a first
attempt at trying to get the VMSD for generic I2C state factored out of the
individual devices and handled transparently by the super class (I2C_SLAVE).

I have applied the change to only the one I2C device (max7310). If we were going
to run with this, the change pattern would be applied to all I2C devices.

This patch is not a merge proposal it is RFC only.

Please review and let us know if this is flawed or not. What needs to be done to
get this multi-level VMSD going?

I will use whatever review I get to fix my SSI series as well as fix I2C.

Signed-off-by: Peter A. G. Crosthwaite <address@hidden>
---
 hw/i2c.c     |    2 ++
 hw/i2c.h     |    8 --------
 hw/max7310.c |    1 -
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/hw/i2c.c b/hw/i2c.c
index 296bece..17e1633 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -207,6 +207,8 @@ static int i2c_slave_qdev_init(DeviceState *dev)
     I2CSlave *s = I2C_SLAVE_FROM_QDEV(dev);
     I2CSlaveClass *sc = I2C_SLAVE_GET_CLASS(s);
 
+    vmstate_register(NULL, 0, &vmstate_i2c_slave, s);
+
     return sc->init(s);
 }
 
diff --git a/hw/i2c.h b/hw/i2c.h
index 0f5682b..5b75ecc 100644
--- a/hw/i2c.h
+++ b/hw/i2c.h
@@ -81,12 +81,4 @@ void lm832x_key_event(DeviceState *dev, int key, int state);
 
 extern const VMStateDescription vmstate_i2c_slave;
 
-#define VMSTATE_I2C_SLAVE(_field, _state) {                          \
-    .name       = (stringify(_field)),                               \
-    .size       = sizeof(I2CSlave),                                  \
-    .vmsd       = &vmstate_i2c_slave,                                \
-    .flags      = VMS_STRUCT,                                        \
-    .offset     = vmstate_offset_value(_state, _field, I2CSlave),    \
-}
-
 #endif
diff --git a/hw/max7310.c b/hw/max7310.c
index 1ed18ba..9375691 100644
--- a/hw/max7310.c
+++ b/hw/max7310.c
@@ -156,7 +156,6 @@ static const VMStateDescription vmstate_max7310 = {
         VMSTATE_UINT8(polarity, MAX7310State),
         VMSTATE_UINT8(status, MAX7310State),
         VMSTATE_UINT8(command, MAX7310State),
-        VMSTATE_I2C_SLAVE(i2c, MAX7310State),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]