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/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c
index ccfeded..284f5f5 100644
--- a/drivers/clk/aspeed/clk_ast2500.c
+++ b/drivers/clk/aspeed/clk_ast2500.c
@@ -498,8 +498,8 @@
 	struct ast2500_clk_priv *priv = dev_get_priv(dev);
 
 	priv->scu = devfdt_get_addr_ptr(dev);
-	if (IS_ERR(priv->scu))
-		return PTR_ERR(priv->scu);
+	if (!priv->scu)
+		return -EINVAL;
 
 	return 0;
 }
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)
diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c
index 214362d..253e653 100644
--- a/drivers/i2c/ast_i2c.c
+++ b/drivers/i2c/ast_i2c.c
@@ -93,8 +93,8 @@
 	int ret;
 
 	priv->regs = devfdt_get_addr_ptr(dev);
-	if (IS_ERR(priv->regs))
-		return PTR_ERR(priv->regs);
+	if (!priv->regs)
+		return -EINVAL;
 
 	ret = clk_get_by_index(dev, 0, &priv->clk);
 	if (ret < 0) {
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
index 2206e95..ac0377e 100644
--- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c
+++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
@@ -194,7 +194,7 @@
 	}
 
 	priv->base_reg = devfdt_get_addr_ptr(dev);
-	if (priv->base_reg == (void *)FDT_ADDR_T_NONE) {
+	if (!priv->base_reg) {
 		debug("%s: Failed to get base address\n", __func__);
 		return -EINVAL;
 	}
diff --git a/drivers/timer/ast_timer.c b/drivers/timer/ast_timer.c
index 3838601..9f28cbf 100644
--- a/drivers/timer/ast_timer.c
+++ b/drivers/timer/ast_timer.c
@@ -65,8 +65,8 @@
 	struct ast_timer_priv *priv = dev_get_priv(dev);
 
 	priv->regs = devfdt_get_addr_ptr(dev);
-	if (IS_ERR(priv->regs))
-		return PTR_ERR(priv->regs);
+	if (!priv->regs)
+		return -EINVAL;
 
 	priv->tmc = ast_get_timer_counter(priv->regs, AST_TICK_TIMER);
 
diff --git a/drivers/watchdog/ast_wdt.c b/drivers/watchdog/ast_wdt.c
index 7e11465..a21f9a4 100644
--- a/drivers/watchdog/ast_wdt.c
+++ b/drivers/watchdog/ast_wdt.c
@@ -91,8 +91,8 @@
 	struct ast_wdt_priv *priv = dev_get_priv(dev);
 
 	priv->regs = devfdt_get_addr_ptr(dev);
-	if (IS_ERR(priv->regs))
-		return PTR_ERR(priv->regs);
+	if (!priv->regs)
+		return -EINVAL;
 
 	return 0;
 }
diff --git a/include/dm/read.h b/include/dm/read.h
index cac7dd5..0a7aacd 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -802,9 +802,7 @@
 
 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)