From patchwork Mon Nov 8 13:46:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 70420 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5DE81B6EED for ; Tue, 9 Nov 2010 00:52:31 +1100 (EST) Received: from localhost ([127.0.0.1]:34208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFS96-0003md-Ls for incoming@patchwork.ozlabs.org; Mon, 08 Nov 2010 08:52:28 -0500 Received: from [140.186.70.92] (port=38765 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFS3B-0008Ib-Cq for qemu-devel@nongnu.org; Mon, 08 Nov 2010 08:46:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFS3A-0005k9-0F for qemu-devel@nongnu.org; Mon, 08 Nov 2010 08:46:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFS39-0005io-OS for qemu-devel@nongnu.org; Mon, 08 Nov 2010 08:46:19 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA8DkGEQ026316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 8 Nov 2010 08:46:16 -0500 Received: from rincewind.home.kraxel.org (vpn2-10-114.ams2.redhat.com [10.36.10.114]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oA8DkFGH002156; Mon, 8 Nov 2010 08:46:15 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id ADAF64512F; Mon, 8 Nov 2010 14:46:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 8 Nov 2010 14:46:07 +0100 Message-Id: <1289223970-31221-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1289223970-31221-1-git-send-email-kraxel@redhat.com> References: <1289223970-31221-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 1/4] intel-hda: exit cleanup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); };