Re: Node name & property name collusion - json/yaml implications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]




> On Feb 5, 2021, at 11:25 AM, Rob Herring <rob.herring@xxxxxxx> wrote:
> 
> On 2/5/21 6:57 AM, Kumar Gala wrote:
>> 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?
>> 
> 
> IMO, yes. We are effectively doing that already given some of the
> tooling doesn't really support it.
> 
> We've removed the few, rare cases in the kernel tree dts files.
> 
>> 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)
> 
> That reminds me, I need to go turn that off.

Was going to send you a patch to that, but sounds like you might get there first :)

>> $ 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

- k



[Index of Archives]     [Device Tree]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Photos]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]

  Powered by Linux