From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MiOzM-0001Jn-Or for qemu-devel@nongnu.org; Tue, 01 Sep 2009 04:45:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MiOzH-0001Cz-R1 for qemu-devel@nongnu.org; Tue, 01 Sep 2009 04:45:16 -0400 Received: from [199.232.76.173] (port=34948 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MiOzH-0001Cr-JG for qemu-devel@nongnu.org; Tue, 01 Sep 2009 04:45:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30424) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MiOzH-0002Hz-0t for qemu-devel@nongnu.org; Tue, 01 Sep 2009 04:45:11 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n817uKlw028987 for ; Tue, 1 Sep 2009 03:56:20 -0400 From: Gerd Hoffmann Date: Tue, 1 Sep 2009 09:56:12 +0200 Message-Id: <1251791775-5358-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1251791775-5358-1-git-send-email-kraxel@redhat.com> References: <1251791775-5358-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 1/4] qdev: integrate reset List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- hw/qdev.c | 11 ++++++++++- hw/qdev.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index ff2f096..e045968 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -211,12 +211,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 af735d7..fde29ea 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -110,6 +110,9 @@ struct DeviceInfo { Property *props; int no_user; + /* callbacks */ + QEMUResetHandler *reset; + /* Private to qdev / bus. */ qdev_initfn init; BusInfo *bus_info; -- 1.6.2.5