devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Andrew Davis <afd@ti.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Ayush Singh <ayush@beagleboard.org>,
	d-gole@ti.com, lorforlinux@beagleboard.org,
	jkridner@beagleboard.org, robertcnelson@beagleboard.org,
	nenad.marinkovic@mikroe.com,
	Robert Nelson <robertcnelson@gmail.com>,
	devicetree-compiler@vger.kernel.org,
	Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH v2 0/2] Add capability to append to property
Date: Thu, 12 Sep 2024 13:59:30 +1000	[thread overview]
Message-ID: <ZuJnIraA3lSBX0l8@zatzit.fritz.box> (raw)
In-Reply-To: <5a9dc053-d826-4168-a626-8d7f4ee72de1@ti.com>

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

On Fri, Aug 30, 2024 at 10:43:11AM -0500, Andrew Davis wrote:
> On 8/30/24 3:09 AM, Geert Uytterhoeven wrote:
> > Hi Ayush,
> > 
> > On Thu, Aug 29, 2024 at 10:04 PM Ayush Singh <ayush@beagleboard.org> wrote:
> > > Allow appending values to a property instead of overriding the previous
> > > values of property.

I can see how this would be useful for certain cases.  I don't love
implementing it just as a specific ad-hoc new keyword thuogh.  I did
long ago have a more comprehensive plan that would allow for this,
amongst other things.  Currently we allow integer expressions in dts
files, but I had been hoping to add string-valued and
bytestring-valued expressions as well.  That would allow appends as
something like:

	prop = /previous-value/, "extra stuff";

',' being the bytestring append operator.  It would also allow
prepend, and - with the addition of other bytestring operations -
various other manipulations.

However, the chances of me ever actually getting around to
implementing this are basically zero at this point.  I guess based on
that design we could allow appends with the syntax:
	prop ,= "additional data";

Which is, I think, theoretically more elegant, but also risks being
pretty unreadable.

> > Thanks for your series!
> > 
> > > Open items
> > 
> > > - Appending to non-existent property: Currently am just adding a new
> > >    property if not found. Not sure if this is the desired behaviour.
> > 
> > I think this should raise an error.
> > 
> 
> I was thinking this at first too, but if we want to be consistent we
> may want to instead go with adding the new property without error for
> the following reasons.
> 
> High level, nodes and properties should behave the similarly.

I'm not sure I buy that premise.  dtb is not like (say) json, where
"node" and "property" are just different types an entry could have.
Properties are structurally distinct from nodes (the subnodes and
properties and a node even occupy different namespaces).

The other important distinction is that dtc necessarily understands
the internal structure of nodes, but it doesn't necessarily know
anything about the internal structure of properties (beyond that
they're bytestrings).

> When
> we run into an already defined node we take the content and append
> to the existing node. But for properties we replace the content,
> not append. This is the fundamental asymmetry that causes us to
> need /append-property/ but not need /append-node/, nodes append
> by default.
> 
> When we want to replace a node we do /delete-node/ first, followed
> by the defining the new node content. If properties were default
> append, we would do the same with /delete-property/ followed by
> the new content. If we could do all this over that would have made
> the semantics much cleaner and only required /delete-node/ and
> /delete-property/, but little late for that now..
> 
> So when we label a property with /append-property/, we want it to
> have the same semantics as nodes. Which is to append if it exists,
> and to add new if not, without error.

Hrm.  I'm pretty dubious about this approach because a property being
absent is different from a property being present, but containing an
empty bytestring as value ("boolean" properties rely on this).
Appending in this matter erases that distinction in the base tree.

-- 
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:[~2024-09-12  3:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-29 20:03 [PATCH v2 0/2] Add capability to append to property Ayush Singh
2024-08-29 20:03 ` [PATCH v2 1/2] dtc: Add /append-property/ Ayush Singh
2024-08-29 20:03 ` [PATCH v2 2/2] tests: Add test for append-property Ayush Singh
2024-08-30  1:06   ` Simon Glass
2024-08-30  3:28     ` CVS
2024-08-30  8:07       ` Ayush Singh
2024-08-30  8:01     ` Ayush Singh
2024-09-12 11:06       ` CVS
2024-09-17 17:23         ` Ayush Singh
2024-08-30  8:09 ` [PATCH v2 0/2] Add capability to append to property Geert Uytterhoeven
2024-08-30 15:43   ` Andrew Davis
2024-09-12  3:59     ` David Gibson [this message]
2024-10-10  6:31       ` Ayush Singh

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=ZuJnIraA3lSBX0l8@zatzit.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=afd@ti.com \
    --cc=ayush@beagleboard.org \
    --cc=d-gole@ti.com \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=jkridner@beagleboard.org \
    --cc=lorforlinux@beagleboard.org \
    --cc=nenad.marinkovic@mikroe.com \
    --cc=robertcnelson@beagleboard.org \
    --cc=robertcnelson@gmail.com \
    --cc=sjg@chromium.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;
as well as URLs for NNTP newsgroup(s).