source: rtems/cpukit/libpci/pci_get_dev.c @ 89ac281

5
Last change on this file since 89ac281 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: 810 bytes
Line 
1/*  PCI Help function, Find a PCI device by BUS|SLOT|FUNCTION
2 *
3 *  COPYRIGHT (c) 2010 Cobham Gaisler AB.
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#include <pci.h>
11#include <pci/cfg.h>
12
13static int compare_dev_pcidev(struct pci_dev *dev, void *arg)
14{
15        pci_dev_t pcidev = (unsigned)arg;
16
17        if (dev->busdevfun == pcidev)
18                return (int)dev;
19        else
20                return 0;
21}
22
23/* Get a Device in PCI device tree located in RAM by PCI BUS|SLOT|FUNCTION */
24int pci_get_dev(pci_dev_t pcidev, struct pci_dev **ppdev)
25{
26        int result;
27
28        result = pci_for_each_dev(compare_dev_pcidev, (void *)(unsigned)pcidev);
29        if (ppdev)
30                *ppdev = (struct pci_dev *)result;
31        if (result == 0)
32                return -1;
33        else
34                return 0;
35}
Note: See TracBrowser for help on using the repository browser.