mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] of: move of_get_node_by_reproducible_name() into common code
Date: Mon, 15 Aug 2022 18:07:08 +0200	[thread overview]
Message-ID: <20220815160708.2430433-1-a.fatoum@pengutronix.de> (raw)

The function already has a good generic name and can be useful for board
code or for other drivers seeking to fix up the kernel device tree
according to information within the barebox DT.
Thus move it to a central location.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/base.c                 | 13 +++++++++++++
 drivers/power/reset/reboot-mode.c | 13 -------------
 include/of.h                      |  9 +++++++++
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index b91ee92e1b88..52e6a9294e11 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2865,6 +2865,19 @@ struct device_node *of_find_node_by_reproducible_name(struct device_node *from,
 	return NULL;
 }
 
+struct device_node *of_get_node_by_reproducible_name(struct device_node *dstroot,
+						     struct device_node *srcnp)
+{
+	struct device_node *dstnp;
+	char *name;
+
+	name = of_get_reproducible_name(srcnp);
+	dstnp = of_find_node_by_reproducible_name(dstroot, name);
+	free(name);
+
+	return dstnp;
+}
+
 /**
  * of_graph_parse_endpoint() - parse common endpoint node properties
  * @node: pointer to endpoint device_node
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index 1316af4213fb..5761128f8e5a 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -48,19 +48,6 @@ static int reboot_mode_add_param(struct device_d *dev,
 	return PTR_ERR_OR_ZERO(param);
 }
 
-static struct device_node *of_get_node_by_reproducible_name(struct device_node *dstroot,
-							    struct device_node *srcnp)
-{
-	struct device_node *dstnp;
-	char *name;
-
-	name = of_get_reproducible_name(srcnp);
-	dstnp = of_find_node_by_reproducible_name(dstroot, name);
-	free(name);
-
-	return dstnp;
-}
-
 static int of_reboot_mode_fixup(struct device_node *root, void *ctx)
 {
 	struct reboot_mode_driver *reboot = ctx;
diff --git a/include/of.h b/include/of.h
index 91c3766992aa..995e9b591399 100644
--- a/include/of.h
+++ b/include/of.h
@@ -195,6 +195,9 @@ extern struct device_node *of_get_compatible_child(const struct device_node *par
 extern struct device_node *of_get_child_by_name(const struct device_node *node,
 					const char *name);
 extern char *of_get_reproducible_name(struct device_node *node);
+extern struct device_node *of_get_node_by_reproducible_name(struct device_node *dstroot,
+							    struct device_node *srcnp);
+
 extern struct device_node *of_find_node_by_reproducible_name(struct device_node
 							     *from,
 							     const char *name);
@@ -493,6 +496,12 @@ of_find_node_by_reproducible_name(struct device_node *from, const char *name)
 	return NULL;
 }
 
+
+static iline struct device_node *of_get_node_by_reproducible_name(struct device_node *dstroot,
+								  struct device_node *srcnp)
+{
+	return NULL;
+}
 static inline struct property *of_find_property(const struct device_node *np,
 						const char *name,
 						int *lenp)
-- 
2.30.2




             reply	other threads:[~2022-08-15 16:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 16:07 Ahmad Fatoum [this message]
2022-08-16  8:53 ` Sascha Hauer

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=20220815160708.2430433-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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