platform_external_dtc/tests/addresses.dts
David Gibson b8d6eca782 libfdt: Allow #size-cells of 0
c12b2b0c20 "libfdt: fdt_address_cells() and fdt_size_cells()" introduced
a bug as it consolidated code between the helpers for getting
#address-cells and #size-cells.  Specifically #size-cells is allowed to
be 0, and is frequently found so in practice for /cpus.  IEEE1275 only
requires implementations to handle 1..4 for #address-cells, although one
could make a case for #address-cells == #size-cells == 0 being used to
represent a bridge with a single port.

While we're there, it's not totally obvious that the existing implicit
cast of a u32 to int will give the correct results according to strict C,
although it does work in practice.  Straighten that up to cast only after
we've made our range checks.

Reported-by: yonghuhaige via https://github.com/dgibson/dtc/issues/28
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-28 16:31:44 +10:00

40 lines
516 B
Text

/dts-v1/;
/ {
compatible = "test_addresses";
#address-cells = <2>;
#size-cells = <2>;
identity-bus@0 {
};
simple-bus@1000000 {
#address-cells = <2>;
#size-cells = <1>;
};
discrete-bus@2000000 {
#address-cells = <1>;
#size-cells = <0>;
};
c0@0 {
#address-cells = <1 1>;
#size-cells = <1 1>;
};
c1@0 {
#address-cells = <0x80000000>;
#size-cells = <0x80000000>;
};
c2@0 {
#address-cells = <5>;
#size-cells = <5>;
};
c3@0 {
#address-cells = <0>;
#size-cells = <0>;
};
};