summaryrefslogtreecommitdiffstats
path: root/cpukit/libpci/pci_get_dev.c
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2011-11-28 10:11:10 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2015-04-17 01:10:15 +0200
commita31845f7f9b4770cf9ddd8b6820641d2f4f4c1da (patch)
tree0d7f215ec45d7c4cf6f1293af72ece2fbde1ddc3 /cpukit/libpci/pci_get_dev.c
parentleon3,ngmp: simplify cpucounter initialization (diff)
downloadrtems-a31845f7f9b4770cf9ddd8b6820641d2f4f4c1da.tar.bz2
LIBPCI: added PCI layer to cpukit/libpci
Diffstat (limited to 'cpukit/libpci/pci_get_dev.c')
-rw-r--r--cpukit/libpci/pci_get_dev.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/cpukit/libpci/pci_get_dev.c b/cpukit/libpci/pci_get_dev.c
new file mode 100644
index 0000000000..5e07653e6c
--- /dev/null
+++ b/cpukit/libpci/pci_get_dev.c
@@ -0,0 +1,36 @@
+/* PCI Help function, Find a PCI device by BUS|SLOT|FUNCTION
+ *
+ * COPYRIGHT (c) 2010.
+ * Cobham Gaisler AB.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <pci.h>
+#include <pci/cfg.h>
+
+static int compare_dev_pcidev(struct pci_dev *dev, void *arg)
+{
+ pci_dev_t pcidev = (unsigned)arg;
+
+ if (dev->busdevfun == pcidev)
+ return (int)dev;
+ else
+ return 0;
+}
+
+/* Get a Device in PCI device tree located in RAM by PCI BUS|SLOT|FUNCTION */
+int pci_get_dev(pci_dev_t pcidev, struct pci_dev **ppdev)
+{
+ int result;
+
+ result = pci_for_each_dev(compare_dev_pcidev, (void *)(unsigned)pcidev);
+ if (ppdev)
+ *ppdev = (struct pci_dev *)result;
+ if (result == 0)
+ return -1;
+ else
+ return 0;
+}