@@ -180,7 +180,7 @@ int qemu_devtree_setprop_string(void *fdt, const char *node_path,
const void *qemu_devtree_getprop(void *fdt, const char *node_path,
const char *property, int *lenp,
- Error **errp)
+ bool inherit, Error **errp)
{
int len;
const void *r;
@@ -189,6 +189,11 @@ const void *qemu_devtree_getprop(void *fdt, const char *node_path,
}
r = fdt_getprop(fdt, findnode_nofail(fdt, node_path), property, lenp);
if (!r) {
+ char parent[DT_PATH_LENGTH];
+ if (inherit && !qemu_devtree_getparent(fdt, parent, node_path)) {
+ return qemu_devtree_getprop(fdt, parent, property, lenp, true,
+ errp);
+ }
fprintf(stderr, "%s: Couldn't get %s/%s: %s\n", __func__,
node_path, property, fdt_strerror(*lenp));
/* FIXME: Be smarter */
@@ -200,11 +205,11 @@ const void *qemu_devtree_getprop(void *fdt, const char *node_path,
uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path,
const char *property, int offset,
- Error **errp)
+ bool inherit, Error **errp)
{
int len;
const uint32_t *p = qemu_devtree_getprop(fdt, node_path, property, &len,
- errp);
+ inherit, errp);
if (errp && *errp) {
return 0;
}
@@ -33,10 +33,10 @@ int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
const char *target_node_path);
const void *qemu_devtree_getprop(void *fdt, const char *node_path,
const char *property, int *lenp,
- Error **errp);
+ bool inherit, Error **errp);
uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path,
const char *property, int offset,
- Error **errp);
+ bool inherit, Error **errp);
uint32_t qemu_devtree_get_phandle(void *fdt, const char *path);
uint32_t qemu_devtree_alloc_phandle(void *fdt);
int qemu_devtree_nop_node(void *fdt, const char *node_path);
@@ -239,8 +239,10 @@ static int load_dtb(target_phys_addr_t addr, const struct arm_boot_info *binfo)
}
g_free(filename);
- acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells", 0, &errp);
- scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells", 0, &errp);
+ acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells", 0,
+ false, &errp);
+ scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells", 0,
+ false, &errp);
assert_no_error(errp);
if (acells == 0 || scells == 0) {
If the inherit flag is set, and the specified property is not found, then search the parents for it as well. Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com> --- device_tree.c | 11 ++++++++--- device_tree.h | 4 ++-- hw/arm_boot.c | 6 ++++-- 3 files changed, 14 insertions(+), 7 deletions(-)