From 959f733a296a69564a075d60d8c821ad8e258623 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 1 Sep 2009 09:56:12 +0200 Subject: [PATCH] qdev: integrate reset Signed-off-by: Gerd Hoffmann Signed-off-by: Anthony Liguori --- hw/qdev.c | 11 ++++++++++- hw/qdev.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/qdev.c b/hw/qdev.c index 0e9732b1ca..675248fc12 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -214,12 +214,21 @@ DeviceState *qdev_device_add(QemuOpts *opts) calling this function. */ int qdev_init(DeviceState *dev) { - return dev->info->init(dev, dev->info); + int rc; + + rc = dev->info->init(dev, dev->info); + if (rc < 0) + return rc; + if (dev->info->reset) + qemu_register_reset(dev->info->reset, dev); + return 0; } /* Unlink device from bus and free the structure. */ void qdev_free(DeviceState *dev) { + if (dev->info->reset) + qemu_unregister_reset(dev->info->reset, dev); LIST_REMOVE(dev, sibling); qemu_free(dev); } diff --git a/hw/qdev.h b/hw/qdev.h index 56a0c1f1bb..b146aa1406 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -108,6 +108,9 @@ struct DeviceInfo { Property *props; int no_user; + /* callbacks */ + QEMUResetHandler *reset; + /* Private to qdev / bus. */ qdev_initfn init; BusInfo *bus_info;