diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-04 11:36:01 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-01-27 10:50:46 -0600 |
commit | 94afdadcb3ab71f5123f719d74065c6f4cc837ea (patch) | |
tree | 747906b65b821ed33449a231b9b68ace8ac06374 /hw/qdev.c | |
parent | f79f2bfc6aae76718652f0b3e15a849f7b58104a (diff) |
qdev: use a wrapper to access reset and promote reset to a class method
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r-- | hw/qdev.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -48,7 +48,12 @@ static BusState *qbus_find(const char *path); static void qdev_subclass_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->info = data; + dc->reset = dc->info->reset; + + /* Poison to try to detect future uses */ + dc->info->reset = NULL; } DeviceInfo *qdev_get_info(DeviceState *dev) @@ -378,8 +383,8 @@ int qdev_init(DeviceState *dev) dev->alias_required_for_version); } dev->state = DEV_STATE_INITIALIZED; - if (dev->hotplugged && qdev_get_info(dev)->reset) { - qdev_get_info(dev)->reset(dev); + if (dev->hotplugged) { + device_reset(dev); } return 0; } @@ -407,9 +412,7 @@ int qdev_unplug(DeviceState *dev) static int qdev_reset_one(DeviceState *dev, void *opaque) { - if (qdev_get_info(dev)->reset) { - qdev_get_info(dev)->reset(dev); - } + device_reset(dev); return 0; } @@ -1593,6 +1596,15 @@ void qdev_machine_init(void) qdev_get_peripheral(); } +void device_reset(DeviceState *dev) +{ + DeviceClass *klass = DEVICE_GET_CLASS(dev); + + if (klass->reset) { + klass->reset(dev); + } +} + static TypeInfo device_type_info = { .name = TYPE_DEVICE, .parent = TYPE_OBJECT, |