Skip to content

Commit

Permalink
treewide: convert devfdt_get_addr_ptr() to dev_read_addr_ptr()
Browse files Browse the repository at this point in the history
When you enable CONFIG_OF_LIVE, you will end up with a lot of
conversions.

To help this tedious work, this commit converts devfdt_get_addr_ptr()
to dev_read_addr_ptr() by coccinelle. I also removed redundant casts
because dev_read_addr_ptr() returns an opaque pointer.

To generate this commit, I ran the following semantic patch
excluding include/dm/.

  <smpl>
  @@
  type T;
  expression dev;
  @@
  -(T *)devfdt_get_addr_ptr(dev)
  +dev_read_addr_ptr(dev)
  @@
  expression dev;
  @@
  -devfdt_get_addr_ptr(dev)
  +dev_read_addr_ptr(dev)
  </smpl>

Signed-off-by: Masahiro Yamada <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
  • Loading branch information
masahir0y authored and sjg20 committed Aug 22, 2020
1 parent 1450bff commit 702e57e
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion drivers/clk/aspeed/clk_ast2500.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ 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);
priv->scu = dev_read_addr_ptr(dev);
if (!priv->scu)
return -EINVAL;

Expand Down
4 changes: 2 additions & 2 deletions drivers/clk/at91/pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int at91_pmc_core_probe(struct udevice *dev)

dev = dev_get_parent(dev);

plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev);
plat->reg_base = dev_read_addr_ptr(dev);

return 0;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ int at91_clk_probe(struct udevice *dev)
dev_periph_container = dev_get_parent(dev);
dev_pmc = dev_get_parent(dev_periph_container);

plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev_pmc);
plat->reg_base = dev_read_addr_ptr(dev_pmc);

return 0;
}
2 changes: 1 addition & 1 deletion drivers/gpio/hsdk-creg-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static int hsdk_creg_gpio_probe(struct udevice *dev)
u32 shift, bit_per_gpio, activate, deactivate, gpio_count;
const u8 *defaults;

hcg->regs = (u32 *)devfdt_get_addr_ptr(dev);
hcg->regs = dev_read_addr_ptr(dev);
gpio_count = dev_read_u32_default(dev, "gpio-count", 1);
shift = dev_read_u32_default(dev, "gpio-first-shift", 0);
bit_per_gpio = dev_read_u32_default(dev, "gpio-bit-per-line", 1);
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/ast_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int ast_i2c_ofdata_to_platdata(struct udevice *dev)
struct ast_i2c_priv *priv = dev_get_priv(dev);
int ret;

priv->regs = devfdt_get_addr_ptr(dev);
priv->regs = dev_read_addr_ptr(dev);
if (!priv->regs)
return -EINVAL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/designware_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ int designware_i2c_ofdata_to_platdata(struct udevice *bus)
int ret;

if (!priv->regs)
priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
priv->regs = dev_read_addr_ptr(bus);
dev_read_u32(bus, "i2c-scl-rising-time-ns", &priv->scl_rise_time_ns);
dev_read_u32(bus, "i2c-scl-falling-time-ns", &priv->scl_fall_time_ns);
dev_read_u32(bus, "i2c-sda-hold-time-ns", &priv->sda_hold_time_ns);
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/mv_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ static int mv_i2c_probe(struct udevice *bus)
{
struct mv_i2c_priv *priv = dev_get_priv(bus);

priv->base = (void *)devfdt_get_addr_ptr(bus);
priv->base = dev_read_addr_ptr(bus);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/i2c/mvtwsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus)
{
struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);

dev->base = devfdt_get_addr_ptr(bus);
dev->base = dev_read_addr_ptr(bus);

if (!dev->base)
return -ENOMEM;
Expand All @@ -820,7 +820,7 @@ static void twsi_disable_i2c_slave(struct mvtwsi_registers *twsi)

static int mvtwsi_i2c_bind(struct udevice *bus)
{
struct mvtwsi_registers *twsi = devfdt_get_addr_ptr(bus);
struct mvtwsi_registers *twsi = dev_read_addr_ptr(bus);

/* Disable the hidden slave in i2c0 of these platforms */
if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARCH_KIRKWOOD))
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/gen_atmel_mci.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ static int atmel_mci_probe(struct udevice *dev)
if (ret)
return ret;

plat->mci = (struct atmel_mci *)devfdt_get_addr_ptr(dev);
plat->mci = dev_read_addr_ptr(dev);

atmel_mci_setup_cfg(dev);

Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/snps_dw_mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static int snps_dwmmc_ofdata_to_platdata(struct udevice *dev)
u32 fifo_depth;
int ret;

host->ioaddr = devfdt_get_addr_ptr(dev);
host->ioaddr = dev_read_addr_ptr(dev);

/*
* If fifo-depth is unset don't set fifoth_val - we will try to
Expand Down
2 changes: 1 addition & 1 deletion drivers/pinctrl/mvebu/pinctrl-mvebu.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int mvebu_pinctl_probe(struct udevice *dev)
return -EINVAL;
}

priv->base_reg = devfdt_get_addr_ptr(dev);
priv->base_reg = dev_read_addr_ptr(dev);
if (!priv->base_reg) {
debug("%s: Failed to get base address\n", __func__);
return -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/reset/reset-socfpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static int socfpga_reset_probe(struct udevice *dev)
u32 modrst_offset;
void __iomem *membase;

membase = devfdt_get_addr_ptr(dev);
membase = dev_read_addr_ptr(dev);

modrst_offset = dev_read_u32_default(dev, "altr,modrst-offset", 0x10);
data->modrst_base = membase + modrst_offset;
Expand Down
2 changes: 1 addition & 1 deletion drivers/serial/serial_mvebu_a3700.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int mvebu_serial_ofdata_to_platdata(struct udevice *dev)
{
struct mvebu_platdata *plat = dev_get_platdata(dev);

plat->base = devfdt_get_addr_ptr(dev);
plat->base = dev_read_addr_ptr(dev);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/uniphier_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static int uniphier_spi_ofdata_to_platdata(struct udevice *bus)
const void *blob = gd->fdt_blob;
int node = dev_of_offset(bus);

plat->base = devfdt_get_addr_ptr(bus);
plat->base = dev_read_addr_ptr(bus);

plat->frequency =
fdtdec_get_int(blob, node, "spi-max-frequency", 12500000);
Expand Down
2 changes: 1 addition & 1 deletion drivers/sysreset/sysreset_socfpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int socfpga_sysreset_probe(struct udevice *dev)
{
struct socfpga_sysreset_data *data = dev_get_priv(dev);

data->rstmgr_base = devfdt_get_addr_ptr(dev);
data->rstmgr_base = dev_read_addr_ptr(dev);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/timer/ast_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ 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);
priv->regs = dev_read_addr_ptr(dev);
if (!priv->regs)
return -EINVAL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/timer/atmel_pit_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static int atmel_pit_ofdata_to_platdata(struct udevice *dev)
{
struct atmel_pit_platdata *plat = dev_get_platdata(dev);

plat->regs = (struct atmel_pit_regs *)devfdt_get_addr_ptr(dev);
plat->regs = dev_read_addr_ptr(dev);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/ehci-zynq.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static int ehci_zynq_ofdata_to_platdata(struct udevice *dev)
{
struct zynq_ehci_priv *priv = dev_get_priv(dev);

priv->ehci = (struct usb_ehci *)devfdt_get_addr_ptr(dev);
priv->ehci = dev_read_addr_ptr(dev);
if (!priv->ehci)
return -EINVAL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/watchdog/ast_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ 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);
priv->regs = dev_read_addr_ptr(dev);
if (!priv->regs)
return -EINVAL;

Expand Down

0 comments on commit 702e57e

Please sign in to comment.