From patchwork Fri Oct 30 12:21:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 37305 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 AB078B7C2D for ; Sat, 31 Oct 2009 01:28:11 +1100 (EST) Received: from localhost ([127.0.0.1]:58873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N3sSW-0000O1-FR for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2009 10:28:08 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N3r1n-00025f-VP for qemu-devel@nongnu.org; Fri, 30 Oct 2009 08:56:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N3r1i-00021x-Cv for qemu-devel@nongnu.org; Fri, 30 Oct 2009 08:56:26 -0400 Received: from [199.232.76.173] (port=33105 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N3r1h-00021b-EK for qemu-devel@nongnu.org; Fri, 30 Oct 2009 08:56:22 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:52740) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N3r1g-0006zQ-TE for qemu-devel@nongnu.org; Fri, 30 Oct 2009 08:56:21 -0400 Received: from nm.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with ESMTP id 591461806E; Fri, 30 Oct 2009 21:23:07 +0900 (JST) Received: from yamahata by nm.local.valinux.co.jp with local (Exim 4.69) (envelope-from ) id 1N3qTw-0006e6-5o; Fri, 30 Oct 2009 21:21:28 +0900 From: Isaku Yamahata To: qemu-devel@nongnu.org, mst@redhat.com Date: Fri, 30 Oct 2009 21:21:24 +0900 Message-Id: <1256905286-25435-31-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1256905286-25435-1-git-send-email-yamahata@valinux.co.jp> References: <1256905286-25435-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 V6 30/32] pci: factor out pci_for_each_device(). 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 split out device iteration logic from pci_for_each_device(). factored out function, pci_for_each_device_under_bus() will be used later. Signed-off-by: Isaku Yamahata --- hw/pci.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index b43f6c6..d565f6e 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -885,19 +885,26 @@ static void pci_info_device(PCIBus *bus, PCIDevice *d) } } -void pci_for_each_device(PCIBus *bus, int bus_num, - void (*fn)(PCIBus *b, PCIDevice *d)) +static void pci_for_each_device_under_bus(PCIBus *bus, + void (*fn)(PCIBus *b, PCIDevice *d)) { PCIDevice *d; int devfn; + for(devfn = 0; devfn < 256; devfn++) { + d = bus->devices[devfn]; + if (d) + fn(bus, d); + } +} + +void pci_for_each_device(PCIBus *bus, int bus_num, + void (*fn)(PCIBus *b, PCIDevice *d)) +{ bus = pci_find_bus(bus, bus_num); + if (bus) { - for(devfn = 0; devfn < 256; devfn++) { - d = bus->devices[devfn]; - if (d) - fn(bus, d); - } + pci_for_each_device_under_bus(bus, fn); } }