]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
treewide: use dev_read_addr_*_ptr() where appropriate
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
Wed, 27 Sep 2023 13:33:34 +0000 (15:33 +0200)
committerSimon Glass <sjg@chromium.org>
Fri, 13 Oct 2023 20:01:42 +0000 (14:01 -0600)
A follow-up to commit 842fb5de424e
("drivers: use devfdt_get_addr_size_index_ptr when cast to pointer")
and commit 320a1938b6f7
("drivers: use devfdt_get_addr_index_ptr when cast to pointer").

In addition to using the *_ptr variants of these functions where the
address is cast to a pointer, this also changes devfdt_get_addr_*() to
dev_read_addr_*() in a few places. Some variable and field types are
changed from fdt_addr_t or phys_addr_t to void* where the cast was
happening later.

This patch fixes a number of compile warnings when building a 32bit
U-Boot with CONFIG_PHYS_64BIT=y. In some places, it also fixes error
handling where the return value of dev_read_addr() etc. was checked for
NULL instead of FDT_ADDR_T_NONE.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/arm/mach-k3/sysfw-loader.c
drivers/dma/ti/k3-udma.c
drivers/gpio/tegra186_gpio.c
drivers/mailbox/k3-sec-proxy.c
drivers/phy/allwinner/phy-sun4i-usb.c
drivers/phy/phy-bcm-sr-pcie.c
drivers/ram/k3-am654-ddrss.c
drivers/ram/k3-ddrss/k3-ddrss.c
drivers/soc/ti/k3-navss-ringacc.c

index 9be2d9eaea265ef5578a2c66124cd6eb7a3a99d5..ef245fef9c4b9cf80665b7173684da541bbe0d8b 100644 (file)
@@ -321,7 +321,7 @@ exit:
 static void *k3_sysfw_get_spi_addr(void)
 {
        struct udevice *dev;
-       fdt_addr_t addr;
+       void *addr;
        int ret;
        unsigned int sf_bus = spl_spi_boot_bus();
 
@@ -329,11 +329,11 @@ static void *k3_sysfw_get_spi_addr(void)
        if (ret)
                return NULL;
 
-       addr = dev_read_addr_index(dev, 1);
-       if (addr == FDT_ADDR_T_NONE)
+       addr = dev_read_addr_index_ptr(dev, 1);
+       if (!addr)
                return NULL;
 
-       return (void *)(addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS);
+       return addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS;
 }
 
 static void k3_sysfw_spi_copy(u32 *dst, u32 *src, size_t len)
@@ -349,18 +349,18 @@ static void k3_sysfw_spi_copy(u32 *dst, u32 *src, size_t len)
 static void *get_sysfw_hf_addr(void)
 {
        struct udevice *dev;
-       fdt_addr_t addr;
+       void *addr;
        int ret;
 
        ret = uclass_find_first_device(UCLASS_MTD, &dev);
        if (ret)
                return NULL;
 
-       addr = dev_read_addr_index(dev, 1);
-       if (addr == FDT_ADDR_T_NONE)
+       addr = dev_read_addr_index_ptr(dev, 1);
+       if (!addr)
                return NULL;
 
-       return (void *)(addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS);
+       return addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS;
 }
 #endif
 
index 4f2effd39a803af9cb200d15f059d1d5c4e2ad2f..9273c70e9d942031d5d6bf191143444183ca992b 100644 (file)
@@ -1287,7 +1287,7 @@ static int udma_get_mmrs(struct udevice *dev)
        u32 cap2, cap3, cap4;
        int i;
 
-       ud->mmrs[MMR_GCFG] = (uint32_t *)devfdt_get_addr_name(dev, mmr_names[MMR_GCFG]);
+       ud->mmrs[MMR_GCFG] = dev_read_addr_name_ptr(dev, mmr_names[MMR_GCFG]);
        if (!ud->mmrs[MMR_GCFG])
                return -EINVAL;
 
@@ -1325,8 +1325,7 @@ static int udma_get_mmrs(struct udevice *dev)
                if (i == MMR_RCHANRT && ud->rchan_cnt == 0)
                        continue;
 
-               ud->mmrs[i] = (uint32_t *)devfdt_get_addr_name(dev,
-                               mmr_names[i]);
+               ud->mmrs[i] = dev_read_addr_name_ptr(dev, mmr_names[i]);
                if (!ud->mmrs[i])
                        return -EINVAL;
        }
index 82dcaf96312ae9a92dcecf4cbfc6fe7416daf439..94a20d143e10b868e760b50af4cc483568423b55 100644 (file)
@@ -176,8 +176,8 @@ static int tegra186_gpio_bind(struct udevice *parent)
        if (parent_plat)
                return 0;
 
-       regs = (uint32_t *)devfdt_get_addr_name(parent, "gpio");
-       if (regs == (uint32_t *)FDT_ADDR_T_NONE)
+       regs = dev_read_addr_name_ptr(parent, "gpio");
+       if (!regs)
                return -EINVAL;
 
        for (port = 0; port < ctlr_data->port_count; port++) {
index 2707261046273acf6697263f30e1de8b196a5cc6..e0a18d8a97d8cdd430d567cdc94966f777f00432 100644 (file)
@@ -84,9 +84,9 @@ struct k3_sec_proxy_mbox {
        struct mbox_chan chan;
        struct k3_sec_proxy_desc *desc;
        struct k3_sec_proxy_thread *chans;
-       phys_addr_t target_data;
-       phys_addr_t scfg;
-       phys_addr_t rt;
+       void *target_data;
+       void *scfg;
+       void *rt;
 };
 
 static inline u32 sp_readl(void __iomem *addr, unsigned int offset)
@@ -319,20 +319,20 @@ static int k3_sec_proxy_of_to_priv(struct udevice *dev,
                return -ENODEV;
        }
 
-       spm->target_data = devfdt_get_addr_name(dev, "target_data");
-       if (spm->target_data == FDT_ADDR_T_NONE) {
+       spm->target_data = dev_read_addr_name_ptr(dev, "target_data");
+       if (!spm->target_data) {
                dev_err(dev, "No reg property for target data base\n");
                return -EINVAL;
        }
 
-       spm->scfg = devfdt_get_addr_name(dev, "scfg");
-       if (spm->scfg == FDT_ADDR_T_NONE) {
+       spm->scfg = dev_read_addr_name_ptr(dev, "scfg");
+       if (!spm->scfg) {
                dev_err(dev, "No reg property for Secure Cfg base\n");
                return -EINVAL;
        }
 
-       spm->rt = devfdt_get_addr_name(dev, "rt");
-       if (spm->rt == FDT_ADDR_T_NONE) {
+       spm->rt = dev_read_addr_name_ptr(dev, "rt");
+       if (!spm->rt) {
                dev_err(dev, "No reg property for Real Time Cfg base\n");
                return -EINVAL;
        }
index 77dffcad88457917ae6412d497524a62ef1d7cb3..6624e9134f43baebf0bd612267498bd95a174a25 100644 (file)
@@ -472,9 +472,9 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
        if (!data->cfg)
                return -EINVAL;
 
-       data->base = (void __iomem *)devfdt_get_addr_name(dev, "phy_ctrl");
-       if (IS_ERR(data->base))
-               return PTR_ERR(data->base);
+       data->base = (void __iomem *)dev_read_addr_name_ptr(dev, "phy_ctrl");
+       if (!data->base)
+               return -EINVAL;
 
        device_get_supply_regulator(dev, "usb0_vbus_power-supply",
                                    &data->vbus_power_supply);
@@ -555,9 +555,9 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
 
                if (i || data->cfg->phy0_dual_route) {
                        snprintf(name, sizeof(name), "pmu%d", i);
-                       phy->pmu = (void __iomem *)devfdt_get_addr_name(dev, name);
-                       if (IS_ERR(phy->pmu))
-                               return PTR_ERR(phy->pmu);
+                       phy->pmu = (void __iomem *)dev_read_addr_name_ptr(dev, name);
+                       if (!phy->pmu)
+                               return -EINVAL;
                }
 
                phy->id = i;
index f0e795333b92e898f99953de6f1cca0f40a217ac..cf33bab370729b57bd2de604f6d85e99452cd2ed 100644 (file)
@@ -143,8 +143,8 @@ static int sr_pcie_phy_probe(struct udevice *dev)
 
        core->dev = dev;
 
-       core->base = (void __iomem *)devfdt_get_addr_name(dev, "reg_base");
-       core->cdru = (void __iomem *)devfdt_get_addr_name(dev, "cdru_base");
+       core->base = (void __iomem *)dev_read_addr_name_ptr(dev, "reg_base");
+       core->cdru = (void __iomem *)dev_read_addr_name_ptr(dev, "cdru_base");
        debug("ip base %p\n", core->base);
        debug("cdru base %p\n", core->cdru);
 
index b8338f84a3d15f87fe68c3d97a286914a4d2ab62..4a8a6a90bfc8bf3a8ee4cdae427c35bc224fb09f 100644 (file)
@@ -903,7 +903,7 @@ static int am654_ddrss_power_on(struct am654_ddrss_desc *ddrss)
 static int am654_ddrss_ofdata_to_priv(struct udevice *dev)
 {
        struct am654_ddrss_desc *ddrss = dev_get_priv(dev);
-       phys_addr_t reg;
+       void *reg;
        int ret;
 
        debug("%s(dev=%p)\n", __func__, dev);
@@ -926,26 +926,26 @@ static int am654_ddrss_ofdata_to_priv(struct udevice *dev)
                return ret;
        }
 
-       reg = devfdt_get_addr_name(dev, "ss");
-       if (reg == FDT_ADDR_T_NONE) {
+       reg = dev_read_addr_name_ptr(dev, "ss");
+       if (!reg) {
                dev_err(dev, "No reg property for DDRSS wrapper logic\n");
                return -EINVAL;
        }
-       ddrss->ddrss_ss_cfg = (void *)reg;
+       ddrss->ddrss_ss_cfg = reg;
 
-       reg = devfdt_get_addr_name(dev, "ctl");
-       if (reg == FDT_ADDR_T_NONE) {
+       reg = dev_read_addr_name_ptr(dev, "ctl");
+       if (!reg) {
                dev_err(dev, "No reg property for Controller region\n");
                return -EINVAL;
        }
-       ddrss->ddrss_ctl_cfg = (void *)reg;
+       ddrss->ddrss_ctl_cfg = reg;
 
-       reg = devfdt_get_addr_name(dev, "phy");
-       if (reg == FDT_ADDR_T_NONE) {
+       reg = dev_read_addr_name_ptr(dev, "phy");
+       if (!reg) {
                dev_err(dev, "No reg property for PHY region\n");
                return -EINVAL;
        }
-       ddrss->ddrss_phy_cfg = (void *)reg;
+       ddrss->ddrss_phy_cfg = reg;
 
        ret = dev_read_u32_array(dev, "ti,ss-reg",
                                 (u32 *)&ddrss->params.ss_reg,
index b54557f02cce1c52ed0143b8b83a2bcf9eb8bba3..5b6089e8526a10bdb11e46fdfee600b3a6678710 100644 (file)
@@ -331,32 +331,29 @@ static int k3_ddrss_ofdata_to_priv(struct udevice *dev)
 {
        struct k3_ddrss_desc *ddrss = dev_get_priv(dev);
        struct k3_ddrss_data *ddrss_data = (struct k3_ddrss_data *)dev_get_driver_data(dev);
-       phys_addr_t reg;
+       void *reg;
        int ret;
 
        debug("%s(dev=%p)\n", __func__, dev);
 
-       reg = dev_read_addr_name(dev, "cfg");
-       if (reg == FDT_ADDR_T_NONE) {
+       reg = dev_read_addr_name_ptr(dev, "cfg");
+       if (!reg) {
                dev_err(dev, "No reg property for DDRSS wrapper logic\n");
                return -EINVAL;
        }
-       ddrss->ddrss_ctl_cfg = (void *)reg;
+       ddrss->ddrss_ctl_cfg = reg;
 
-       reg = dev_read_addr_name(dev, "ctrl_mmr_lp4");
-       if (reg == FDT_ADDR_T_NONE) {
+       reg = dev_read_addr_name_ptr(dev, "ctrl_mmr_lp4");
+       if (!reg) {
                dev_err(dev, "No reg property for CTRL MMR\n");
                return -EINVAL;
        }
-       ddrss->ddrss_ctrl_mmr = (void *)reg;
+       ddrss->ddrss_ctrl_mmr = reg;
 
-       reg = dev_read_addr_name(dev, "ss_cfg");
-       if (reg == FDT_ADDR_T_NONE) {
+       reg = dev_read_addr_name_ptr(dev, "ss_cfg");
+       if (!reg)
                dev_dbg(dev, "No reg property for SS Config region, but this is optional so continuing.\n");
-               ddrss->ddrss_ss_cfg = NULL;
-       } else {
-               ddrss->ddrss_ss_cfg = (void *)reg;
-       }
+       ddrss->ddrss_ss_cfg = reg;
 
        ret = power_domain_get_by_index(dev, &ddrss->ddrcfg_pwrdmn, 0);
        if (ret) {
index 9881bffc8e179c1c8d4e09faa767940ede51b8ce..e02889649b28e26b9d3ae3ad352a5515e477e859 100644 (file)
@@ -987,10 +987,10 @@ static int k3_nav_ringacc_init(struct udevice *dev, struct k3_nav_ringacc *ringa
        if (!base_cfg)
                return -EINVAL;
 
-       base_rt = (uint32_t *)devfdt_get_addr_name(dev, "rt");
+       base_rt = dev_read_addr_name_ptr(dev, "rt");
        pr_debug("rt %p\n", base_rt);
-       if (IS_ERR(base_rt))
-               return PTR_ERR(base_rt);
+       if (!base_rt)
+               return -EINVAL;
 
        ringacc->rings = devm_kzalloc(dev,
                                      sizeof(*ringacc->rings) *
@@ -1045,9 +1045,9 @@ struct k3_nav_ringacc *k3_ringacc_dmarings_init(struct udevice *dev,
        ringacc->tisci = data->tisci;
        ringacc->tisci_dev_id = data->tisci_dev_id;
 
-       base_rt = (uint32_t *)devfdt_get_addr_name(dev, "ringrt");
-       if (IS_ERR(base_rt))
-               return base_rt;
+       base_rt = dev_read_addr_name_ptr(dev, "ringrt");
+       if (!base_rt)
+               return ERR_PTR(-EINVAL);
 
        ringacc->rings = devm_kzalloc(dev,
                                      sizeof(*ringacc->rings) *