5
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 | |
---|
13 | static 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 */ |
---|
24 | int 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.