source: rtems/cpukit/libpci/pci_for_each_child.c @ a31845f7

4.115
Last change on this file since a31845f7 was a31845f7, checked in by Daniel Hellstrom <daniel@…>, on 11/28/11 at 09:11:10

LIBPCI: added PCI layer to cpukit/libpci

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