diff options
author | Ovidiu Panait <ovidiu.panait@windriver.com> | 2020-08-03 22:17:35 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-08-22 07:59:14 -0600 |
commit | 3fe69d3764c3ca6f304c51faa6aae7a84f1fa56c (patch) | |
tree | 4c61149fa9ef7f082f02ef176363e99cb2301ec5 /drivers/core/fdtaddr.c | |
parent | 02291d83fdaaf30e355eb7cef05581ec086962bd (diff) | |
download | u-boot-3fe69d3764c3ca6f304c51faa6aae7a84f1fa56c.tar.gz u-boot-3fe69d3764c3ca6f304c51faa6aae7a84f1fa56c.tar.xz u-boot-3fe69d3764c3ca6f304c51faa6aae7a84f1fa56c.zip |
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>
Diffstat (limited to 'drivers/core/fdtaddr.c')
-rw-r--r-- | drivers/core/fdtaddr.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c index dfcb868f65..8b48aa5bc5 100644 --- a/drivers/core/fdtaddr.c +++ b/drivers/core/fdtaddr.c @@ -154,7 +154,9 @@ fdt_addr_t devfdt_get_addr(const struct udevice *dev) 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) |