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

4.115
Last change on this file since e53daed was e53daed, checked in by Daniel Hellstrom <daniel@…>, on 04/09/15 at 14:09:42

LIBPCI: updated license to rtems.org

  • Property mode set to 100644
File size: 962 bytes
RevLine 
[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 */
17int 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.