efi_loader: function descriptions efi_unicode_collation.c
[oweals/u-boot.git] / lib / fdtdec.c
index 125d9dbf26395c2262b338c6bb7d77d0e7a08bcb..eb11fc898e308efdadba2dc2b998e0b38158fdf6 100644 (file)
@@ -7,6 +7,9 @@
 #include <common.h>
 #include <boot_fit.h>
 #include <dm.h>
+#include <hang.h>
+#include <init.h>
+#include <malloc.h>
 #include <dm/of_extra.h>
 #include <env.h>
 #include <errno.h>
@@ -222,7 +225,7 @@ int fdtdec_get_pci_vendev(const void *blob, int node, u16 *vendor, u16 *device)
        return -ENOENT;
 }
 
-int fdtdec_get_pci_bar32(struct udevice *dev, struct fdt_pci_addr *addr,
+int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr,
                         u32 *bar)
 {
        int barnum;
@@ -1309,7 +1312,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
                }
 
                if (addr == carveout->start && (addr + size) == carveout->end) {
-                       *phandlep = fdt_get_phandle(blob, node);
+                       if (phandlep)
+                               *phandlep = fdt_get_phandle(blob, node);
                        return 0;
                }
        }
@@ -1338,13 +1342,15 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
        if (node < 0)
                return node;
 
-       err = fdt_generate_phandle(blob, &phandle);
-       if (err < 0)
-               return err;
+       if (phandlep) {
+               err = fdt_generate_phandle(blob, &phandle);
+               if (err < 0)
+                       return err;
 
-       err = fdtdec_set_phandle(blob, node, phandle);
-       if (err < 0)
-               return err;
+               err = fdtdec_set_phandle(blob, node, phandle);
+               if (err < 0)
+                       return err;
+       }
 
        /* store one or two address cells */
        if (na > 1)