devicetree-spec.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Node name & property name collusion - json/yaml implications
@ 2021-02-05 12:57 Kumar Gala
       [not found] ` <C008DF92-364E-4892-A1C0-68A2C97BE946-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Kumar Gala @ 2021-02-05 12:57 UTC (permalink / raw)
  To: Bolivar, Marti, Grant Likely, Rob.Herring-5wv7dgnIgG8,
	David Gibson
  Cc: devicetree-spec-u79uwXL29TY76Z2rM5mHXA

There’s an old thread about this from 2016:

https://www.spinics.net/lists/devicetree-spec/msg00296.html

In which its clearly stated that node names and property names technically can be the same.  However, as we’ve starting utilizing tooling like JSON for validation, does it make sense to maintain this and should we update the specification to require that a node name and property name at the same hierarchy in the tree is not allowed?

Otherwise we get into fun situations like, being valid DTS, but invalid YAML, and various tools not working correct as the YAML loaders have to pick one or there the other version of ‘foo’:

[Example is from Marti]

/dts-v1/;
/ {
	foo;
	foo {
		bar = <0>;
	};
};

(Using pyYAML)

$ dtc -I dts -O yaml ./foo.dts | python -c 'import sys, yaml; print(yaml.safe_load(sys.stdin.read()))’
[{'foo': {'bar': [[0]]}}]

(Using ruamel, w/allow_duplicate_keys as dt-schema does)

$ dtc -I dts -O yaml ./foo.dts | python -c 'import sys, ruamel.yaml; yaml = ruamel.yaml.YAML(typ="safe"); yaml.allow_duplicate_keys = True; print(yaml.load(sys.stdin.read()))’
[{'foo': True}]

- k

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-02-10  1:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-05 12:57 Node name & property name collusion - json/yaml implications Kumar Gala
     [not found] ` <C008DF92-364E-4892-A1C0-68A2C97BE946-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2021-02-05 17:25   ` Rob Herring
     [not found]     ` <65e8549e-2c90-903a-ed70-a1bda1a02af7-5wv7dgnIgG8@public.gmane.org>
2021-02-05 17:28       ` Kumar Gala
2021-02-06  7:11   ` David Gibson
     [not found]     ` <20210206071131.GA61463-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2021-02-08 14:39       ` Kumar Gala
     [not found]         ` <9B77D509-0790-4210-9B24-24527A8743D8-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2021-02-10  1:35           ` David Gibson
2021-02-08 15:01       ` Rob Herring
     [not found]         ` <CAL_Jsq+e7JjDJTAkDJj_6bcc70QZSZ3cP8012TE7QEf3+sid3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-02-08 15:47           ` Arnd Bergmann
     [not found]             ` <CAK8P3a34jOEFo6YfW752bVjEkh4sVr1dnRU+Y0wW9r+9YHXrzg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-02-08 16:00               ` Rob Herring
     [not found]                 ` <CAL_JsqKxuN-3_2eMbmxnLGXCo2PjOVxqsn7RQqQwTdKg_sJLAg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-02-08 16:07                   ` Kumar Gala

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