devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Enrico Weigelt, metux IT consult" <info@metux.net>
To: linux-kernel@vger.kernel.org
Cc: rafael@kernel.org, info@metux.net, linus.walleij@linaro.org,
	bgolaszewski@baylibre.com, robh+dt@kernel.org,
	frowand.list@gmail.com, pantelis.antoniou@konsulko.com,
	linux-gpio@vger.kernel.org, devicetree@vger.kernel.org
Subject: [RFC PATCH 05/12] of: kobj: __of_attach_node_sysfs(): add optional basename parameter
Date: Mon,  8 Feb 2021 23:21:56 +0100	[thread overview]
Message-ID: <20210208222203.22335-6-info@metux.net> (raw)
In-Reply-To: <20210208222203.22335-1-info@metux.net>

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


  parent reply	other threads:[~2021-02-08 22:25 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 22:21 RFC: oftree based setup of composite board devices Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 01/12] of: base: improve error message in of_phandle_iterator_next() Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 02/12] of: base: introduce of_find_node_by_phandle_from() Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 03/12] of: base: record root node in interator and use it for phandle lookup Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 04/12] of: base: introduce of_match_string() Enrico Weigelt, metux IT consult
2021-02-08 23:52   ` Rob Herring
2021-02-08 22:21 ` Enrico Weigelt, metux IT consult [this message]
2021-02-08 22:21 ` [RFC PATCH 06/12] of: kobj: introduce of_attach_tree_sysfs() Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 07/12] gpio: amd-fch: add oftree probing support Enrico Weigelt, metux IT consult
2021-02-11  9:57   ` Bartosz Golaszewski
2021-03-01 14:51   ` Linus Walleij
2021-03-11 10:17     ` Enrico Weigelt, metux IT consult
2021-03-11 10:42       ` Andy Shevchenko
2021-03-18  8:00         ` Enrico Weigelt, metux IT consult
2021-03-25  9:09           ` Linus Walleij
2021-02-08 22:21 ` [RFC PATCH 08/12] drivers: base: introduce bus_remove_device_by_name() Enrico Weigelt, metux IT consult
2021-02-08 22:22 ` [RFC PATCH 09/12] drivers: base: reintroduce find_bus() Enrico Weigelt, metux IT consult
2021-02-13 10:20   ` Greg KH
2021-02-23 20:13     ` Enrico Weigelt, metux IT consult
2021-02-24  8:00       ` Greg KH
2021-02-24 15:30         ` Enrico Weigelt, metux IT consult
2021-02-24 16:28           ` Greg KH
2021-02-08 22:22 ` [RFC PATCH 10/12] export bus_get() / bus_put() Enrico Weigelt, metux IT consult
2021-02-08 22:22 ` [RFC PATCH 11/12] platform/x86: skeleton for oftree based board device initialization Enrico Weigelt, metux IT consult
2021-02-10 10:32   ` Andy Shevchenko
2021-02-12  9:58   ` Linus Walleij
2021-02-12 11:54     ` Enrico Weigelt, metux IT consult
2021-02-15  1:18       ` Frank Rowand
2021-02-23 20:41         ` Enrico Weigelt, metux IT consult
2021-03-02 13:33       ` Linus Walleij
2021-02-08 22:22 ` [RFC PATCH 12/12] platform/x86/of: add support for PC Engines APU v2/3/4 boards Enrico Weigelt, metux IT consult
2021-02-09  0:06   ` Rob Herring
2021-02-11 13:15     ` Enrico Weigelt, metux IT consult
2021-03-01 14:55   ` Linus Walleij
2021-02-08 23:48 ` RFC: oftree based setup of composite board devices Rob Herring
2021-02-10 22:13   ` Enrico Weigelt, metux IT consult
2021-02-15  1:12   ` Frank Rowand
2021-02-15 15:35     ` Andy Shevchenko
2021-02-24 13:00     ` Enrico Weigelt, metux IT consult
2021-02-24 23:14       ` Frank Rowand
2021-03-05 18:29         ` Rob Herring
2021-02-10 10:30 ` Andy Shevchenko
2021-02-11 11:08   ` Enrico Weigelt, metux IT consult
2021-02-11 11:41     ` Andy Shevchenko
2021-02-11 17:01       ` Enrico Weigelt, metux IT consult

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210208222203.22335-6-info@metux.net \
    --to=info@metux.net \
    --cc=bgolaszewski@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).