5
Line | |
---|
1 | /* |
---|
2 | * AMBA Plug & Play routines |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 2011 |
---|
5 | * Aeroflex Gaisler |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.org/license/LICENSE. |
---|
10 | */ |
---|
11 | |
---|
12 | #include <grlib/ambapp.h> |
---|
13 | |
---|
14 | /* AMBAPP helper routine to find a device by index. The function is given to |
---|
15 | * ambapp_for_each, the argument may be NULL (find first device) or a pointer |
---|
16 | * to a index which is downcounted until 0 is reached. If the int-pointer |
---|
17 | * points to a value of: |
---|
18 | * 0 - first device is returned |
---|
19 | * 1 - second device is returned |
---|
20 | * ... |
---|
21 | * |
---|
22 | * The matching device is returned, which will stop the ambapp_for_each search. |
---|
23 | * If zero is returned from ambapp_for_each no device matching the index was |
---|
24 | * found |
---|
25 | */ |
---|
26 | int ambapp_find_by_idx(struct ambapp_dev *dev, int index, void *pcount) |
---|
27 | { |
---|
28 | int *pi = pcount; |
---|
29 | |
---|
30 | if (pi) { |
---|
31 | if ((*pi)-- == 0) |
---|
32 | return (int)dev; |
---|
33 | else |
---|
34 | return 0; |
---|
35 | } else { |
---|
36 | /* Satisfied with first matching device, stop search */ |
---|
37 | return (int)dev; |
---|
38 | } |
---|
39 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.