Introduce helper for attaching an (separate) oftree into sysfs. This is useful, when drivers use their own internal device trees, separate from the platform's global one, and wanna make it visible to userspace via sysfs. Signed-off-by: Enrico Weigelt, metux IT consult <info@xxxxxxxxx> --- drivers/of/kobj.c | 17 +++++++++++++++++ include/linux/of.h | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index 511d7e8b9068..96dc5a2753f4 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -166,3 +166,20 @@ void __of_detach_node_sysfs(struct device_node *np) of_node_put(np); } + +void of_attach_tree_sysfs(struct device_node *root, const char* base) +{ + struct device_node *np; + + if (!root) + return; + + /* need to from our parent, so we don't traverse above our root, + * if it's actually a subtree */ + root->parent = NULL; + + __of_attach_node_sysfs(root, base); + for_each_of_allnodes_from(root, np) + __of_attach_node_sysfs(np, base); +} +EXPORT_SYMBOL_GPL(of_attach_tree_sysfs); diff --git a/include/linux/of.h b/include/linux/of.h index 3612429632f4..c2fb12ce07f9 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -421,6 +421,8 @@ extern int of_update_property(struct device_node *np, struct property *newprop); extern int of_attach_node(struct device_node *); extern int of_detach_node(struct device_node *); +extern void of_attach_tree_sysfs(struct device_node *root, const char* base); + #define of_match_ptr(_ptr) (_ptr) /** @@ -1010,6 +1012,11 @@ static inline phys_addr_t of_dma_get_max_cpu_address(struct device_node *np) return PHYS_ADDR_MAX; } +static inline void of_attach_tree_sysfs(struct device_node *root, + const char* base) +{ +} + #define of_match_ptr(_ptr) NULL #define of_match_node(_matches, _node) NULL #endif /* CONFIG_OF */ -- 2.11.0