fdt: Add a function to look up a /chosen property
It is sometimes useful to find a property in the chosen node. Add a function
for this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 9db033a..e1df144 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -601,16 +601,21 @@
return -ENOENT;
}
+const char *fdtdec_get_chosen_prop(const void *blob, const char *name)
+{
+ int chosen_node;
+
+ if (!blob)
+ return NULL;
+ chosen_node = fdt_path_offset(blob, "/chosen");
+ return fdt_getprop(blob, chosen_node, name, NULL);
+}
+
int fdtdec_get_chosen_node(const void *blob, const char *name)
{
const char *prop;
- int chosen_node;
- int len;
- if (!blob)
- return -FDT_ERR_NOTFOUND;
- chosen_node = fdt_path_offset(blob, "/chosen");
- prop = fdt_getprop(blob, chosen_node, name, &len);
+ prop = fdtdec_get_chosen_prop(blob, name);
if (!prop)
return -FDT_ERR_NOTFOUND;
return fdt_path_offset(blob, prop);