aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2009-09-16 13:40:27 +0300
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-05 09:32:50 -0500
commit7f23f812c49da6d6fe03bcd4bc2d07341e93db11 (patch)
tree68577e6d08641474f5dd3ea919e343b68eb14fe1 /hw/qdev.c
parentac0be998009257f0368e25470bac4e85b694ceaf (diff)
downloadqemu-7f23f812c49da6d6fe03bcd4bc2d07341e93db11.zip
qemu-7f23f812c49da6d6fe03bcd4bc2d07341e93db11.tar.gz
qemu-7f23f812c49da6d6fe03bcd4bc2d07341e93db11.tar.bz2
qemu/qdev: type safety in reset handler
Add type safety to qdev reset handlers, by declaring them as DeviceState * rather than void *. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r--hw/qdev.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index 3ce69be..86cf81b 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -222,6 +222,13 @@ DeviceState *qdev_device_add(QemuOpts *opts)
return qdev;
}
+static void qdev_reset(void *opaque)
+{
+ DeviceState *dev = opaque;
+ if (dev->info->reset)
+ dev->info->reset(dev);
+}
+
/* Initialize a device. Device properties should be set before calling
this function. IRQs and MMIO regions should be connected/mapped after
calling this function. */
@@ -233,8 +240,7 @@ int qdev_init(DeviceState *dev)
rc = dev->info->init(dev, dev->info);
if (rc < 0)
return rc;
- if (dev->info->reset)
- qemu_register_reset(dev->info->reset, dev);
+ qemu_register_reset(qdev_reset, dev);
if (dev->info->vmsd)
vmstate_register(-1, dev->info->vmsd, dev);
dev->state = DEV_STATE_INITIALIZED;
@@ -273,13 +279,12 @@ void qdev_free(DeviceState *dev)
if (dev->info->vmsd)
vmstate_unregister(dev->info->vmsd, dev);
#endif
- if (dev->info->reset)
- qemu_unregister_reset(dev->info->reset, dev);
if (dev->info->exit)
dev->info->exit(dev);
if (dev->opts)
qemu_opts_del(dev->opts);
}
+ qemu_unregister_reset(qdev_reset, dev);
QLIST_REMOVE(dev, sibling);
qemu_free(dev);
}