qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] i2c: factor out VMSD to parent class
@ 2012-08-14  8:09 Peter A. G. Crosthwaite
  2012-08-14  8:27 ` Juan Quintela
  0 siblings, 1 reply; 7+ messages in thread
From: Peter A. G. Crosthwaite @ 2012-08-14  8:09 UTC (permalink / raw)
  To: qemu-devel, paul, peter.maydell, quintela, aliguori; +Cc: peter.crosthwaite

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 <peter.crosthwaite@petalogix.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-08-23 12:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-14  8:09 [Qemu-devel] [PATCH] i2c: factor out VMSD to parent class Peter A. G. Crosthwaite
2012-08-14  8:27 ` Juan Quintela
2012-08-14  8:46   ` Peter Maydell
2012-08-20  2:28     ` Peter Crosthwaite
2012-08-20 10:20       ` Juan Quintela
2012-08-21  4:02         ` Peter Crosthwaite
2012-08-23 11:59           ` Juan Quintela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).