4e76ec796c
Iterating through subnodes with libfdt is a little painful to write as we need something like this: for (depth = 0, count = 0, offset = fdt_next_node(fdt, parent_offset, &depth); (offset >= 0) && (depth > 0); offset = fdt_next_node(fdt, offset, &depth)) { if (depth == 1) { /* code body */ } } Using fdt_next_subnode() we can instead write this, which is shorter and easier to get right: for (offset = fdt_first_subnode(fdt, parent_offset); offset >= 0; offset = fdt_next_subnode(fdt, offset)) { /* code body */ } Also, it doesn't require two levels of indentation for the loop body. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
44 lines
761 B
Text
44 lines
761 B
Text
/dts-v1/;
|
|
|
|
/ {
|
|
#address-cells = <1>;
|
|
#size-cells = <0>;
|
|
|
|
test1 {
|
|
subnodes = <2>;
|
|
linux,phandle = <0x1>;
|
|
#address-cells = <1>;
|
|
#size-cells = <0>;
|
|
PowerPC,970@0 {
|
|
name = "PowerPC,970";
|
|
device_type = "cpu";
|
|
reg = <0x00000000>;
|
|
clock-frequency = <1600000000>;
|
|
timebase-frequency = <33333333>;
|
|
linux,boot-cpu;
|
|
i-cache-size = <65536>;
|
|
d-cache-size = <32768>;
|
|
another-sub-node {
|
|
should-be-ignored;
|
|
yet-another {
|
|
should-also-be-ignored;
|
|
};
|
|
};
|
|
};
|
|
|
|
PowerPC,970@1 {
|
|
name = "PowerPC,970";
|
|
device_type = "cpu";
|
|
reg = <0x00000001>;
|
|
clock-frequency = <1600000000>;
|
|
timebase-frequency = <33333333>;
|
|
i-cache-size = <65536>;
|
|
d-cache-size = <32768>;
|
|
};
|
|
};
|
|
|
|
test2 {
|
|
subnodes = <0>;
|
|
};
|
|
};
|
|
|