[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] dtb: correct handling of #address-cells and #size-cells.
commit 0c46b4ce85516e208f587fe518dad24156d84ac2 Author: Ian Campbell <ian.campbell@xxxxxxxxxx> AuthorDate: Mon Feb 18 15:20:33 2013 +0000 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Wed Mar 13 10:56:49 2013 +0000 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@xxxxxxxxxx> Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- xen/arch/arm/domain_build.c | 9 +++++++-- xen/common/device_tree.c | 12 ++++++++---- xen/include/xen/device_tree.h | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 13dc049..9ed5bbc 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -195,11 +195,16 @@ static int write_nodes(struct domain *d, struct kernel_info *kinfo, continue; } + /* We cannot handle descending more than one level at a time */ + ASSERT( depth <= last_depth + 1 ); + while ( last_depth-- >= depth ) fdt_end_node(kinfo->fdt); - 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); fdt_begin_node(kinfo->fdt, name); diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 9af0cd4..19c000e 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); diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 1d04e4f..19bda98 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -66,7 +66,8 @@ void device_tree_get_reg(const u32 **cell, u32 address_cells, u32 size_cells, u64 *start, u64 *size); void device_tree_set_reg(u32 **cell, u32 address_cells, u32 size_cells, u64 start, u64 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); bool_t device_tree_node_matches(const void *fdt, int node, const char *match); bool_t device_tree_node_compatible(const void *fdt, int node, const char *match); int find_compatible_node(const char *compatible, int *node, int *depth, -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |