From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUjAx-0003fS-6l for qemu-devel@nongnu.org; Wed, 04 Feb 2009 09:56:27 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUjAv-0003eT-Sf for qemu-devel@nongnu.org; Wed, 04 Feb 2009 09:56:26 -0500 Received: from [199.232.76.173] (port=34882 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUjAv-0003eH-He for qemu-devel@nongnu.org; Wed, 04 Feb 2009 09:56:25 -0500 Received: from mx20.gnu.org ([199.232.41.8]:45280) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LUjAv-0001yn-5Z for qemu-devel@nongnu.org; Wed, 04 Feb 2009 09:56:25 -0500 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUjAt-0006vs-US for qemu-devel@nongnu.org; Wed, 04 Feb 2009 09:56:24 -0500 From: Paul Brook Subject: Re: [Qemu-devel] [patch 01/18] qemu: add pci helper functions Date: Wed, 4 Feb 2009 14:56:20 +0000 References: <20090204133303.113145633@localhost.localdomain> <20090204133923.175155873@localhost.localdomain> In-Reply-To: <20090204133923.175155873@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200902041456.20944.paul@codesourcery.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Marcelo Tosatti On Wednesday 04 February 2009, Marcelo Tosatti wrote: > +PCIDevice *pci_find_device(int bus_num, int slot) > +{ > + =A0 =A0int devfn; > + =A0 =A0PCIDevice *d; > + =A0 =A0PCIBus *bus =3D pci_find_bus(bus_num); > + > + =A0 =A0if (!bus) > + =A0 =A0 =A0 =A0return NULL; > + > + =A0 =A0for(devfn =3D 0; devfn < 256; devfn++) { > + =A0 =A0 =A0 =A0d =3D bus->devices[devfn]; > + =A0 =A0 =A0 =A0 =A0 =A0if (d && PCI_SLOT(devfn) =3D=3D slot) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return d; > + =A0 =A0} > + =A0 =A0return NULL; > +} This loop is bogus. You already know the devfn from the slot. It's also completely busted if you have multifunction devices. Paul