Merge tag 'efi-2020-04-rc4-5' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
[oweals/u-boot.git] / lib / fdtdec.c
index 17736ce66554e0ce56e317480e7b12b64e73b399..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;
@@ -242,7 +245,7 @@ int fdtdec_get_pci_bar32(struct udevice *dev, struct fdt_pci_addr *addr,
 uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,
                           uint64_t default_val)
 {
-       const uint64_t *cell64;
+       const unaligned_fdt64_t *cell64;
        int length;
 
        cell64 = fdt_getprop(blob, node, prop_name, &length);
@@ -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)