Re: [PATCH 0/3] Add capability to create property from old property

David Gibson <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler
Message-ID <Z8VwCsTCGXkFD46h@zatzit>
On Sat, Mar 01, 2025 at 06:55:01PM +0530, Ayush Singh wrote:
> Allow construction of new values for a property using old property
> value.
> 
> This was originally suggested in /append-property/ Patch series [0] and
> can be used to achieve the same results (and much more).
> 
> In practice, it looks as follows:
> 
> dts-v1/;
> 
> / {
> 	str-prop = "0";
> 	int-prop = <0>;
> };
> 
> / {
> 	str-prop = /./, "1", /./;
> 	int-prop = /./, <1>, /./;
> };
> 
> Open Items:
> 
> - Integer array:
> 
>   Currently, the use with integer arrays looks as follows:
> 
>   /dts-v1/;
>   
>   / {
>           int-prop = <0 1>;
>   };
>   
>   / {
>           int-prop = /./, <2 3>, /./;
>   };
> 
>   This will produce the correct code, and I personally prefer the
>   current syntax to ``</./ 1 /./>``.

You've made the correct choice.  We don't exactly keep track of types
in dtc, but we do some things close enough that you can kind of think
of things in terms of types.  </./ 1 /./> would make no sense from a
typing point of view, because you're putting a bytestring value /./ in
an operator that expects integers < ... >.

> - dts to source output can look somewhat weird
> 
>   The above dts produces the following with annoation:
> 
>   /dts-v1/;
>   
>   / { /* base.dts:3:3-5:3, base.dts:7:3-9:3 */
>           int-prop = <0x00 0x01>, <0x02 0x03>, <0x00 0x01>; /* base.dts:4:9-4:26, base.dts:8:9-8:36 */
>   }; /* base.dts:3:3-5:3, base.dts:7:3-9:3 */
> 
>   It isn't a real problem since it allows easily tracing that some parts
>   were constructed at other places, but is differnt from how a normal
>   array would appear.

Right.  This is just another example of the fact that properties are
just bytestrings, so how we format them for -Odts is a guess as to
type.  I sometimes think that preserving some "type" information
during the run so that -I dts -O dts will give output more similar to
the input was a mistake, since it can increase the false impression
that the dtb format is self-describing.

-- 
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+dNsU4E3yXUXRK2zQJF27ox2GcFAmfFcAYACgkQzQJF27ox
2GfyNg/+PJLaguBsewvB6S8EDB3i3vi5EzC4p5B7ZqJDyY+4bTktvZz2NK1TgSLP
4XKC/UdSYRkYWkvFi82BDEcQ+b28t5PvQLkYENA0Tc9V8PRyu3uJLvmpF93rEi0Z
fEboCrUYfXBEZJMXtegJgCcp2Ti3Fqu/qWfKN7pUYqpP6lC2bBClMNauFtSV3TQ7
x75b30i0Y3POHN1Z2RUHfFZSFi3zYvSD/Z0tT5/T7MVc+P9Q7w6NYHEktRQPDo9I
SQObLNBrvELhQWXqMaZDUzzpbcKQHxHwF3gj8l6qWEN0Mtgx4IL8mLfCSDSmLMUj
BHkZ/6Ow/7A/ZV30Kxvw4d1hPe5PfsR7+S0VZJ9hBgNrLytyg+9O7SMA/b71rbyC
4DXaVmttIkwUoIp5CX8bsJnNkglcBegHcYkFWjf2kCn/vAgrIuMBnL54fkcGbkfk
InCdnXQrSqfvSMCDhaepAsq8Fez2fU9V0Q+H//jys3+veqItxNuWlKi8pUYaIMbM
DaFB1HOLDhz90jMi+XJH9VXJX7OJdYXn1zS9fdn/9olEHcpAs+Y1iQKxUFY0CFEM
J07D41kMhaYLFGr7P8fL7LZ9Sjgv/jLLdh+NFjdj4gHCRr2Cs+RRVHF6R0+NIEeG
cPnLcEGp6b/3PqS9w478edeMsZPOPZK8SoywK8Kk2Y4pdXqJb4k=
=pEtR
-----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.