From patchwork Wed Jan 6 02:39:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 42260 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 7D1F8B6EEF for ; Wed, 6 Jan 2010 14:06:21 +1100 (EST) Received: from localhost ([127.0.0.1]:58595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSMDy-0001F9-Ru for incoming@patchwork.ozlabs.org; Tue, 05 Jan 2010 22:06:18 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSLog-0004Ot-0w for qemu-devel@nongnu.org; Tue, 05 Jan 2010 21:40:10 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSLoT-0004HW-B8 for qemu-devel@nongnu.org; Tue, 05 Jan 2010 21:40:01 -0500 Received: from [199.232.76.173] (port=54790 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSLoS-0004H5-DY for qemu-devel@nongnu.org; Tue, 05 Jan 2010 21:39:56 -0500 Received: from mail.valinux.co.jp ([210.128.90.3]:60931) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NSLoR-0003kx-39 for qemu-devel@nongnu.org; Tue, 05 Jan 2010 21:39:56 -0500 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 40C051829F; Wed, 6 Jan 2010 11:39:45 +0900 (JST) Received: (nullmailer pid 28770 invoked by uid 1000); Wed, 06 Jan 2010 02:39:52 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org, kraxel@redhat.com, aurelien@aurel32.net Date: Wed, 6 Jan 2010 11:39:46 +0900 Message-Id: <1262745591-28697-23-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.5.4 In-Reply-To: <1262745591-28697-1-git-send-email-yamahata@valinux.co.jp> References: <1262745591-28697-1-git-send-email-yamahata@valinux.co.jp> X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp Subject: [Qemu-devel] [PATCH V12 22/27] pci hotplug: add argument to pci hot plug callback. 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 argument, DeviceState*, to pci hot plug callback. The argument will be used later to remove global variable. Signed-off-by: Isaku Yamahata Acked-by: Gerd Hoffmann --- changes v10 -> v11: - change callback argument from void* to DeviceState*. --- hw/acpi_piix4.c | 6 +++--- hw/pci.c | 8 +++++--- hw/pci.h | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index f06f257..574392e 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -562,7 +562,7 @@ static void pciej_write(void *opaque, uint32_t addr, uint32_t val) #endif } -static int piix4_device_hotplug(PCIDevice *dev, int state); +static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, int state); void piix4_acpi_system_hot_add_init(PCIBus *bus) { @@ -575,7 +575,7 @@ void piix4_acpi_system_hot_add_init(PCIBus *bus) register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, bus); register_ioport_read(PCI_EJ_BASE, 4, 4, pciej_read, bus); - pci_bus_hotplug(bus, piix4_device_hotplug); + pci_bus_hotplug(bus, piix4_device_hotplug, NULL); } static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot) @@ -590,7 +590,7 @@ static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot) p->down |= (1 << slot); } -static int piix4_device_hotplug(PCIDevice *dev, int state) +static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, int state) { int slot = PCI_SLOT(dev->devfn); diff --git a/hw/pci.c b/hw/pci.c index 0814383..7b6b02d 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -41,6 +41,7 @@ struct PCIBus { pci_set_irq_fn set_irq; pci_map_irq_fn map_irq; pci_hotplug_fn hotplug; + DeviceState *hotplug_qdev; uint32_t config_reg; /* XXX: suppress */ void *irq_opaque; PCIDevice *devices[256]; @@ -232,10 +233,11 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, bus->irq_count = qemu_mallocz(nirq * sizeof(bus->irq_count[0])); } -void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug) +void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *qdev) { bus->qbus.allow_hotplug = 1; bus->hotplug = hotplug; + bus->hotplug_qdev = qdev; } void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base) @@ -1384,7 +1386,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_add_option_rom(pci_dev); if (qdev->hotplugged) - bus->hotplug(pci_dev, 1); + bus->hotplug(bus->hotplug_qdev, pci_dev, 1); return 0; } @@ -1392,7 +1394,7 @@ static int pci_unplug_device(DeviceState *qdev) { PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev); - dev->bus->hotplug(dev, 0); + dev->bus->hotplug(dev->bus->hotplug_qdev, dev, 0); return 0; } diff --git a/hw/pci.h b/hw/pci.h index fd16460..79b198a 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -273,13 +273,13 @@ int pci_device_load(PCIDevice *s, QEMUFile *f); typedef void (*pci_set_irq_fn)(void *opaque, int irq_num, int level); typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num); -typedef int (*pci_hotplug_fn)(PCIDevice *pci_dev, int state); +typedef int (*pci_hotplug_fn)(DeviceState *qdev, PCIDevice *pci_dev, int state); void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent, const char *name, int devfn_min); PCIBus *pci_bus_new(DeviceState *parent, const char *name, int devfn_min); void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, void *irq_opaque, int nirq); -void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug); +void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *dev); PCIBus *pci_register_bus(DeviceState *parent, const char *name, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, void *irq_opaque, int devfn_min, int nirq);