4.115
Last change
on this file since e189f241 was
71e8a5c,
checked in by Daniel Hellstrom <daniel@…>, on 02/27/15 at 15:45:59
|
LIBPCI: moved copyright into a single line
|
-
Property mode set to
100644
|
File size:
1017 bytes
|
Line | |
---|
1 | /* PCI Help function, Find a PCI device by VENDOR/DEVICE ID |
---|
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.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #include <pci.h> |
---|
11 | #include <pci/cfg.h> |
---|
12 | |
---|
13 | struct compare_info { |
---|
14 | int index; |
---|
15 | uint16_t vendor; |
---|
16 | uint16_t device; |
---|
17 | }; |
---|
18 | |
---|
19 | static int compare_dev_id(struct pci_dev *dev, void *arg) |
---|
20 | { |
---|
21 | struct compare_info *info = arg; |
---|
22 | |
---|
23 | if ((dev->vendor != info->vendor) || (dev->device != info->device)) |
---|
24 | return 0; |
---|
25 | if (info->index-- == 0) |
---|
26 | return (int)dev; |
---|
27 | else |
---|
28 | return 0; |
---|
29 | } |
---|
30 | |
---|
31 | /* Find a Device in PCI device tree located in RAM */ |
---|
32 | int pci_find_dev(uint16_t ven, uint16_t dev, int index, struct pci_dev **ppdev) |
---|
33 | { |
---|
34 | struct compare_info info; |
---|
35 | int result; |
---|
36 | |
---|
37 | info.index = index; |
---|
38 | info.vendor = ven; |
---|
39 | info.device = dev; |
---|
40 | |
---|
41 | result = pci_for_each_dev(compare_dev_id, &info); |
---|
42 | if (ppdev) |
---|
43 | *ppdev = (struct pci_dev *)result; |
---|
44 | if (result == 0) |
---|
45 | return -1; |
---|
46 | else |
---|
47 | return 0; |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.