dm: core: Support writing a property to an empty node

At present this does not work with livetree. Fix it and add a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass authored and Tom Rini committed 2022-09-29 16:07:58 -04:00
1 parent ffe9039249
commit c3a194dec9
2 files changed
+7 -4

No files matched your search

+4 -4
View File
@@ -947,9 +947,6 @@ int of_write_prop(struct device_node *np, const char *propname, int len,
pp_last = pp;
}
if (!pp_last)
return -ENOENT;
/* Property does not exist -> append new property */
new = malloc(sizeof(struct property));
if (!new)
@@ -965,7 +962,10 @@ int of_write_prop(struct device_node *np, const char *propname, int len,
new->length = len;
new->next = NULL;
pp_last->next = new;
if (pp_last)
pp_last->next = new;
else
np->properties = new;
return 0;
}
+3
View File
@@ -672,6 +672,9 @@ static int dm_test_ofnode_add_subnode(struct unit_test_state *uts)
malloc_disable_testing();
}
/* write to the empty node */
ut_assertok(ofnode_write_string(subnode, "example", "text"));
return 0;
}
DM_TEST(dm_test_ofnode_add_subnode,