|
From: | Anthony Liguori |
Subject: | Re: [Qemu-devel] [patch 01/18] qemu: add pci helper functions |
Date: | Wed, 04 Feb 2009 13:15:19 -0600 |
User-agent: | Thunderbird 2.0.0.19 (X11/20090105) |
Paul Brook wrote:
On Wednesday 04 February 2009, Marcelo Tosatti wrote:+PCIDevice *pci_find_device(int bus_num, int slot) +{ + int devfn; + PCIDevice *d; + PCIBus *bus = pci_find_bus(bus_num); + + if (!bus) + return NULL; + + for(devfn = 0; devfn < 256; devfn++) { + d = bus->devices[devfn]; + if (d && PCI_SLOT(devfn) == slot) + return d; + } + return NULL; +}This loop is bogus. You already know the devfn from the slot. It's also completely busted if you have multifunction devices.
It should probably try a bit harder to handle the multifunction case. You know your device is bus->devices[slot * 8] but you should also check slot * 8 + 1..slot * 8 + 7 to see if there are any sub functions and return NULL or something.
Regards, Anthony Liguori
Paul
[Prev in Thread] | Current Thread | [Next in Thread] |