Re: [PATCH v3 0/2] Add capability to append to property

David Gibson <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler
Message-ID <Z24nldCpXpoT7RaK@zatzit>
On Thu, Dec 26, 2024 at 12:10:04PM +0100, Geert Uytterhoeven wrote:
> On Thu, Dec 26, 2024 at 7:54 AM David Gibson
> <[email protected]> wrote:
> > On Fri, Dec 20, 2024 at 09:00:14PM +0530, Ayush Singh wrote:
> > > On 16/12/24 11:39, David Gibson wrote:
> > > > On Tue, Dec 10, 2024 at 04:34:17PM +0100, Andreas Gnau wrote:
> > > > > If we add /append-property/, why not add /prepend-property/ as well? This is
> > > > > not only "nice for consistency", but it would also enable solving a problem
> > > > > where SoC compatible strings from dtsi [1] need to be repeated in board dts
> > > > > [2], because one cannot prepend to an existing property.
> > > > >
> > > > > ```
> > > > > dts-v1/;
> > > > > / {
> > > > >   compatible = "soc-vendor,soc1234";
> > > > > };
> > > > >
> > > > > / {
> > > > >   /prepend-property/ compatible = "board-vendor,board-xyz";
> > > > > };
> > > > > ```
> > > > >
> > > > > What do you think?
> > > > So, this kind of demonstrates why I don't love /append-property/ as a
> > > > proposed syntax.  The way I'd prefer to do this, ideally, is to allow
> > > > properties to be described as expressions.  We already have integer
> > > > expressions that can be used in < > context, but I had intended to
> > > > extent to string and bytestring expressions - but I've never had the
> > > > time to implement that.
> > > >
> > > > Under that proposal, I'd expect appending to look something like:
> > > >     str-prop = /previous-value/, "1";
> > > >
> > > > Prepending,
> > > >     str-prop = "1", /previous-value/;
> > > >
> > > > .. and you could do both at once in the obvious way.
> > > >
> > > > The downside, of course, is that this is a much more complicated
> > > > proposal to implement.  Parsing that syntax isn't too hard, but I
> > > > think doing it sensibly will need some structural changes in order to
> > > > evaluate property values as expressions, rather than simply
> > > > constructing the properties directly left to right.  In particular the
> > > > interactions between expression syntax and within-property labels (and
> > > > other markers) could be fiddly to get right.
> > >
> > > Do you wish to allow `/previous-value/` to be repeated in the same property?
> > > Something like this:
> > >
> > >     str-prop = "1", /previous-value/, "2", /previous-value/, "3";
> >
> > Yes, I'd expect that to work.  Note that I don't particularly like the
> > name "/previous-value/" - that was just an example to demonstrate what
> > I had in mind.  If anyone can think of a better or more succinct name
> > for this, please suggest it.
> 
> Something like "/./"? (dot is also used in assembler for the current address)
> So e.g.
> 
>     str-prop = "1", /./, "2", /./, "3";

/./ might work.

> Or would that be too short? "/orig/"?

It's not too short but I think "/orig/" is a bad idea. In cases where
the value of a property is modified more than twice, this would refer
to the most recent previous value, not the "original" / first value
assigned.  "/prev/" might work, though.

-- 
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
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmduJ4IACgkQzQJF27ox
2Gew+w//ajINHlXhmg23c+vjin8fGduJrNNqRPbOLZoV8IjKGvfiitBrb7aq78iX
gscIjHwFbHasN/Ie0ePY+pO0RW3XuejDOLcJ870+TcSJ9rDF/fGyvdtR4pbL/xGy
G29UESsxh1LytBAag3d6FuzSVNifJKPRkzzfnhTUIaT8yxr/2P2MI562wRi3f04n
9vQDDrnviVqTSAi3f60DdZCU5OVq8Uq7szwqAAc1bnNuobFh/Ue70EcvsQHrBWzg
uh/LURRV1ENHapY5VHlQpMQ6HqIjmrE1brAkK+nLneWXtuBWAb5gdLL0ULOtDO/U
aT3jruefS5nNxftzs5Ws9BoGqPOGNQL4IZ8niCoErEyd+zk69plX9/AHTOe21ti5
TLROEXSQn/Ws9i1EY+f6i+UlS89J3Ukuiu7P5YYZyCuTZ8SdkyVXTvoRoJgdkHgU
hvefYgA9HppaPo4LhGit+8M8Y+rg+7OTLcmC0qD7v/q391jOJValF7BymjktbHZr
1lNbnzmyC3ptA/yPytg5bq+gI83iTGZyutNpdJErH8prtsNhGS9UlIvMvHSmJRnu
VL3Smvf9Iz24cSWK4t3QHCRMuOG1uFmZMzg7LyghLRmroSJl2XggDoh6PI0TnLiN
Pfs1cwmtJSaICfu0lRTlrLWRxNXtCAleW6JvjE2gdp/LZ7YEdao=
=BdNG
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.