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 <ovidiu.panait@windriver.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
index dfcb868..8b48aa5 100644
--- a/drivers/core/fdtaddr.c
+++ b/drivers/core/fdtaddr.c
@@ -154,7 +154,9 @@
void *devfdt_get_addr_ptr(const struct udevice *dev)
{
- return (void *)(uintptr_t)devfdt_get_addr_index(dev, 0);
+ fdt_addr_t addr = devfdt_get_addr_index(dev, 0);
+
+ return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr;
}
void *devfdt_remap_addr_index(const struct udevice *dev, int index)