mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] of: base: add helper to rename a node
@ 2019-02-11 16:20 Marco Felsch
  2019-02-11 16:20 ` [PATCH 2/2] memory: of_fixup: adapt to new memory layout Marco Felsch
  2019-02-12  7:32 ` [PATCH 1/2] of: base: add helper to rename a node Sascha Hauer
  0 siblings, 2 replies; 8+ messages in thread
From: Marco Felsch @ 2019-02-11 16:20 UTC (permalink / raw)
  To: barebox; +Cc: mfe

Sometimes it can be necessary to rename a node, e.g. to override/create
a node which gets renamed upstream.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/of/base.c | 18 ++++++++++++++++++
 include/of.h      |  5 +++++
 2 files changed, 23 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index b082f0c656..6644d9b96a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2094,6 +2094,24 @@ void of_delete_node(struct device_node *node)
 		of_set_root_node(NULL);
 }
 
+void of_rename_node(struct device_node *node, char *name)
+{
+	struct device_node *parent;
+
+	if (!node)
+		return;
+
+	parent = node->parent;
+	if (parent) {
+		node->name = name;
+		node->full_name = basprintf("%s/%s", parent->full_name, name);
+	} else {
+		/* root node */
+		node->name = xstrdup("");
+		node->full_name = xstrdup("");
+	}
+}
+
 int of_device_is_stdout_path(struct device_d *dev)
 {
 	struct device_node *dn;
diff --git a/include/of.h b/include/of.h
index 184acb4741..403f399d95 100644
--- a/include/of.h
+++ b/include/of.h
@@ -158,6 +158,7 @@ extern struct device_node *of_create_node(struct device_node *root,
 extern struct device_node *of_copy_node(struct device_node *parent,
 				const struct device_node *other);
 extern void of_delete_node(struct device_node *node);
+extern void of_rename_node(struct device_node *node, char *name);
 
 extern const char *of_get_machine_compatible(void);
 extern int of_machine_is_compatible(const char *compat);
@@ -605,6 +606,10 @@ static inline void of_delete_node(struct device_node *node)
 {
 }
 
+static inline void of_rename_node(struct device_node *node, char *name)
+{
+}
+
 static inline int of_machine_is_compatible(const char *compat)
 {
 	return 0;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-02-12  9:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-11 16:20 [PATCH 1/2] of: base: add helper to rename a node Marco Felsch
2019-02-11 16:20 ` [PATCH 2/2] memory: of_fixup: adapt to new memory layout Marco Felsch
2019-02-12  8:03   ` Sascha Hauer
2019-02-12  8:45     ` Marco Felsch
2019-02-12  8:56       ` Sascha Hauer
2019-02-12  9:01         ` Marco Felsch
2019-02-12  7:32 ` [PATCH 1/2] of: base: add helper to rename a node Sascha Hauer
2019-02-12  8:49   ` Marco Felsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox