@@ -224,6 +224,20 @@ int tree_for_each(struct tree *tree, tree_cb_t cb, void *data)
return tree_for_each(tree->next, cb, data);
}
+int tree_for_each_reverse(struct tree *tree, tree_cb_t cb, void *data)
+{
+ if (!tree)
+ return 0;
+
+ if (cb(tree, data))
+ return -1;
+
+ if (tree_for_each_reverse(tree->prev, cb, data))
+ return -1;
+
+ return tree_for_each_reverse(tree->parent, cb, data);
+}
+
int tree_for_each_parent(struct tree *tree, tree_cb_t cb, void *data)
{
if (!tree)
@@ -46,4 +46,6 @@ extern struct tree *tree_find(struct tree *tree, const char *name);
extern int tree_for_each(struct tree *tree, tree_cb_t cb, void *data);
+extern int tree_for_each_reverse(struct tree *tree, tree_cb_t cb, void *data);
+
extern int tree_for_each_parent(struct tree *tree, tree_cb_t cb, void *data);
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> --- tree.c | 14 ++++++++++++++ tree.h | 2 ++ 2 files changed, 16 insertions(+), 0 deletions(-)