blob: ef26216f54edce073a89108eea7a0675d1d9565a [file] [log] [blame]
Daniel Lezcano7c15fad2016-02-18 15:57:43 +00001/*
2 * Power debug tool (powerdebug)
Daniel Lezcanoc193b602011-06-08 23:30:00 +02003 *
Daniel Lezcano7c15fad2016-02-18 15:57:43 +00004 * Copyright (C) 2016, Linaro Limited.
Daniel Lezcanoc193b602011-06-08 23:30:00 +02005 *
Daniel Lezcano7c15fad2016-02-18 15:57:43 +00006 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
Daniel Lezcanoc193b602011-06-08 23:30:00 +020010 *
Daniel Lezcano7c15fad2016-02-18 15:57:43 +000011 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Daniel Lezcanoc193b602011-06-08 23:30:00 +020015 *
Daniel Lezcano7c15fad2016-02-18 15:57:43 +000016 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 */
Daniel Lezcanoc193b602011-06-08 23:30:00 +020021
22/*
23 * Structure describing a node of the clock tree
24 *
25 * tail : points to the last element in the list
26 * next : points to the next element in the list
27 * child : points to the child node
28 * parent : points to the parent node
29 * depth : the recursive level of the node
30 * path : absolute pathname of the directory
31 * name : basename of the directory
32 */
33struct tree {
34 struct tree *tail;
35 struct tree *next;
36 struct tree *prev;
37 struct tree *child;
38 struct tree *parent;
39 char *path;
40 char *name;
41 void *private;
Daniel Lezcanocb86e1d2011-06-08 23:30:01 +020042 int nrchild;
Daniel Lezcanoc193b602011-06-08 23:30:00 +020043 unsigned char depth;
44};
45
46typedef int (*tree_cb_t)(struct tree *t, void *data);
47
48typedef int (*tree_filter_t)(const char *name);
49
Daniel Lezcano25fc4a32011-08-25 15:46:13 +020050extern struct tree *tree_load(const char *path, tree_filter_t filter, bool follow);
Daniel Lezcanoc193b602011-06-08 23:30:00 +020051
Daniel Lezcano357dd8a2011-06-08 23:30:00 +020052extern struct tree *tree_find(struct tree *tree, const char *name);
53
Daniel Lezcanoc193b602011-06-08 23:30:00 +020054extern int tree_for_each(struct tree *tree, tree_cb_t cb, void *data);
Daniel Lezcanoafe62252011-06-08 23:30:00 +020055
Daniel Lezcano6d42e812011-06-08 23:30:01 +020056extern int tree_for_each_reverse(struct tree *tree, tree_cb_t cb, void *data);
57
Daniel Lezcanoafe62252011-06-08 23:30:00 +020058extern int tree_for_each_parent(struct tree *tree, tree_cb_t cb, void *data);
Daniel Lezcanofabe20a2011-06-08 23:30:01 +020059
60extern int tree_finds(struct tree *tree, const char *name, struct tree ***ptr);