@@ -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);
@@ -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 */
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@metux.net> --- drivers/of/kobj.c | 17 +++++++++++++++++ include/linux/of.h | 7 +++++++ 2 files changed, 24 insertions(+)