devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH v2 2/2] livetree: Add only new data to fixup nodes instead of complete regeneration
Date: Mon, 18 Aug 2025 13:06:29 +1000	[thread overview]
Message-ID: <aKKYtbra546AQLlz@zatzit> (raw)
In-Reply-To: <2jywkljpilxb654diunhguk7apu5st2cotkgjjvyn25cpq6slx@e5ufgjcipzez>

[-- Attachment #1: Type: text/plain, Size: 3253 bytes --]

On Sun, Aug 17, 2025 at 12:40:59PM +0200, Uwe Kleine-König wrote:
> On Sat, Aug 16, 2025 at 02:54:27PM +1000, David Gibson wrote:
> > On Fri, Aug 15, 2025 at 03:34:54PM +0200, Uwe Kleine-König wrote:
> > > Removing the complete __fixups__ and __local_fixups__ tree might delete
> > > data that should better be retained. See the added test for a situation
> > > that was broken before.
> > > 
> > > Note that without removing /__fixups__ and /__local_fixups__ in
> > > generate_fixups_tree() and generate_local_fixups_tree() respectively
> > > calling build_and_name_child_node() isn't safe as the nodes might
> > > already exist and then a duplicate would be added. So build_root_node()
> > > has to be used which copes correctly here.
> > > 
> > > Fixes: 915daadbb62d ("Start with empty __local_fixups__ and __fixups__ nodes")
> > > Closes: https://github.com/dgibson/dtc/issues/170
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> > > ---
> > >  livetree.c              | 75 +++++++++++++++++++++++++++++++----------
> > >  tests/retain-fixups.dts | 29 ++++++++++++++++
> > >  tests/run_tests.sh      |  5 +++
> > >  3 files changed, 92 insertions(+), 17 deletions(-)
> > >  create mode 100644 tests/retain-fixups.dts
> > > 
> > > diff --git a/livetree.c b/livetree.c
> > > index 6127d604d528..f23988483b01 100644
> > > --- a/livetree.c
> > > +++ b/livetree.c
> > > @@ -352,6 +352,60 @@ void append_to_property(struct node *node,
> > >  	p->val = data_append_data(p->val, data, len);
> > >  }
> > >  
> > > +static void append_unique_str_to_property(struct node *node,
> > > +					  char *name, const char *data, int len)
> > > +{
> > > +	struct property *p;
> > > +
> > > +	p = get_property(node, name);
> > > +	if (p) {
> > > +		if (p->val.val[p->val.len - 1] == '\0') {
> > > +			const char *s;
> > > +
> > > +			for (s = p->val.val; s < p->val.val + p->val.len; s = strchr(s, '\0') + 1) {
> > > +				if (strcmp(data, s) == 0)
> > > +					/* data already contained in node.name */
> > > +					return;
> > > +			}
> > > +		} else {
> > > +			fprintf(stderr, "Warning: appending string to non-string property %s/%s\n",
> > > +				node->fullpath, name);
> > 
> > I don't think carrying on with the operation when the original
> > property is malformed is a good idea.  This message will also be
> > pretty confusing in the one place it will occur.  I think it would be
> > preferable to return an error code here.  The caller, which knows what
> > the purpose is can then report that the relevant property is malformed
> > - if that's the case, I think we can just give up on updating
> > __fixups__ / __local_fixups__.
> 
> I picked that option to somewhat keep the behaviour of dtc as it was
> before (which appended irrespective of the pre-existing content).

The rationale make sense, but I think just giving an error is a more
useful behaviour over all.

> But I don't feel strong and can rework it accordingly to your comments.
> 
> Best regards
> Uwe



-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2025-08-18  3:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-15 13:34 [PATCH v2 0/2] livetree: Add only new data to fixup nodes instead of complete regeneration Uwe Kleine-König
2025-08-15 13:34 ` [PATCH v2 1/2] livetree: Simplify append_to_property() Uwe Kleine-König
2025-08-16  4:46   ` David Gibson
2025-08-15 13:34 ` [PATCH v2 2/2] livetree: Add only new data to fixup nodes instead of complete regeneration Uwe Kleine-König
2025-08-16  4:54   ` David Gibson
2025-08-17 10:40     ` Uwe Kleine-König
2025-08-18  3:06       ` David Gibson [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=aKKYtbra546AQLlz@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    /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;
as well as URLs for NNTP newsgroup(s).