aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2019-07-28 16:25:51 +1000
committerDavid Gibson <david@gibson.dropbear.id.au>2019-07-28 16:31:44 +1000
commitb8d6eca78210952c6d93235c38ebd5836d6409c4 (patch)
tree6c01595b68f42cc955e2906786180430636ef7c4 /tests
parent184f51099471341715bc81a4c09b56a3c6f9d687 (diff)
downloaddtc-b8d6eca78210952c6d93235c38ebd5836d6409c4.zip
dtc-b8d6eca78210952c6d93235c38ebd5836d6409c4.tar.gz
dtc-b8d6eca78210952c6d93235c38ebd5836d6409c4.tar.bz2
libfdt: Allow #size-cells of 0
c12b2b0c20eb "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>
Diffstat (limited to 'tests')
-rw-r--r--tests/addr_size_cells.c2
-rw-r--r--tests/addresses.dts10
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/addr_size_cells.c b/tests/addr_size_cells.c
index 0d90d53..783574d 100644
--- a/tests/addr_size_cells.c
+++ b/tests/addr_size_cells.c
@@ -47,8 +47,10 @@ int main(int argc, char *argv[])
check_node(fdt, "/", 2, 2);
check_node(fdt, "/identity-bus@0", 2, 1);
check_node(fdt, "/simple-bus@1000000", 2, 1);
+ check_node(fdt, "/discrete-bus@2000000", 1, 0);
check_node(fdt, "/c0", -FDT_ERR_BADNCELLS, -FDT_ERR_BADNCELLS);
check_node(fdt, "/c1", -FDT_ERR_BADNCELLS, -FDT_ERR_BADNCELLS);
check_node(fdt, "/c2", -FDT_ERR_BADNCELLS, -FDT_ERR_BADNCELLS);
+ check_node(fdt, "/c3", -FDT_ERR_BADNCELLS, 0);
PASS();
}
diff --git a/tests/addresses.dts b/tests/addresses.dts
index fab6b19..1b307ab 100644
--- a/tests/addresses.dts
+++ b/tests/addresses.dts
@@ -13,6 +13,11 @@
#size-cells = <1>;
};
+ discrete-bus@2000000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+
c0@0 {
#address-cells = <1 1>;
#size-cells = <1 1>;
@@ -27,4 +32,9 @@
#address-cells = <5>;
#size-cells = <5>;
};
+
+ c3@0 {
+ #address-cells = <0>;
+ #size-cells = <0>;
+ };
};