]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
drivers: use dev_read_addr_index_ptr when cast to pointer
authorJohan Jonker <jbx6244@gmail.com>
Mon, 13 Mar 2023 00:31:49 +0000 (01:31 +0100)
committerKever Yang <kever.yang@rock-chips.com>
Sat, 6 May 2023 09:28:18 +0000 (17:28 +0800)
The fdt_addr_t and phys_addr_t size have been decoupled. A 32bit CPU
can expect 64-bit data from the device tree parser, so use
dev_read_addr_index_ptr instead of the dev_read_addr_index function
in the various files in the drivers directory that cast to a pointer.
As we are there also streamline the error response to -EINVAL on return.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/mtd/nand/raw/cortina_nand.c
drivers/net/dm9000x.c
drivers/net/dwmac_meson8b.c
drivers/pci/pcie_dw_meson.c
drivers/pci/pcie_dw_rockchip.c
drivers/watchdog/sbsa_gwdt.c

index 88798f233ea7b8c5bf60266e4d3bda0ec5dd29c6..8de35731a53f24c36335ade0252830604d361aca 100644 (file)
@@ -1175,8 +1175,8 @@ static int fdt_decode_nand(struct udevice *dev, struct nand_drv *info)
        int ecc_strength;
 
        info->reg = (struct nand_ctlr *)dev_read_addr(dev);
-       info->dma_glb = (struct dma_global *)dev_read_addr_index(dev, 1);
-       info->dma_nand = (struct dma_ssp *)dev_read_addr_index(dev, 2);
+       info->dma_glb = dev_read_addr_index_ptr(dev, 1);
+       info->dma_nand = dev_read_addr_index_ptr(dev, 2);
        info->config.enabled = dev_read_enabled(dev);
        ecc_strength = dev_read_u32_default(dev, "nand-ecc-strength", 16);
        info->flash_base =
index b46bdeb23bee3b7bc108390bfa97b69e95ff7f5f..bec8d67dad0fd238368f709d237f637fda33cea9 100644 (file)
@@ -651,7 +651,7 @@ static int dm9000_of_to_plat(struct udevice *dev)
 
        pdata->iobase = dev_read_addr_index(dev, 0);
        db->base_io = (void __iomem *)pdata->iobase;
-       db->base_data = (void __iomem *)dev_read_addr_index(dev, 1);
+       db->base_data = dev_read_addr_index_ptr(dev, 1);
 
        return 0;
 }
index ddbaa87daf3d65d1bd7b9efbfba890676c9dbc6e..871171e1be5e68c40bee29aed6860409ecc1724a 100644 (file)
@@ -41,8 +41,8 @@ static int dwmac_meson8b_of_to_plat(struct udevice *dev)
 {
        struct dwmac_meson8b_plat *pdata = dev_get_plat(dev);
 
-       pdata->regs = (void *)dev_read_addr_index(dev, 1);
-       if ((fdt_addr_t)pdata->regs == FDT_ADDR_T_NONE)
+       pdata->regs = dev_read_addr_index_ptr(dev, 1);
+       if (!pdata->regs)
                return -EINVAL;
 
        pdata->dwmac_setup = (void *)dev_get_driver_data(dev);
index 07da9fa533221b672f459ff8fb422ca9350f47cf..f953797908b871c3ab50ea48df26a500dd5a348e 100644 (file)
@@ -337,15 +337,15 @@ static int meson_pcie_parse_dt(struct udevice *dev)
        struct meson_pcie *priv = dev_get_priv(dev);
        int ret;
 
-       priv->dw.dbi_base = (void *)dev_read_addr_index(dev, 0);
+       priv->dw.dbi_base = dev_read_addr_index_ptr(dev, 0);
        if (!priv->dw.dbi_base)
-               return -ENODEV;
+               return -EINVAL;
 
        dev_dbg(dev, "ELBI address is 0x%p\n", priv->dw.dbi_base);
 
-       priv->meson_cfg_base = (void *)dev_read_addr_index(dev, 1);
+       priv->meson_cfg_base = dev_read_addr_index_ptr(dev, 1);
        if (!priv->meson_cfg_base)
-               return -ENODEV;
+               return -EINVAL;
 
        dev_dbg(dev, "CFG address is 0x%p\n", priv->meson_cfg_base);
 
index 9322e735b9c3b35503fb8cd9651f65b79e343e58..624ca1cbcb89a825db13d2d8364f6806fc82a167 100644 (file)
@@ -353,15 +353,15 @@ static int rockchip_pcie_parse_dt(struct udevice *dev)
        struct rk_pcie *priv = dev_get_priv(dev);
        int ret;
 
-       priv->dw.dbi_base = (void *)dev_read_addr_index(dev, 0);
+       priv->dw.dbi_base = dev_read_addr_index_ptr(dev, 0);
        if (!priv->dw.dbi_base)
-               return -ENODEV;
+               return -EINVAL;
 
        dev_dbg(dev, "DBI address is 0x%p\n", priv->dw.dbi_base);
 
-       priv->apb_base = (void *)dev_read_addr_index(dev, 1);
+       priv->apb_base = dev_read_addr_index_ptr(dev, 1);
        if (!priv->apb_base)
-               return -ENODEV;
+               return -EINVAL;
 
        dev_dbg(dev, "APB address is 0x%p\n", priv->apb_base);
 
index f43cd3fd2fb29574c8d671e67d2e467ad3d22213..96d04665d52c1c0731c09f309d28cd5810bc6e89 100644 (file)
@@ -98,13 +98,13 @@ static int sbsa_gwdt_of_to_plat(struct udevice *dev)
 {
        struct sbsa_gwdt_priv *priv = dev_get_priv(dev);
 
-       priv->reg_control = (void __iomem *)dev_read_addr_index(dev, 0);
-       if (IS_ERR(priv->reg_control))
-               return PTR_ERR(priv->reg_control);
+       priv->reg_control = dev_read_addr_index_ptr(dev, 0);
+       if (!priv->reg_control)
+               return -EINVAL;
 
-       priv->reg_refresh = (void __iomem *)dev_read_addr_index(dev, 1);
-       if (IS_ERR(priv->reg_refresh))
-               return PTR_ERR(priv->reg_refresh);
+       priv->reg_refresh = dev_read_addr_index_ptr(dev, 1);
+       if (!priv->reg_refresh)
+               return -EINVAL;
 
        return 0;
 }