qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [patch 01/18] qemu: add pci helper functions


From: Paul Brook
Subject: Re: [Qemu-devel] [patch 01/18] qemu: add pci helper functions
Date: Wed, 4 Feb 2009 14:56:20 +0000
User-agent: KMail/1.9.9

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.

Paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]