From patchwork Fri Sep 25 19:42:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 34289 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 5833EB7BC0 for ; Sat, 26 Sep 2009 05:57:41 +1000 (EST) Received: from localhost ([127.0.0.1]:50769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MrGvC-0002q8-Ji for incoming@patchwork.ozlabs.org; Fri, 25 Sep 2009 15:57:38 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MrGhC-0006SH-Ng for qemu-devel@nongnu.org; Fri, 25 Sep 2009 15:43:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MrGh8-0006OX-I5 for qemu-devel@nongnu.org; Fri, 25 Sep 2009 15:43:09 -0400 Received: from [199.232.76.173] (port=56048 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MrGh7-0006Nk-6l for qemu-devel@nongnu.org; Fri, 25 Sep 2009 15:43:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22215) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MrGh6-0004ds-Lj for qemu-devel@nongnu.org; Fri, 25 Sep 2009 15:43:04 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8PJh3kt024986 for ; Fri, 25 Sep 2009 15:43:03 -0400 Received: from zweiblum.home.kraxel.org (vpn2-8-108.ams2.redhat.com [10.36.8.108]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n8PJgusU028042; Fri, 25 Sep 2009 15:42:57 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 7FC25700F0; Fri, 25 Sep 2009 21:42:50 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 25 Sep 2009 21:42:37 +0200 Message-Id: <1253907769-1067-13-git-send-email-kraxel@redhat.com> In-Reply-To: <1253907769-1067-1-git-send-email-kraxel@redhat.com> References: <1253907769-1067-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 12/24] pci: use qdev for device destruction. 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 pci_unregister_device is static now and hooked into Devicestate->exit. qdev_free(pci_device) works now. Signed-off-by: Gerd Hoffmann --- hw/pci-hotplug.c | 2 +- hw/pci.c | 5 +++-- hw/pci.h | 2 -- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index f3dc421..255decd 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -247,6 +247,6 @@ void pci_device_hot_remove_success(int pcibus, int slot) break; } - pci_unregister_device(d); + qdev_free(&d->qdev); } diff --git a/hw/pci.c b/hw/pci.c index 608792a..a6cd630 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -399,8 +399,9 @@ static void pci_unregister_io_regions(PCIDevice *pci_dev) } } -int pci_unregister_device(PCIDevice *pci_dev) +static int pci_unregister_device(DeviceState *dev) { + PCIDevice *pci_dev = DO_UPCAST(PCIDevice, qdev, dev); int ret = 0; if (pci_dev->unregister) @@ -412,7 +413,6 @@ int pci_unregister_device(PCIDevice *pci_dev) qemu_free_irqs(pci_dev->irq); pci_dev->bus->devices[pci_dev->devfn] = NULL; - qdev_free(&pci_dev->qdev); return 0; } @@ -945,6 +945,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) void pci_qdev_register(PCIDeviceInfo *info) { info->qdev.init = pci_qdev_init; + info->qdev.exit = pci_unregister_device; info->qdev.bus_info = &pci_bus_info; qdev_register(&info->qdev); } diff --git a/hw/pci.h b/hw/pci.h index 2b6a0f2..0ba7e6c 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -185,7 +185,6 @@ struct PCIDevice { /* do not access the following fields */ PCIConfigReadFunc *config_read; PCIConfigWriteFunc *config_write; - PCIUnregisterFunc *unregister; /* IRQ objects for the INTA-INTD pins. */ qemu_irq *irq; @@ -224,7 +223,6 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name, int instance_size, int devfn, PCIConfigReadFunc *config_read, PCIConfigWriteFunc *config_write); -int pci_unregister_device(PCIDevice *pci_dev); void pci_register_bar(PCIDevice *pci_dev, int region_num, uint32_t size, int type,