4.115
Rev | Line | |
---|
[a31845f7] | 1 | /* PCI Help function, iterate all PCI device children of PCI bus. |
---|
| 2 | * |
---|
[71e8a5c] | 3 | * COPYRIGHT (c) 2010 Cobham Gaisler AB. |
---|
[a31845f7] | 4 | * |
---|
| 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
[e53daed] | 7 | * http://www.rtems.org/license/LICENSE. |
---|
[a31845f7] | 8 | */ |
---|
| 9 | |
---|
| 10 | #include <pci/cfg.h> |
---|
| 11 | |
---|
| 12 | /* Iterate over all PCI devices on a bus (not child buses) and call func(), |
---|
| 13 | * iteration is stopped if a non-zero value is returned by func(). |
---|
| 14 | * |
---|
| 15 | * search options: 0 (no child buses), 1 (depth first), 2 (breadth first) |
---|
| 16 | */ |
---|
| 17 | int pci_for_each_child( |
---|
| 18 | struct pci_bus *bus, |
---|
| 19 | int (*func)(struct pci_dev *, void *arg), |
---|
| 20 | void *arg, |
---|
| 21 | int search) |
---|
| 22 | { |
---|
| 23 | struct pci_dev *dev = bus->devs; |
---|
| 24 | int ret; |
---|
| 25 | |
---|
| 26 | while (dev) { |
---|
| 27 | ret = func(dev, arg); |
---|
| 28 | if (ret) |
---|
| 29 | return ret; |
---|
| 30 | if (search == SEARCH_DEPTH && (dev->flags & PCI_DEV_BRIDGE)) { |
---|
| 31 | ret = pci_for_each_child((struct pci_bus *)dev, |
---|
| 32 | func, arg, search); |
---|
| 33 | if (ret) |
---|
| 34 | return ret; |
---|
| 35 | } |
---|
| 36 | dev = dev->next; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | return 0; |
---|
| 40 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.