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