Patchwork [v3,041/197] add class_init to deviceinfo

login
register
mail settings
Submitter Anthony Liguori
Date Dec. 12, 2011, 8:18 p.m.
Message ID <1323721273-32404-42-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/130845/
State New
Headers show

Comments

Anthony Liguori - Dec. 12, 2011, 8:18 p.m.
---
 hw/ccid.h |    2 +-
 hw/qdev.c |    4 ++++
 hw/qdev.h |    5 +++++
 3 files changed, 10 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/ccid.h b/hw/ccid.h
index ad055d3..d8e0485 100644
--- a/hw/ccid.h
+++ b/hw/ccid.h
@@ -17,7 +17,7 @@  typedef struct CCIDCardInfo CCIDCardInfo;
 
 #define TYPE_CCID_CARD "ccid-card"
 #define CCID_CARD(obj) \
-     OBJECT_CHECK(CCIDCard, (obj), TYPE_CCID_CARD)
+     OBJECT_CHECK(CCIDCardState, (obj), TYPE_CCID_CARD)
 #define CCID_CARD_CLASS(klass) \
      OBJECT_CLASS_CHECK(CCIDCardClass, (klass), TYPE_CCID_CARD)
 #define CCID_CARD_GET_CLASS(obj) \
diff --git a/hw/qdev.c b/hw/qdev.c
index 09f8b4c..d062470 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -54,6 +54,10 @@  static void qdev_subclass_init(ObjectClass *klass, void *data)
 
     /* Poison to try to detect future uses */
     dc->info->reset = NULL;
+
+    if (dc->info->class_init) {
+        dc->info->class_init(klass, data);
+    }
 }
 
 DeviceInfo *qdev_get_info(DeviceState *dev)
diff --git a/hw/qdev.h b/hw/qdev.h
index aab8f42..6617a2b 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -225,6 +225,11 @@  struct DeviceInfo {
     /* device state */
     const VMStateDescription *vmsd;
 
+    /**
+     * See @TypeInfo::class_init()
+     */
+    void (*class_init)(ObjectClass *klass, void *data);
+
     /* Private to qdev / bus.  */
     qdev_initfn init;
     qdev_event unplug;