mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: barebox@lists.infradead.org, mfe@pengutronix.de
Subject: Re: [PATCH 1/2] of: base: add helper to rename a node
Date: Tue, 12 Feb 2019 08:32:46 +0100	[thread overview]
Message-ID: <20190212073246.faodocc6e6nigbsi@pengutronix.de> (raw)
In-Reply-To: <20190211162013.5320-1-m.felsch@pengutronix.de>

Hi Marco,

On Mon, Feb 11, 2019 at 05:20:12PM +0100, Marco Felsch wrote:
> 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)

Should be const char * name.

> +{
> +	struct device_node *parent;
> +
> +	if (!node)
> +		return;
> +
> +	parent = node->parent;
> +	if (parent) {
> +		node->name = name;

node->name is an allocated string. It should be freed and then set to an
allocated string again.

> +		node->full_name = basprintf("%s/%s", parent->full_name, name);
> +	} else {
> +		/* root node */
> +		node->name = xstrdup("");
> +		node->full_name = xstrdup("");

I think we can drop the else path entirely. If we do not allow to give
the root node a name then we can assume that it doesn't have a name
right now, so nothing to do here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

  parent reply	other threads:[~2019-02-12  7:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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  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 ` Sascha Hauer [this message]
2019-02-12  8:49   ` [PATCH 1/2] of: base: add helper to rename a node Marco Felsch

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=20190212073246.faodocc6e6nigbsi@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    --cc=mfe@pengutronix.de \
    /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