diff options
Diffstat (limited to 'drivers/pci/search.c')
| -rw-r--r-- | drivers/pci/search.c | 63 |
1 files changed, 21 insertions, 42 deletions
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 993d4a0a2469..bf969ba58e59 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
| @@ -41,7 +41,7 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev) | |||
| 41 | continue; | 41 | continue; |
| 42 | } | 42 | } |
| 43 | /* PCI device should connect to a PCIe bridge */ | 43 | /* PCI device should connect to a PCIe bridge */ |
| 44 | if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) { | 44 | if (pci_pcie_type(pdev) != PCI_EXP_TYPE_PCI_BRIDGE) { |
| 45 | /* Busted hardware? */ | 45 | /* Busted hardware? */ |
| 46 | WARN_ON_ONCE(1); | 46 | WARN_ON_ONCE(1); |
| 47 | return NULL; | 47 | return NULL; |
| @@ -130,16 +130,14 @@ pci_find_next_bus(const struct pci_bus *from) | |||
| 130 | * decrement the reference count by calling pci_dev_put(). | 130 | * decrement the reference count by calling pci_dev_put(). |
| 131 | * If no device is found, %NULL is returned. | 131 | * If no device is found, %NULL is returned. |
| 132 | */ | 132 | */ |
| 133 | struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) | 133 | struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn) |
| 134 | { | 134 | { |
| 135 | struct list_head *tmp; | ||
| 136 | struct pci_dev *dev; | 135 | struct pci_dev *dev; |
| 137 | 136 | ||
| 138 | WARN_ON(in_interrupt()); | 137 | WARN_ON(in_interrupt()); |
| 139 | down_read(&pci_bus_sem); | 138 | down_read(&pci_bus_sem); |
| 140 | 139 | ||
| 141 | list_for_each(tmp, &bus->devices) { | 140 | list_for_each_entry(dev, &bus->devices, bus_list) { |
| 142 | dev = pci_dev_b(tmp); | ||
| 143 | if (dev->devfn == devfn) | 141 | if (dev->devfn == devfn) |
| 144 | goto out; | 142 | goto out; |
| 145 | } | 143 | } |
| @@ -245,30 +243,14 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, | |||
| 245 | unsigned int ss_vendor, unsigned int ss_device, | 243 | unsigned int ss_vendor, unsigned int ss_device, |
| 246 | struct pci_dev *from) | 244 | struct pci_dev *from) |
| 247 | { | 245 | { |
| 248 | struct pci_dev *pdev; | 246 | struct pci_device_id id = { |
| 249 | struct pci_device_id *id; | 247 | .vendor = vendor, |
| 250 | 248 | .device = device, | |
| 251 | /* | 249 | .subvendor = ss_vendor, |
| 252 | * pci_find_subsys() can be called on the ide_setup() path, | 250 | .subdevice = ss_device, |
| 253 | * super-early in boot. But the down_read() will enable local | 251 | }; |
| 254 | * interrupts, which can cause some machines to crash. So here we | 252 | |
| 255 | * detect and flag that situation and bail out early. | 253 | return pci_get_dev_by_id(&id, from); |
| 256 | */ | ||
| 257 | if (unlikely(no_pci_devices())) | ||
| 258 | return NULL; | ||
| 259 | |||
| 260 | id = kzalloc(sizeof(*id), GFP_KERNEL); | ||
| 261 | if (!id) | ||
| 262 | return NULL; | ||
| 263 | id->vendor = vendor; | ||
| 264 | id->device = device; | ||
| 265 | id->subvendor = ss_vendor; | ||
| 266 | id->subdevice = ss_device; | ||
| 267 | |||
| 268 | pdev = pci_get_dev_by_id(id, from); | ||
| 269 | kfree(id); | ||
| 270 | |||
| 271 | return pdev; | ||
| 272 | } | 254 | } |
| 273 | 255 | ||
| 274 | /** | 256 | /** |
| @@ -307,19 +289,16 @@ pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from) | |||
| 307 | */ | 289 | */ |
| 308 | struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) | 290 | struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) |
| 309 | { | 291 | { |
| 310 | struct pci_dev *dev; | 292 | struct pci_device_id id = { |
| 311 | struct pci_device_id *id; | 293 | .vendor = PCI_ANY_ID, |
| 312 | 294 | .device = PCI_ANY_ID, | |
| 313 | id = kzalloc(sizeof(*id), GFP_KERNEL); | 295 | .subvendor = PCI_ANY_ID, |
| 314 | if (!id) | 296 | .subdevice = PCI_ANY_ID, |
| 315 | return NULL; | 297 | .class_mask = PCI_ANY_ID, |
| 316 | id->vendor = id->device = id->subvendor = id->subdevice = PCI_ANY_ID; | 298 | .class = class, |
| 317 | id->class_mask = PCI_ANY_ID; | 299 | }; |
| 318 | id->class = class; | 300 | |
| 319 | 301 | return pci_get_dev_by_id(&id, from); | |
| 320 | dev = pci_get_dev_by_id(id, from); | ||
| 321 | kfree(id); | ||
| 322 | return dev; | ||
| 323 | } | 302 | } |
| 324 | 303 | ||
| 325 | /** | 304 | /** |
