]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Fix devfdt_get_addr_ptr return value
authorOvidiu Panait <ovidiu.panait@windriver.com>
Mon, 3 Aug 2020 19:17:35 +0000 (22:17 +0300)
committerSimon Glass <sjg@chromium.org>
Sat, 22 Aug 2020 13:59:14 +0000 (07:59 -0600)
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>
drivers/clk/aspeed/clk_ast2500.c
drivers/core/fdtaddr.c
drivers/i2c/ast_i2c.c
drivers/pinctrl/mvebu/pinctrl-mvebu.c
drivers/timer/ast_timer.c
drivers/watchdog/ast_wdt.c
include/dm/read.h

index ccfeded30c56240a70bdcb99014a778c8b25c003..284f5f58d6e2d35a43faf940f1e0e81254da1045 100644 (file)
@@ -498,8 +498,8 @@ static int ast2500_clk_ofdata_to_platdata(struct udevice *dev)
        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;
 }
index dfcb868f6504709c9b2eb21c54fde59b44797c84..8b48aa5bc5b949ff950618d4e8c9400334dd2336 100644 (file)
@@ -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)
index 214362d04bb309ce74793cdb7cfaeed8bd0d40fc..253e653666ae29d364bb6abc1e1b09ed7c0b713c 100644 (file)
@@ -93,8 +93,8 @@ static int ast_i2c_ofdata_to_platdata(struct udevice *dev)
        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) {
index 2206e958ec7017a94556d8fa3875d96e87deec34..ac0377e7968cfc7f9b41b888d49f9e7bec2c77ea 100644 (file)
@@ -194,7 +194,7 @@ int mvebu_pinctl_probe(struct udevice *dev)
        }
 
        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;
        }
index 3838601f54d1c6b166f3e8e0b466160b79c0157e..9f28cbfcf9aaff39bf1bf921de27d59e1e73ee50 100644 (file)
@@ -65,8 +65,8 @@ static int ast_timer_ofdata_to_platdata(struct udevice *dev)
        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);
 
index 7e11465a570c48dbffa90de0f0ddc9f73bbeaed8..a21f9a4d1407d03f9403796073b9bb5b6422818c 100644 (file)
@@ -91,8 +91,8 @@ static int ast_wdt_ofdata_to_platdata(struct udevice *dev)
        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;
 }
index cac7dd5f187ee9e26e3f036153884022daae3d0c..0a7aacd2d04ccb0a567f5002dd46ecad803ed045 100644 (file)
@@ -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)