From patchwork Tue Jun 12 15:05:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 164428 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EBF32B6FBE for ; Wed, 13 Jun 2012 01:06:45 +1000 (EST) Received: from localhost ([::1]:44466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeSg7-0000mO-O2 for incoming@patchwork.ozlabs.org; Tue, 12 Jun 2012 11:06:43 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeSfk-0000iM-Lj for qemu-devel@nongnu.org; Tue, 12 Jun 2012 11:06:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeSfF-00065k-7l for qemu-devel@nongnu.org; Tue, 12 Jun 2012 11:06:20 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:54868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeSfD-00061T-Lx for qemu-devel@nongnu.org; Tue, 12 Jun 2012 11:05:48 -0400 X-IronPort-AV: E=Sophos;i="4.75,758,1330923600"; d="scan'208";a="198438605" Received: from ftlpmailmx02.citrite.net ([10.13.107.66]) by FTLPIPO02.CITRIX.COM with ESMTP/TLS/RC4-MD5; 12 Jun 2012 11:05:42 -0400 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.66) with Microsoft SMTP Server id 8.3.213.0; Tue, 12 Jun 2012 11:05:42 -0400 Received: from [10.80.3.61] (helo=perard.uk.xensource.com) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1SeSf8-0003OM-9V; Tue, 12 Jun 2012 16:05:42 +0100 From: Anthony PERARD To: QEMU-devel Date: Tue, 12 Jun 2012 16:05:18 +0100 Message-ID: <1339513523-1699-5-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1339513523-1699-1-git-send-email-anthony.perard@citrix.com> References: <1339513523-1699-1-git-send-email-anthony.perard@citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: Anthony PERARD , Anthony Liguori , Stefano Stabellini , "Michael S. Tsirkin" , Xen Devel Subject: [Qemu-devel] [PATCH V12 4/9] pci.c: Add opaque argument to pci_for_each_device. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The purpose is to have a more generic pci_for_each_device by passing an extra argument to the function called on every device. This patch will be used in a next patch. Signed-off-by: Anthony PERARD Acked-by: Stefano Stabellini --- hw/pci.c | 11 +++++++---- hw/pci.h | 4 +++- hw/xen_platform.c | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index c1ebdde..eec106a 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1127,7 +1127,9 @@ static const pci_class_desc pci_class_descriptions[] = }; static void pci_for_each_device_under_bus(PCIBus *bus, - void (*fn)(PCIBus *b, PCIDevice *d)) + void (*fn)(PCIBus *b, PCIDevice *d, + void *opaque), + void *opaque) { PCIDevice *d; int devfn; @@ -1135,18 +1137,19 @@ static void pci_for_each_device_under_bus(PCIBus *bus, for(devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) { d = bus->devices[devfn]; if (d) { - fn(bus, d); + fn(bus, d, opaque); } } } void pci_for_each_device(PCIBus *bus, int bus_num, - void (*fn)(PCIBus *b, PCIDevice *d)) + void (*fn)(PCIBus *b, PCIDevice *d, void *opaque), + void *opaque) { bus = pci_find_bus_nr(bus, bus_num); if (bus) { - pci_for_each_device_under_bus(bus, fn); + pci_for_each_device_under_bus(bus, fn, opaque); } } diff --git a/hw/pci.h b/hw/pci.h index c3cacce..ecf37fd 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -312,7 +312,9 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model, const char *default_devaddr); int pci_bus_num(PCIBus *s); -void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d)); +void pci_for_each_device(PCIBus *bus, int bus_num, + void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque), + void *opaque); PCIBus *pci_find_root_bus(int domain); int pci_find_domain(const PCIBus *bus); PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn); diff --git a/hw/xen_platform.c b/hw/xen_platform.c index 0214f37..c1fe984 100644 --- a/hw/xen_platform.c +++ b/hw/xen_platform.c @@ -83,7 +83,7 @@ static void log_writeb(PCIXenPlatformState *s, char val) #define UNPLUG_ALL_NICS 2 #define UNPLUG_AUX_IDE_DISKS 4 -static void unplug_nic(PCIBus *b, PCIDevice *d) +static void unplug_nic(PCIBus *b, PCIDevice *d, void *o) { if (pci_get_word(d->config + PCI_CLASS_DEVICE) == PCI_CLASS_NETWORK_ETHERNET) { @@ -96,10 +96,10 @@ static void unplug_nic(PCIBus *b, PCIDevice *d) static void pci_unplug_nics(PCIBus *bus) { - pci_for_each_device(bus, 0, unplug_nic); + pci_for_each_device(bus, 0, unplug_nic, NULL); } -static void unplug_disks(PCIBus *b, PCIDevice *d) +static void unplug_disks(PCIBus *b, PCIDevice *d, void *o) { if (pci_get_word(d->config + PCI_CLASS_DEVICE) == PCI_CLASS_STORAGE_IDE) { @@ -109,7 +109,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d) static void pci_unplug_disks(PCIBus *bus) { - pci_for_each_device(bus, 0, unplug_disks); + pci_for_each_device(bus, 0, unplug_disks, NULL); } static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t val)