[RFC PATCH v1 4/4] drivers: use devfdt_get_addr_index_ptr when cast to pointer
Johan Jonker
jbx6244 at gmail.com
Sat Feb 25 20:19:52 CET 2023
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 devfdt_get_addr_index_ptr instead of
the devfdt_get_addr_index function in the various files
in the drivers directory that cast to a pointer.
Signed-off-by: Johan Jonker <jbx6244 at gmail.com>
---
Note:
This is needed for a Rockchip patch serie to pass the test and
must be merged before by Rockchip maintainers:
[PATCH v4 00/11] Fixes for Rockchip NFC driver part 1
https://lore.kernel.org/u-boot/f3dba231-4a55-0a94-dfab-5cab1419d132@gmail.com/
Replacement command used:
find . -type f -exec sed -i 's/*)devfdt_get_addr_index(/
*)devfdt_get_addr_index_ptr(/g' {} +
---
drivers/clk/clk-hsdk-cgu.c | 4 ++--
drivers/ddr/altera/sdram_gen5.c | 2 +-
drivers/mmc/xenon_sdhci.c | 2 +-
drivers/net/mvpp2.c | 24 ++++++++++++------------
drivers/pci/pcie_dw_mvebu.c | 4 ++--
drivers/pci/pcie_imx.c | 4 ++--
drivers/pci/pcie_layerscape_ep.c | 4 ++--
drivers/phy/marvell/comphy_core.c | 12 ++++++------
drivers/spi/cadence_qspi.c | 2 +-
drivers/usb/musb-new/ti-musb.c | 2 +-
10 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/drivers/clk/clk-hsdk-cgu.c b/drivers/clk/clk-hsdk-cgu.c
index 26b0aa9a..cf3d0fd3 100644
--- a/drivers/clk/clk-hsdk-cgu.c
+++ b/drivers/clk/clk-hsdk-cgu.c
@@ -753,11 +753,11 @@ static int hsdk_cgu_clk_probe(struct udevice *dev)
else
hsdk_clk->map = hsdk_4xd_clk_map;
- hsdk_clk->cgu_regs = (void __iomem *)devfdt_get_addr_index(dev, 0);
+ hsdk_clk->cgu_regs = (void __iomem *)devfdt_get_addr_index_ptr(dev, 0);
if (!hsdk_clk->cgu_regs)
return -EINVAL;
- hsdk_clk->creg_regs = (void __iomem *)devfdt_get_addr_index(dev, 1);
+ hsdk_clk->creg_regs = (void __iomem *)devfdt_get_addr_index_ptr(dev, 1);
if (!hsdk_clk->creg_regs)
return -EINVAL;
diff --git a/drivers/ddr/altera/sdram_gen5.c b/drivers/ddr/altera/sdram_gen5.c
index 8d3ce495..2cdfdd42 100644
--- a/drivers/ddr/altera/sdram_gen5.c
+++ b/drivers/ddr/altera/sdram_gen5.c
@@ -567,7 +567,7 @@ static int altera_gen5_sdram_of_to_plat(struct udevice *dev)
{
struct altera_gen5_sdram_plat *plat = dev_get_plat(dev);
- plat->sdr = (struct socfpga_sdr *)devfdt_get_addr_index(dev, 0);
+ plat->sdr = (struct socfpga_sdr *)devfdt_get_addr_index_ptr(dev, 0);
if (!plat->sdr)
return -ENODEV;
diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c
index 2f880509..16ac84a2 100644
--- a/drivers/mmc/xenon_sdhci.c
+++ b/drivers/mmc/xenon_sdhci.c
@@ -537,7 +537,7 @@ static int xenon_sdhci_of_to_plat(struct udevice *dev)
host->ioaddr = dev_read_addr_ptr(dev);
if (device_is_compatible(dev, "marvell,armada-3700-sdhci"))
- priv->pad_ctrl_reg = (void *)devfdt_get_addr_index(dev, 1);
+ priv->pad_ctrl_reg = devfdt_get_addr_index_ptr(dev, 1);
name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "marvell,pad-type",
NULL);
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 8c9afdf7..907d826d 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -5351,18 +5351,18 @@ static int mvpp2_base_probe(struct udevice *dev)
}
/* Save base addresses for later use */
- priv->base = (void *)devfdt_get_addr_index(dev, 0);
- if (IS_ERR(priv->base))
- return PTR_ERR(priv->base);
+ priv->base = devfdt_get_addr_index_ptr(dev, 0);
+ if (!priv->base)
+ return -EINVAL;
if (priv->hw_version == MVPP21) {
- priv->lms_base = (void *)devfdt_get_addr_index(dev, 1);
- if (IS_ERR(priv->lms_base))
- return PTR_ERR(priv->lms_base);
+ priv->lms_base = devfdt_get_addr_index_ptr(dev, 1);
+ if (!priv->lms_base)
+ return -EINVAL;
} else {
- priv->iface_base = (void *)devfdt_get_addr_index(dev, 1);
- if (IS_ERR(priv->iface_base))
- return PTR_ERR(priv->iface_base);
+ priv->iface_base = devfdt_get_addr_index_ptr(dev, 1);
+ if (!priv->iface_base)
+ return -EINVAL;
/* Store common base addresses for all ports */
priv->mpcs_base = priv->iface_base + MVPP22_MPCS;
@@ -5401,10 +5401,10 @@ static int mvpp2_probe(struct udevice *dev)
if (priv->hw_version == MVPP21) {
int priv_common_regs_num = 2;
- port->base = (void __iomem *)devfdt_get_addr_index(
+ port->base = (void __iomem *)devfdt_get_addr_index_ptr(
dev->parent, priv_common_regs_num + port->id);
- if (IS_ERR(port->base))
- return PTR_ERR(port->base);
+ if (!port->base)
+ return -EINVAL;
} else {
port->gop_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"gop-port-id", -1);
diff --git a/drivers/pci/pcie_dw_mvebu.c b/drivers/pci/pcie_dw_mvebu.c
index 3b2ada54..c41f3f15 100644
--- a/drivers/pci/pcie_dw_mvebu.c
+++ b/drivers/pci/pcie_dw_mvebu.c
@@ -564,8 +564,8 @@ static int pcie_dw_mvebu_of_to_plat(struct udevice *dev)
struct pcie_dw_mvebu *pcie = dev_get_priv(dev);
/* Get the controller base address */
- pcie->ctrl_base = (void *)devfdt_get_addr_index(dev, 0);
- if ((fdt_addr_t)pcie->ctrl_base == FDT_ADDR_T_NONE)
+ pcie->ctrl_base = devfdt_get_addr_index_ptr(dev, 0);
+ if (!pcie->ctrl_base)
return -EINVAL;
/* Get the config space base address and size */
diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c
index da484664..bf1ca5b6 100644
--- a/drivers/pci/pcie_imx.c
+++ b/drivers/pci/pcie_imx.c
@@ -751,8 +751,8 @@ static int imx_pcie_of_to_plat(struct udevice *dev)
{
struct imx_pcie_priv *priv = dev_get_priv(dev);
- priv->dbi_base = (void __iomem *)devfdt_get_addr_index(dev, 0);
- priv->cfg_base = (void __iomem *)devfdt_get_addr_index(dev, 1);
+ priv->dbi_base = (void __iomem *)devfdt_get_addr_index_ptr(dev, 0);
+ priv->cfg_base = (void __iomem *)devfdt_get_addr_index_ptr(dev, 1);
if (!priv->dbi_base || !priv->cfg_base)
return -EINVAL;
diff --git a/drivers/pci/pcie_layerscape_ep.c b/drivers/pci/pcie_layerscape_ep.c
index ff26a5cd..f4a0d1f2 100644
--- a/drivers/pci/pcie_layerscape_ep.c
+++ b/drivers/pci/pcie_layerscape_ep.c
@@ -250,11 +250,11 @@ static int ls_pcie_ep_probe(struct udevice *dev)
pcie_ep->pcie = pcie;
- pcie->dbi = (void __iomem *)devfdt_get_addr_index(dev, 0);
+ pcie->dbi = (void __iomem *)devfdt_get_addr_index_ptr(dev, 0);
if (!pcie->dbi)
return -ENOMEM;
- pcie->ctrl = (void __iomem *)devfdt_get_addr_index(dev, 1);
+ pcie->ctrl = (void __iomem *)devfdt_get_addr_index_ptr(dev, 1);
if (!pcie->ctrl)
return -ENOMEM;
diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c
index df2460db..7272dfb9 100644
--- a/drivers/phy/marvell/comphy_core.c
+++ b/drivers/phy/marvell/comphy_core.c
@@ -88,13 +88,13 @@ static int comphy_probe(struct udevice *dev)
int res;
/* Save base addresses for later use */
- chip_cfg->comphy_base_addr = (void *)devfdt_get_addr_index(dev, 0);
- if (IS_ERR(chip_cfg->comphy_base_addr))
- return PTR_ERR(chip_cfg->comphy_base_addr);
+ chip_cfg->comphy_base_addr = devfdt_get_addr_index_ptr(dev, 0);
+ if (!chip_cfg->comphy_base_addr)
+ return -EINVAL;
- chip_cfg->hpipe3_base_addr = (void *)devfdt_get_addr_index(dev, 1);
- if (IS_ERR(chip_cfg->hpipe3_base_addr))
- return PTR_ERR(chip_cfg->hpipe3_base_addr);
+ chip_cfg->hpipe3_base_addr = devfdt_get_addr_index_ptr(dev, 1);
+ if (!chip_cfg->hpipe3_base_addr)
+ return -EINVAL;
if (device_is_compatible(dev, "marvell,comphy-a3700")) {
chip_cfg->comphy_init_map = comphy_a3700_init_serdes_map;
diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index 93e57a54..ce069b96 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -377,7 +377,7 @@ static int cadence_spi_of_to_plat(struct udevice *bus)
struct cadence_spi_priv *priv = dev_get_priv(bus);
ofnode subnode;
- plat->regbase = (void *)devfdt_get_addr_index(bus, 0);
+ plat->regbase = devfdt_get_addr_index_ptr(bus, 0);
plat->ahbbase = devfdt_get_addr_size_index_ptr(bus, 1, &plat->ahbsize);
plat->is_decoded_cs = dev_read_bool(bus, "cdns,is-decoded-cs");
plat->fifo_depth = dev_read_u32_default(bus, "cdns,fifo-depth", 128);
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 91042935..3be3f93d 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -88,7 +88,7 @@ static int ti_musb_of_to_plat(struct udevice *dev)
int usb_index;
struct musb_hdrc_config *musb_config;
- plat->base = (void *)devfdt_get_addr_index(dev, 1);
+ plat->base = devfdt_get_addr_index_ptr(dev, 1);
phys = fdtdec_lookup_phandle(fdt, node, "phys");
ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod");
--
2.20.1
More information about the U-Boot
mailing list