Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Power debug tool (powerdebug) |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 3 | * |
Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 4 | * Copyright (C) 2016, Linaro Limited. |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 5 | * |
Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 6 | * 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 Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 10 | * |
Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 11 | * 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 Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 15 | * |
Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 16 | * 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 Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 21 | |
| 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 | */ |
| 33 | struct 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 Lezcano | cb86e1d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 42 | int nrchild; |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 43 | unsigned char depth; |
| 44 | }; |
| 45 | |
| 46 | typedef int (*tree_cb_t)(struct tree *t, void *data); |
| 47 | |
| 48 | typedef int (*tree_filter_t)(const char *name); |
| 49 | |
Daniel Lezcano | 25fc4a3 | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 50 | extern struct tree *tree_load(const char *path, tree_filter_t filter, bool follow); |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 51 | |
Daniel Lezcano | 357dd8a | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 52 | extern struct tree *tree_find(struct tree *tree, const char *name); |
| 53 | |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 54 | extern int tree_for_each(struct tree *tree, tree_cb_t cb, void *data); |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 55 | |
Daniel Lezcano | 6d42e81 | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 56 | extern int tree_for_each_reverse(struct tree *tree, tree_cb_t cb, void *data); |
| 57 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 58 | extern int tree_for_each_parent(struct tree *tree, tree_cb_t cb, void *data); |
Daniel Lezcano | fabe20a | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 59 | |
| 60 | extern int tree_finds(struct tree *tree, const char *name, struct tree ***ptr); |