summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-09-07 05:27:18 +0300
committerTom Rini <trini@konsulko.com>2022-09-30 05:43:42 +0300
commit66d0d0c188db9e816c5b18e8823a8d8bf5e9cd63 (patch)
tree382d7c8364b9c1cdbe4a6665410bd2312e1b462f /drivers/core
parent8909066199281b86bf4ee7673ec6d7983dd12a26 (diff)
downloadu-boot-66d0d0c188db9e816c5b18e8823a8d8bf5e9cd63.tar.xz
dm: core: Expand integer-reading tests
The current tests do not cover all the behaviour. Add some more. Tidy up a few inconsistencies between livetree and flattree which come to light with these tests. Also drop the -ENODATA error since it is never actually returned. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/of_access.c5
-rw-r--r--drivers/core/ofnode.c17
2 files changed, 15 insertions, 7 deletions
diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index 8631e1c286..85f7da5a49 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -471,8 +471,7 @@ struct device_node *of_find_node_by_phandle(struct device_node *root,
* @len: requested length of property value
*
* Return: the property value on success, -EINVAL if the property does not
- * exist, -ENODATA if property does not have a value, and -EOVERFLOW if the
- * property data isn't large enough.
+ * exist and -EOVERFLOW if the property data isn't large enough.
*/
static void *of_find_property_value_of_size(const struct device_node *np,
const char *propname, u32 len)
@@ -481,8 +480,6 @@ static void *of_find_property_value_of_size(const struct device_node *np,
if (!prop)
return ERR_PTR(-EINVAL);
- if (!prop->value)
- return ERR_PTR(-ENODATA);
if (len > prop->length)
return ERR_PTR(-EOVERFLOW);
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 4dd2aee11c..e4b4b352e4 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -296,9 +296,20 @@ int ofnode_read_u32_array(ofnode node, const char *propname,
return of_read_u32_array(ofnode_to_np(node), propname,
out_values, sz);
} else {
- return fdtdec_get_int_array(gd->fdt_blob,
- ofnode_to_offset(node), propname,
- out_values, sz);
+ int ret;
+
+ ret = fdtdec_get_int_array(gd->fdt_blob,
+ ofnode_to_offset(node), propname,
+ out_values, sz);
+
+ /* get the error right, but space is more important in SPL */
+ if (!IS_ENABLED(CONFIG_SPL_BUILD)) {
+ if (ret == -FDT_ERR_NOTFOUND)
+ return -EINVAL;
+ else if (ret == -FDT_ERR_BADLAYOUT)
+ return -EOVERFLOW;
+ }
+ return ret;
}
}