summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-01-27 08:49:45 -0700
committerSimon Glass <sjg@chromium.org>2020-02-05 19:33:45 -0700
commit1aada6313ca9b9e9123a4118c78558ef413e1039 (patch)
treef5199e4a2cb45617d9ddf38012645f421d616a85
parenta8167d8ee2305f688d970f7ea4c38d7ca9b205ca (diff)
downloadu-boot-1aada6313ca9b9e9123a4118c78558ef413e1039.tar.gz
u-boot-1aada6313ca9b9e9123a4118c78558ef413e1039.tar.bz2
u-boot-1aada6313ca9b9e9123a4118c78558ef413e1039.zip
dm: core: Reimplement ofnode_read_size()
Now that we have ofnode_read_prop() we can rewrite this function using that one, reducing the amount of duplicated code. Update ofnode_read_size() and move it up next to the other similar functions. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/core/ofnode.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index eebc5a7dce..4fc29a7c43 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -151,6 +151,16 @@ const char *ofnode_read_string(ofnode node, const char *propname)
return str;
}
+int ofnode_read_size(ofnode node, const char *propname)
+{
+ int len;
+
+ if (!ofnode_read_prop(node, propname, &len))
+ return -EINVAL;
+
+ return len;
+}
+
ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)
{
ofnode subnode;
@@ -253,25 +263,6 @@ ofnode ofnode_get_by_phandle(uint phandle)
return node;
}
-int ofnode_read_size(ofnode node, const char *propname)
-{
- int len;
-
- if (ofnode_is_np(node)) {
- struct property *prop = of_find_property(
- ofnode_to_np(node), propname, NULL);
-
- if (prop)
- return prop->length;
- } else {
- if (fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
- &len))
- return len;
- }
-
- return -EINVAL;
-}
-
fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)
{
int na, ns;