]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
qdev: add a interface to register subclasses
authorAnthony Liguori <aliguori@us.ibm.com>
Thu, 15 Dec 2011 20:40:29 +0000 (14:40 -0600)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 27 Jan 2012 16:50:46 +0000 (10:50 -0600)
In order to introduce inheritance while still using the qdev registration
interfaces, we need to be able to use a parent other than TYPE_DEVICE.  Add a
new interface that allows this.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/qdev.c
hw/qdev.h

index a80ca7ccbc9d07716ae61f2928986382f02f143d..c4b5284fdc07d03689fb814af5dcb5fc5bd08dd8 100644 (file)
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -61,7 +61,7 @@ DeviceInfo *qdev_get_info(DeviceState *dev)
     return DEVICE_GET_CLASS(dev)->info;
 }
 
-void qdev_register(DeviceInfo *info)
+void qdev_register_subclass(DeviceInfo *info, const char *parent)
 {
     TypeInfo type_info = {};
 
@@ -69,7 +69,7 @@ void qdev_register(DeviceInfo *info)
     assert(!info->next);
 
     type_info.name = info->name;
-    type_info.parent = TYPE_DEVICE;
+    type_info.parent = parent;
     type_info.instance_size = info->size;
     type_info.class_init = qdev_subclass_init;
     type_info.class_data = info;
@@ -80,6 +80,11 @@ void qdev_register(DeviceInfo *info)
     device_info_list = info;
 }
 
+void qdev_register(DeviceInfo *info)
+{
+    qdev_register_subclass(info, TYPE_DEVICE);
+}
+
 static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)
 {
     DeviceInfo *info;
index f3c92199f014e8278f3da1e74c4d9c4a456a81bd..48f80a5cce222fe764c2d2a085669707c79f6cc5 100644 (file)
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -241,6 +241,7 @@ struct DeviceInfo {
 extern DeviceInfo *device_info_list;
 
 void qdev_register(DeviceInfo *info);
+void qdev_register_subclass(DeviceInfo *info, const char *parent);
 
 /* Register device properties.  */
 /* GPIO inputs also double as IRQ sinks.  */