Merge branch '2020-06-15-misc-bugfixes'
[platform/kernel/u-boot.git] / lib / optee / optee.c
index 9b49eb8..457d4cc 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <image.h>
+#include <log.h>
 #include <malloc.h>
 #include <linux/libfdt.h>
 #include <tee/optee.h>
@@ -92,7 +93,7 @@ static int optee_copy_firmware_node(const void *old_blob, void *fdt_blob)
 
        offs = fdt_add_subnode(fdt_blob, offs, "optee");
        if (offs < 0)
-               return ret;
+               return offs;
 
        /* copy the compatible property */
        prop = fdt_getprop(old_blob, old_offs, "compatible", &len);
@@ -155,8 +156,9 @@ int optee_copy_fdt_nodes(const void *old_blob, void *new_blob)
        /* optee inserts its memory regions as reserved-memory nodes */
        nodeoffset = fdt_subnode_offset(old_blob, 0, "reserved-memory");
        if (nodeoffset >= 0) {
-               subnode = fdt_first_subnode(old_blob, nodeoffset);
-               while (subnode >= 0) {
+               for (subnode = fdt_first_subnode(old_blob, nodeoffset);
+                    subnode >= 0;
+                    subnode = fdt_next_subnode(old_blob, subnode)) {
                        const char *name = fdt_get_name(old_blob,
                                                        subnode, NULL);
                        if (!name)
@@ -196,8 +198,6 @@ int optee_copy_fdt_nodes(const void *old_blob, void *new_blob)
                                if (ret < 0)
                                        return ret;
                        }
-
-                       subnode = fdt_next_subnode(old_blob, subnode);
                }
        }