dtc/tests/type-preservation.dts
David Gibson 3b02a94b48 dtc: Correct invalid dts output with mixed phandles and integers
The handling of "type preservation" dts output is based on the idea of
"phandles with arguments" in properties, which isn't really a thing, other
than a fairly common convention about how bindings are written.  There's
nothing preventing a binding which freely mixes phandles and other integers
in an array of cells.

Currently write_propval() handles this incorrectly: specifically the case
of a phandle which follows a regular integer in a 32-bit cell array, but
without a new '< >' delimited causing an extra TYPE_UINT32 marker to be
inserted.  In this case it omits the necessary space between the integer
and the phandle reference, leading to output which can't be sent back into
dtc and parsed.

Correct this, and update tests to match.  I think this is more or less
correct for now, but really write_propval() is a big mess :(.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2023-05-14 16:27:27 +10:00

32 lines
928 B
Text

/dts-v1/;
/ {
#address-cells = <0x01>;
#size-cells = <0x00>;
sub1: subnode@1 {
prop_label: compatible = value_label: "subnode1";
reg = <0x01>;
int-array = <0x00 0x01>, int_value_label: <0x02 0x03>;
int8 = [56];
int8-array = [00 12 34 56] label:;
int16 = /bits/ 16 <0x3210>;
int16-array = /bits/ 16 <0x1234 0x5678 0x90ab 0xcdef>;
int16-matrix = /bits/ 16 <0x1234 0x5678>, <0x90ab 0xcdef>;
int64 = /bits/ 64 <0x200000000>;
int64-array = /bits/ 64 <0x100000000 0x00> int64_array_label_end:;
a-string-with-nulls = "foo\0bar", "baz";
a-phandle = <&subsub1>;
a-phandle-with-args = <&subsub1 0x00 0x01>, <&subsub1 0x02 0x03>;
mixed-ints-and-phandles = <0x01 &subsub1 0x02 &subsub1>;
subsub1: subsubnode {
compatible = "subsubnode1", "subsubnode";
phandle = <0x01>;
subsubsub1: subsubsubnode {
compatible = "subsubsubnode1", <0x1234>, valuea: valueb: "subsubsubnode";
};
};
};
};