X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fpci%2Fsearch.c;h=c6e79d01ce3d1a8e4f747a762f8e052712320102;hb=ce9d3c9a6a9aef61525be07fe6ba27d937236aa2;hp=2dd8681d6b312a3b6c3c2362315dadddf9bf1de5;hpb=e049d1ca3094f3d1d94617f456a9961202f96e3a;p=mv-sheeva.git diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 2dd8681d6b3..c6e79d01ce3 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -15,8 +15,7 @@ DECLARE_RWSEM(pci_bus_sem); -static struct pci_bus * -pci_do_find_bus(struct pci_bus* bus, unsigned char busnr) +static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr) { struct pci_bus* child; struct list_head *tmp; @@ -140,12 +139,14 @@ struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) } /** - * pci_get_bus_and_slot - locate PCI device from a given PCI slot + * pci_get_bus_and_slot - locate PCI device from a given PCI bus & slot * @bus: number of PCI bus on which desired PCI device resides * @devfn: encodes number of PCI slot in which the desired PCI * device resides and the logical device number within that slot * in case of multi-function devices. * + * Note: the bus/slot search is limited to PCI domain (segment) 0. + * * Given a PCI bus and slot/function number, the desired PCI device * is located in system global list of PCI devices. If the device * is found, a pointer to its data structure is returned. If no @@ -158,7 +159,8 @@ struct pci_dev * pci_get_bus_and_slot(unsigned int bus, unsigned int devfn) struct pci_dev *dev = NULL; while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - if (dev->bus->number == bus && dev->devfn == devfn) + if (pci_domain_nr(dev->bus) == 0 && + (dev->bus->number == bus && dev->devfn == devfn)) return dev; } return NULL; @@ -200,7 +202,7 @@ static struct pci_dev * pci_find_subsys(unsigned int vendor, * can cause some machines to crash. So here we detect and flag that * situation and bail out early. */ - if (unlikely(list_empty(&pci_devices))) + if (unlikely(no_pci_devices())) return NULL; down_read(&pci_bus_sem); n = from ? from->global_list.next : pci_devices.next; @@ -275,7 +277,7 @@ pci_get_subsys(unsigned int vendor, unsigned int device, * can cause some machines to crash. So here we detect and flag that * situation and bail out early. */ - if (unlikely(list_empty(&pci_devices))) + if (unlikely(no_pci_devices())) return NULL; down_read(&pci_bus_sem); n = from ? from->global_list.next : pci_devices.next; @@ -404,10 +406,11 @@ const struct pci_device_id *pci_find_present(const struct pci_device_id *ids) while (ids->vendor || ids->subvendor || ids->class_mask) { list_for_each_entry(dev, &pci_devices, global_list) { if ((found = pci_match_one_device(ids, dev)) != NULL) - break; + goto exit; } ids++; } +exit: up_read(&pci_bus_sem); return found; }