ofnode: Indicate when out of space in a few places

Update ofnode_add_subnode() and ofnode_add_prop() to return a suitable
error when space is exhausted in the FDT. This makes it easier to see
what is going wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Simon Glass
2025-01-10 17:00:10 -07:00
committed by Tom Rini
parent 6c6591c823
commit 8b2561bf9f

View File

@@ -1710,9 +1710,10 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname,
int ofnode_write_prop(ofnode node, const char *propname, const void *value,
int len, bool copy)
{
int ret;
if (of_live_active()) {
void *newval;
int ret;
if (copy) {
newval = malloc(len);
@@ -1726,8 +1727,12 @@ int ofnode_write_prop(ofnode node, const char *propname, const void *value,
free(newval);
return ret;
} else {
return fdt_setprop(ofnode_to_fdt(node), ofnode_to_offset(node),
propname, value, len);
ret = fdt_setprop(ofnode_to_fdt(node), ofnode_to_offset(node),
propname, value, len);
if (ret)
return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EINVAL;
return 0;
}
}
@@ -2015,7 +2020,7 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep)
ret = -EEXIST;
}
if (offset < 0)
return -EINVAL;
return offset == -FDT_ERR_NOSPACE ? -ENOSPC : -EINVAL;
subnode = noffset_to_ofnode(node, offset);
}