mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] dt:overlay: fix operation with multiple overlays
Date: Fri, 12 Feb 2021 11:16:13 +0100	[thread overview]
Message-ID: <20210212101613.GL19583@pengutronix.de> (raw)
In-Reply-To: <20210210142704.1855761-1-enrico.scholz@sigma-chemnitz.de>


Hi Enrico,

On Wed, Feb 10, 2021 at 03:27:02PM +0100, Enrico Scholz wrote:
> When applying multiple devicetree overlays the 'phandle' attribute
> must be updated too.  Else, every overlay will be adjusted to start
> with the same base which causes duplicate phandles.
> 
> Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
> ---
>  drivers/of/base.c    | 1 +
>  drivers/of/overlay.c | 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index edb0a8e71a0f..c88803d8ab4b 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -2385,6 +2385,7 @@ struct device_node *of_copy_node(struct device_node *parent, const struct device
>  	struct property *pp;
>  
>  	np = of_new_node(parent, other->name);
> +	np->phandle = other->phandle;

I can see why we have to do this for overlays. Without this all phandle
values from the overlay are lost.
I think however, that just copying the phandle values is wrong at least
in some cases of_copy_node() is used. When of_copy_node() is called with
a non NULL parent argument it duplicates the tree given in 'other' and
puts it below 'parent'. In that case we can't just copy the phandle
values as we would risk having duplicate phandle values in the parent
tree.

Maybe we can split of_copy_node() into two functions. One

struct device_node *of_duplicate(struct device_node *np);

this function can copy the phandle values without risk. The other
function

int of_attach(struct device_node *np, struct device_node *to);

would just make np a child node of 'to' and makes sure that phandle
values do not overlap.

Sascha

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

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

      parent reply	other threads:[~2021-02-12 10:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 14:27 Enrico Scholz
2021-02-10 14:27 ` [PATCH] imx8:pinfunc: fix definition Enrico Scholz
2021-02-12 10:17   ` Sascha Hauer
2021-02-10 14:27 ` [PATCH] nvmem: avoid false positive in of_nvmem_find() and simplify it Enrico Scholz
2021-02-12 10:16 ` Sascha Hauer [this message]

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=20210212101613.GL19583@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=enrico.scholz@sigma-chemnitz.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