提交 ff46d9d4 编写于 作者: P Philippe Mathieu-Daudé 提交者: Paolo Bonzini

qdev: Remove DeviceClass::init() and ::exit()

Since no devices use it, we can safely remove it.
Signed-off-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180419212727.26095-5-f4bug@amsat.org>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
[Removal of DeviceClass::init() moved from previous patch, missing
documentation updates supplied]
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Message-Id: <20180528144509.15812-5-armbru@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 dbfe0013
...@@ -208,32 +208,6 @@ void device_listener_unregister(DeviceListener *listener) ...@@ -208,32 +208,6 @@ void device_listener_unregister(DeviceListener *listener)
QTAILQ_REMOVE(&device_listeners, listener, link); QTAILQ_REMOVE(&device_listeners, listener, link);
} }
static void device_realize(DeviceState *dev, Error **errp)
{
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dc->init) {
int rc = dc->init(dev);
if (rc < 0) {
error_setg(errp, "Device initialization failed.");
return;
}
}
}
static void device_unrealize(DeviceState *dev, Error **errp)
{
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dc->exit) {
int rc = dc->exit(dev);
if (rc < 0) {
error_setg(errp, "Device exit failed.");
return;
}
}
}
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
int required_for_version) int required_for_version)
{ {
...@@ -1065,8 +1039,6 @@ static void device_class_init(ObjectClass *class, void *data) ...@@ -1065,8 +1039,6 @@ static void device_class_init(ObjectClass *class, void *data)
DeviceClass *dc = DEVICE_CLASS(class); DeviceClass *dc = DEVICE_CLASS(class);
class->unparent = device_unparent; class->unparent = device_unparent;
dc->realize = device_realize;
dc->unrealize = device_unrealize;
/* by default all devices were considered as hotpluggable, /* by default all devices were considered as hotpluggable,
* so with intent to check it in generic qdev_unplug() / * so with intent to check it in generic qdev_unplug() /
......
...@@ -29,8 +29,6 @@ typedef enum DeviceCategory { ...@@ -29,8 +29,6 @@ typedef enum DeviceCategory {
DEVICE_CATEGORY_MAX DEVICE_CATEGORY_MAX
} DeviceCategory; } DeviceCategory;
typedef int (*qdev_initfn)(DeviceState *dev);
typedef int (*qdev_event)(DeviceState *dev);
typedef void (*DeviceRealize)(DeviceState *dev, Error **errp); typedef void (*DeviceRealize)(DeviceState *dev, Error **errp);
typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp); typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp);
typedef void (*DeviceReset)(DeviceState *dev); typedef void (*DeviceReset)(DeviceState *dev);
...@@ -43,13 +41,9 @@ struct VMStateDescription; ...@@ -43,13 +41,9 @@ struct VMStateDescription;
* DeviceClass: * DeviceClass:
* @props: Properties accessing state fields. * @props: Properties accessing state fields.
* @realize: Callback function invoked when the #DeviceState:realized * @realize: Callback function invoked when the #DeviceState:realized
* property is changed to %true. The default invokes @init if not %NULL. * property is changed to %true.
* @unrealize: Callback function invoked when the #DeviceState:realized * @unrealize: Callback function invoked when the #DeviceState:realized
* property is changed to %false. * property is changed to %false.
* @init: Callback function invoked when the #DeviceState::realized property
* is changed to %true. Deprecated, new types inheriting directly from
* TYPE_DEVICE should use @realize instead, new leaf types should consult
* their respective parent type.
* @hotpluggable: indicates if #DeviceClass is hotpluggable, available * @hotpluggable: indicates if #DeviceClass is hotpluggable, available
* as readonly "hotpluggable" property of #DeviceState instance * as readonly "hotpluggable" property of #DeviceState instance
* *
...@@ -73,19 +67,15 @@ struct VMStateDescription; ...@@ -73,19 +67,15 @@ struct VMStateDescription;
* object_initialize() in their own #TypeInfo.instance_init and forward the * object_initialize() in their own #TypeInfo.instance_init and forward the
* realization events appropriately. * realization events appropriately.
* *
* The @init callback is considered private to a particular bus implementation
* (immediate abstract child types of TYPE_DEVICE). Derived leaf types set an
* "init" callback on their parent class instead.
*
* Any type may override the @realize and/or @unrealize callbacks but needs * Any type may override the @realize and/or @unrealize callbacks but needs
* to call the parent type's implementation if keeping their functionality * to call the parent type's implementation if keeping their functionality
* is desired. Refer to QOM documentation for further discussion and examples. * is desired. Refer to QOM documentation for further discussion and examples.
* *
* <note> * <note>
* <para> * <para>
* If a type derived directly from TYPE_DEVICE implements @realize, it does * Since TYPE_DEVICE doesn't implement @realize and @unrealize, types
* not need to implement @init and therefore does not need to store and call * derived directly from it need not call their parent's @realize and
* #DeviceClass' default @realize callback. * @unrealize.
* For other types consult the documentation and implementation of the * For other types consult the documentation and implementation of the
* respective parent types. * respective parent types.
* </para> * </para>
...@@ -124,8 +114,6 @@ typedef struct DeviceClass { ...@@ -124,8 +114,6 @@ typedef struct DeviceClass {
const struct VMStateDescription *vmsd; const struct VMStateDescription *vmsd;
/* Private to qdev / bus. */ /* Private to qdev / bus. */
qdev_initfn init; /* TODO remove, once users are converted to realize */
qdev_event exit; /* TODO remove, once users are converted to unrealize */
const char *bus_type; const char *bus_type;
} DeviceClass; } DeviceClass;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册