]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - lib/fdtdec.c
dm: fdt: Add a function to look up a chosen node
[karo-tx-uboot.git] / lib / fdtdec.c
index eb5aa20526fd509618311fdb3b4aab3c6379d46d..2b08be2405055863f4a1ace791eccbd32e125cb4 100644 (file)
@@ -380,6 +380,21 @@ int fdtdec_get_alias_node(const void *blob, const char *name)
        return fdt_path_offset(blob, prop);
 }
 
+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);
+       if (!prop)
+               return -FDT_ERR_NOTFOUND;
+       return fdt_path_offset(blob, prop);
+}
+
 int fdtdec_check_fdt(void)
 {
        /*