source: rtems/cpukit/libpci/pci_get_dev.c

Last change on this file was e53daed, checked in by Daniel Hellstrom <daniel@…>, on Apr 9, 2015 at 2:09:42 PM

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.