aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/device_tree.c
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2013-02-18 15:20:33 +0000
committerIan Campbell <ian.campbell@citrix.com>2013-03-13 10:56:49 +0000
commit0c46b4ce85516e208f587fe518dad24156d84ac2 (patch)
tree304de2b6908ccb4ac59acad77fceb65d58cb90ff /xen/common/device_tree.c
parentfde3412217a1e84e2601e591ca92e82a208d9688 (diff)
downloadxen-0c46b4ce85516e208f587fe518dad24156d84ac2.tar.gz
xen-0c46b4ce85516e208f587fe518dad24156d84ac2.tar.bz2
xen-0c46b4ce85516e208f587fe518dad24156d84ac2.zip
dtb: correct handling of #address-cells and #size-cells.
If a node does not have #*-cells then the parent's value should be used. Currently we were asssuming zero which is useless. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Diffstat (limited to 'xen/common/device_tree.c')
-rw-r--r--xen/common/device_tree.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 9af0cd4195..19c000ef06 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -120,13 +120,14 @@ void device_tree_set_reg(u32 **cell, u32 address_cells, u32 size_cells,
set_val(cell, size_cells, size);
}
-u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name)
+u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name,
+ u32 dflt)
{
const struct fdt_property *prop;
prop = fdt_get_property(fdt, node, prop_name, NULL);
if ( !prop || prop->len < sizeof(u32) )
- return 0; /* default to 0 */
+ return dflt;
return fdt32_to_cpu(*(uint32_t*)prop->data);
}
@@ -164,8 +165,11 @@ int device_tree_for_each_node(const void *fdt,
continue;
}
- address_cells[depth] = device_tree_get_u32(fdt, node, "#address-cells");
- size_cells[depth] = device_tree_get_u32(fdt, node, "#size-cells");
+ address_cells[depth] = device_tree_get_u32(fdt, node, "#address-cells",
+ depth > 0 ? address_cells[depth-1] : 0);
+ size_cells[depth] = device_tree_get_u32(fdt, node, "#size-cells",
+ depth > 0 ? size_cells[depth-1] : 0);
+
ret = func(fdt, node, name, depth,
address_cells[depth-1], size_cells[depth-1], data);