lkml.org 
[lkml]   [2021]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 06/12] of: kobj: introduce of_attach_tree_sysfs()
Date
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(+)

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
\
 
 \ /
  Last update: 2021-02-08 23:28    [W:0.470 / U:0.612 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site