提交 3cc90eb2 编写于 作者: A Anthony Liguori

qdev: add a interface to register subclasses

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: NAnthony Liguori <aliguori@us.ibm.com>
上级 94afdadc
......@@ -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;
......
......@@ -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. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册