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

4.11
Last change on this file since a31845f7 was a31845f7, checked in by Daniel Hellstrom <daniel@…>, on Nov 28, 2011 at 9:11:10 AM

LIBPCI: added PCI layer to cpukit/libpci

  • Property mode set to 100644
File size: 815 bytes
Line 
1/*  PCI Help function, Find a PCI device by BUS|SLOT|FUNCTION
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.h>
12#include <pci/cfg.h>
13
14static int compare_dev_pcidev(struct pci_dev *dev, void *arg)
15{
16        pci_dev_t pcidev = (unsigned)arg;
17
18        if (dev->busdevfun == pcidev)
19                return (int)dev;
20        else
21                return 0;
22}
23
24/* Get a Device in PCI device tree located in RAM by PCI BUS|SLOT|FUNCTION */
25int pci_get_dev(pci_dev_t pcidev, struct pci_dev **ppdev)
26{
27        int result;
28
29        result = pci_for_each_dev(compare_dev_pcidev, (void *)(unsigned)pcidev);
30        if (ppdev)
31                *ppdev = (struct pci_dev *)result;
32        if (result == 0)
33                return -1;
34        else
35                return 0;
36}
Note: See TracBrowser for help on using the repository browser.