[RFC PATCH 05/12] of: kobj: __of_attach_node_sysfs(): add optional basename parameter
From: "Enrico Weigelt, metux IT consult" <info@metux.net>
Date: 2021-02-08 22:29:41
Also in:
linux-gpio, lkml
Subsystem:
open firmware and flattened device tree, the rest · Maintainers:
Rob Herring, Saravana Kannan, Linus Torvalds
Introduce additional parameter for specifying the name of the base directory underneath /sys/firmware/devicetree. This is for scenarios where we want entirely separate oftree instances. Passing NULL falls back to the existing base name 'base'. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> --- drivers/of/base.c | 2 +- drivers/of/dynamic.c | 4 ++-- drivers/of/kobj.c | 7 +++++-- drivers/of/of_private.h | 6 +++--- drivers/of/unittest.c | 6 +++--- 5 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 649c2a32bb48..be63493bd232 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c@@ -177,7 +177,7 @@ void __init of_core_init(void) return; } for_each_of_allnodes(np) { - __of_attach_node_sysfs(np); + __of_attach_node_sysfs(np, NULL); if (np->phandle && !phandle_cache[of_phandle_cache_hash(np->phandle)]) phandle_cache[of_phandle_cache_hash(np->phandle)] = np; }
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 9a824decf61f..63768f0dc60e 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c@@ -243,7 +243,7 @@ int of_attach_node(struct device_node *np) __of_attach_node(np); raw_spin_unlock_irqrestore(&devtree_lock, flags); - __of_attach_node_sysfs(np); + __of_attach_node_sysfs(np, NULL); mutex_unlock(&of_mutex); of_reconfig_notify(OF_RECONFIG_ATTACH_NODE, &rd);
@@ -635,7 +635,7 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce) switch (ce->action) { case OF_RECONFIG_ATTACH_NODE: - __of_attach_node_sysfs(ce->np); + __of_attach_node_sysfs(ce->np, NULL); break; case OF_RECONFIG_DETACH_NODE: __of_detach_node_sysfs(ce->np);
diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c
index a32e60b024b8..511d7e8b9068 100644
--- a/drivers/of/kobj.c
+++ b/drivers/of/kobj.c@@ -112,20 +112,23 @@ void __of_update_property_sysfs(struct device_node *np, struct property *newprop __of_add_property_sysfs(np, newprop); } -int __of_attach_node_sysfs(struct device_node *np) +int __of_attach_node_sysfs(struct device_node *np, const char *basename) { const char *name; struct kobject *parent; struct property *pp; int rc; + if (!basename) + basename = "base"; + if (!of_kset) return 0; np->kobj.kset = of_kset; if (!np->parent) { /* Nodes without parents are new top level trees */ - name = safe_name(&of_kset->kobj, "base"); + name = safe_name(&of_kset->kobj, basename); parent = NULL; } else { name = safe_name(&np->parent->kobj, kbasename(np->full_name));
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index d9e6a324de0a..371f4da77161 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h@@ -63,7 +63,7 @@ int __of_add_property_sysfs(struct device_node *np, struct property *pp); void __of_remove_property_sysfs(struct device_node *np, struct property *prop); void __of_update_property_sysfs(struct device_node *np, struct property *newprop, struct property *oldprop); -int __of_attach_node_sysfs(struct device_node *np); +int __of_attach_node_sysfs(struct device_node *np, const char *basename); void __of_detach_node_sysfs(struct device_node *np); #else static inline int __of_add_property_sysfs(struct device_node *np, struct property *pp)
@@ -73,7 +73,7 @@ static inline int __of_add_property_sysfs(struct device_node *np, struct propert static inline void __of_remove_property_sysfs(struct device_node *np, struct property *prop) {} static inline void __of_update_property_sysfs(struct device_node *np, struct property *newprop, struct property *oldprop) {} -static inline int __of_attach_node_sysfs(struct device_node *np) +static inline int __of_attach_node_sysfs(struct device_node *np, const char *basename) { return 0; }
@@ -135,7 +135,7 @@ extern int __of_update_property(struct device_node *np, extern void __of_update_property_sysfs(struct device_node *np, struct property *newprop, struct property *oldprop); -extern int __of_attach_node_sysfs(struct device_node *np); +extern int __of_attach_node_sysfs(struct device_node *np, const char *basename); extern void __of_detach_node(struct device_node *np); extern void __of_detach_node_sysfs(struct device_node *np);
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index eb51bc147440..caf4ade8b141 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c@@ -1391,7 +1391,7 @@ static void attach_node_and_children(struct device_node *np) of_node_clear_flag(np, OF_DETACHED); raw_spin_unlock_irqrestore(&devtree_lock, flags); - __of_attach_node_sysfs(np); + __of_attach_node_sysfs(np, NULL); mutex_unlock(&of_mutex); while (child) {
@@ -1451,7 +1451,7 @@ static int __init unittest_data_add(void) if (!of_root) { of_root = unittest_data_node; for_each_of_allnodes(np) - __of_attach_node_sysfs(np); + __of_attach_node_sysfs(np, NULL); of_aliases = of_find_node_by_path("/aliases"); of_chosen = of_find_node_by_path("/chosen"); of_overlay_mutex_unlock();
@@ -3115,7 +3115,7 @@ static __init void of_unittest_overlay_high_level(void) of_root->child = overlay_base_root->child; for_each_of_allnodes_from(overlay_base_root, np) - __of_attach_node_sysfs(np); + __of_attach_node_sysfs(np, NULL); if (of_symbols) { struct property *new_prop;
--
2.11.0