From ae6b33dcc342e8539f4f69aba238748e9e89280a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 25 Jul 2020 21:38:49 +0200 Subject: dm: fix ofnode_read_addr/size_cells() In the case of the live tree ofnode_read_addr_cells() and ofnode_read_size_cells() return the #address-cells and #size-cells defined in the parent node. With the patch the same is done for a non-live tree. The only consumer of these functions is currently the CFI flash driver. This patch fixes the incorrect parsing of the device tree leading to 'saveenv' failing on qemu_arm64_defconfig. For testing qemu-system-aarch64 has to be called with -drive if=pflash,format=raw,index=1,file=envstore.img to provide the flash memory. envstore.img must be 64 MiB large. Signed-off-by: Heinrich Schuchardt Reviewed-by: Stefan Roese --- include/dm/read.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/dm/read.h b/include/dm/read.h index 487ec9e9c9..cac7dd5f18 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -878,14 +878,16 @@ static inline int dev_count_phandle_with_args(const struct udevice *dev, static inline int dev_read_addr_cells(const struct udevice *dev) { - /* NOTE: this call should walk up the parent stack */ - return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev)); + int parent = fdt_parent_offset(gd->fdt_blob, dev_of_offset(dev)); + + return fdt_address_cells(gd->fdt_blob, parent); } static inline int dev_read_size_cells(const struct udevice *dev) { - /* NOTE: this call should walk up the parent stack */ - return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev)); + int parent = fdt_parent_offset(gd->fdt_blob, dev_of_offset(dev)); + + return fdt_size_cells(gd->fdt_blob, parent); } static inline int dev_read_simple_addr_cells(const struct udevice *dev) -- cgit From 3fe69d3764c3ca6f304c51faa6aae7a84f1fa56c Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Mon, 3 Aug 2020 22:17:35 +0300 Subject: dm: core: Fix devfdt_get_addr_ptr return value According to the description of devfdt_get_addr_ptr, this function should return NULL on failure, but currently it returns (void *)FDT_ADDR_T_NONE. Fix this by making devfdt_get_addr_ptr return NULL on failure, as described in the function comments. Also, update the drivers currently checking (void *)FDT_ADDR_T_NONE to check for NULL. Signed-off-by: Ovidiu Panait Reviewed-by: Simon Glass --- include/dm/read.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include') diff --git a/include/dm/read.h b/include/dm/read.h index cac7dd5f18..0a7aacd2d0 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -802,9 +802,7 @@ static inline fdt_addr_t dev_read_addr(const struct udevice *dev) static inline void *dev_read_addr_ptr(const struct udevice *dev) { - void *addr = devfdt_get_addr_ptr(dev); - - return ((fdt_addr_t)(uintptr_t)addr == FDT_ADDR_T_NONE) ? NULL : addr; + return devfdt_get_addr_ptr(dev); } static inline fdt_addr_t dev_read_addr_pci(const struct udevice *dev) -- cgit