From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53762 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFlk3-0005EK-L2 for qemu-devel@nongnu.org; Tue, 09 Nov 2010 05:47:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFlk1-0002nX-TK for qemu-devel@nongnu.org; Tue, 09 Nov 2010 05:47:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFlk1-0002n8-MG for qemu-devel@nongnu.org; Tue, 09 Nov 2010 05:47:53 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA9Alq03006805 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Nov 2010 05:47:53 -0500 From: Gerd Hoffmann Date: Tue, 9 Nov 2010 11:47:44 +0100 Message-Id: <1289299669-5504-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1289299669-5504-1-git-send-email-kraxel@redhat.com> References: <1289299669-5504-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/6] intel-hda: exit cleanup List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add pci exit callback for the intel-hda device and cleanup properly. Also add an exit callback to the HDA bus implementation and make sure it is called on qdev_free(). Signed-off-by: Gerd Hoffmann --- hw/intel-hda.c | 20 ++++++++++++++++++++ hw/intel-hda.h | 1 + 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/hw/intel-hda.c b/hw/intel-hda.c index ccb059d..78c32da 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -61,9 +61,20 @@ static int hda_codec_dev_init(DeviceState *qdev, DeviceInfo *base) return info->init(dev); } +static int hda_codec_dev_exit(DeviceState *qdev) +{ + HDACodecDevice *dev = DO_UPCAST(HDACodecDevice, qdev, qdev); + + if (dev->info->exit) { + dev->info->exit(dev); + } + return 0; +} + void hda_codec_register(HDACodecDeviceInfo *info) { info->qdev.init = hda_codec_dev_init; + info->qdev.exit = hda_codec_dev_exit; info->qdev.bus_info = &hda_codec_bus_info; qdev_register(&info->qdev); } @@ -1137,6 +1148,14 @@ static int intel_hda_init(PCIDevice *pci) return 0; } +static int intel_hda_exit(PCIDevice *pci) +{ + IntelHDAState *d = DO_UPCAST(IntelHDAState, pci, pci); + + cpu_unregister_io_memory(d->mmio_addr); + return 0; +} + static int intel_hda_post_load(void *opaque, int version) { IntelHDAState* d = opaque; @@ -1219,6 +1238,7 @@ static PCIDeviceInfo intel_hda_info = { .qdev.vmsd = &vmstate_intel_hda, .qdev.reset = intel_hda_reset, .init = intel_hda_init, + .exit = intel_hda_exit, .qdev.props = (Property[]) { DEFINE_PROP_UINT32("debug", IntelHDAState, debug, 0), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/intel-hda.h b/hw/intel-hda.h index ba290ec..4e44e38 100644 --- a/hw/intel-hda.h +++ b/hw/intel-hda.h @@ -32,6 +32,7 @@ struct HDACodecDevice { struct HDACodecDeviceInfo { DeviceInfo qdev; int (*init)(HDACodecDevice *dev); + int (*exit)(HDACodecDevice *dev); void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data); void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running); }; -- 1.7.1