From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N5KQq-0002rk-VF for qemu-devel@nongnu.org; Tue, 03 Nov 2009 09:32:25 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N5KQm-0002pV-FE for qemu-devel@nongnu.org; Tue, 03 Nov 2009 09:32:24 -0500 Received: from [199.232.76.173] (port=60046 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N5KQm-0002pJ-2L for qemu-devel@nongnu.org; Tue, 03 Nov 2009 09:32:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8019) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N5KQl-0000pA-Jh for qemu-devel@nongnu.org; Tue, 03 Nov 2009 09:32:19 -0500 Date: Tue, 3 Nov 2009 16:29:50 +0200 From: "Michael S. Tsirkin" Message-ID: <20091103142950.GH5605@redhat.com> References: <1256905286-25435-1-git-send-email-yamahata@valinux.co.jp> <1256905286-25435-31-git-send-email-yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1256905286-25435-31-git-send-email-yamahata@valinux.co.jp> Subject: [Qemu-devel] Re: [PATCH V6 30/32] pci: factor out pci_for_each_device(). List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: qemu-devel@nongnu.org On Fri, Oct 30, 2009 at 09:21:24PM +0900, Isaku Yamahata wrote: > 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++) { 256 -> ARRAY_SIZE(bus->devices) > + 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); > } > } > > -- > 1.6.0.2