source: rtems/c/src/lib/libbsp/sparc/shared/amba/ambapp_find_by_idx.c @ 62c5c4a5

4.115
Last change on this file since 62c5c4a5 was 62c5c4a5, checked in by Sebastian Huber <sebastian.huber@…>, on 02/11/14 at 09:08:21

bsps/sparc: Fix ambapp_find_by_idx()

The expression "*pi++" post-increments the pointer (not the value).

  • Property mode set to 100644
File size: 1.0 KB
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.com/license/LICENSE.
10 */
11
12#include <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 */
26int 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.