mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] of: move of_get_node_by_reproducible_name() into common code
@ 2022-08-15 16:07 Ahmad Fatoum
  2022-08-16  8:53 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-08-15 16:07 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




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

* Re: [PATCH] of: move of_get_node_by_reproducible_name() into common code
  2022-08-15 16:07 [PATCH] of: move of_get_node_by_reproducible_name() into common code Ahmad Fatoum
@ 2022-08-16  8:53 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-08-16  8:53 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Aug 15, 2022 at 06:07:08PM +0200, Ahmad Fatoum wrote:
> 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(-)

Applied, thanks
  Sascha

> 
> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2022-08-16  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 16:07 [PATCH] of: move of_get_node_by_reproducible_name() into common code Ahmad Fatoum
2022-08-16  8:53 ` Sascha Hauer

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