@@ -321,17 +321,41 @@ static void dt_add_phandle(struct pdbg_target *node, const char *name,
}
}
+static const void *_target_property(struct pdbg_target *target, const char *name, size_t *size)
+{
+ const void *buf;
+ int buflen;
+
+ if (target->fdt_offset == -1) {
+ size ? *size = 0 : 0;
+ return NULL;
+ }
+
+ buf = fdt_getprop(target->fdt, target->fdt_offset, name, &buflen);
+ if (!buf) {
+ size ? *size = 0 : 0;
+ return NULL;
+ }
+
+ size ? *size = buflen : 0;
+ return buf;
+}
+
bool pdbg_target_set_property(struct pdbg_target *target, const char *name, const void *val, size_t size)
{
const void *p;
size_t len;
int ret;
- if (!target->fdt || !pdbg_fdt_is_writeable(target->fdt))
+ p = _target_property(target, name, &len);
+ if (!p && target->vnode) {
+ target = target->vnode;
+ p = _target_property(target, name, &len);
+ }
+ if (!p)
return false;
- p = pdbg_target_property(target, name, &len);
- if (!p)
+ if (!target->fdt || !pdbg_fdt_is_writeable(target->fdt))
return false;
if (len != size)
@@ -346,22 +370,13 @@ bool pdbg_target_set_property(struct pdbg_target *target, const char *name, cons
const void *pdbg_target_property(struct pdbg_target *target, const char *name, size_t *size)
{
- const void *buf;
- int buflen;
-
- if (target->fdt_offset == -1) {
- size ? *size = 0 : 0;
- return NULL;
- }
+ const void *p;
- buf = fdt_getprop(target->fdt, target->fdt_offset, name, &buflen);
- if (!buf) {
- size ? *size = 0 : 0;
- return NULL;
- }
+ p = _target_property(target, name, size);
+ if (!p && target->vnode)
+ p = _target_property(target->vnode, name, size);
- size ? *size = buflen : 0;
- return buf;
+ return p;
}
static u32 dt_property_get_cell(const void *prop, size_t len, u32 index)
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> --- libpdbg/device.c | 49 +++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-)