summaryrefslogtreecommitdiffstats
path: root/bsps/shared/grlib/amba/ambapp_depth.c
blob: 2fe0b142e9a129e452ee6a3b949fe9b04eaf6efe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 *  AMBA Plug & Play routines
 *
 *  COPYRIGHT (c) 2011
 *  Aeroflex Gaisler
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#include <grlib/ambapp.h>

/* Get bus depth a device is located at */
int ambapp_depth(struct ambapp_dev *dev)
{
  int depth = 0;

  do {
    dev = ambapp_find_parent(dev);
    depth++;
  } while (dev);

  return depth - 1;
}