dm: core: Replace of_offset with accessor
At present devices use a simple integer offset to record the device tree
node associated with the device. In preparation for supporting a live
device tree, which uses a node pointer instead, refactor existing code to
access this field through an inline function.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index eff9c59..8344940 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
@@ -92,7 +92,7 @@
plat->regs = map_physmem(dev_get_addr(dev),
sizeof(struct altera_uart_regs),
MAP_NOCACHE);
- plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+ plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"clock-frequency", 0);
return 0;
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 2df4a1f..1f819d4 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -383,13 +383,13 @@
int ret;
/* we prefer to use a memory-mapped register */
- ret = fdtdec_get_pci_addr(gd->fdt_blob, dev->of_offset,
+ ret = fdtdec_get_pci_addr(gd->fdt_blob, dev_of_offset(dev),
FDT_PCI_SPACE_MEM32, "reg",
&pci_addr);
if (ret) {
/* try if there is any i/o-mapped register */
ret = fdtdec_get_pci_addr(gd->fdt_blob,
- dev->of_offset,
+ dev_of_offset(dev),
FDT_PCI_SPACE_IO,
"reg", &pci_addr);
if (ret)
@@ -413,9 +413,9 @@
plat->base = (unsigned long)map_physmem(addr, 0, MAP_NOCACHE);
#endif
- plat->reg_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+ plat->reg_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"reg-offset", 0);
- plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+ plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"reg-shift", 0);
err = clk_get_by_index(dev, 0, &clk);
@@ -429,7 +429,7 @@
}
if (!plat->clock)
- plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+ plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"clock-frequency",
CONFIG_SYS_NS16550_CLK);
if (!plat->clock) {
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index bcc3465..858e340 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -152,7 +152,7 @@
int i;
plat->colour = -1;
- colour = fdt_getprop(gd->fdt_blob, dev->of_offset,
+ colour = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
"sandbox,text-colour", NULL);
if (colour) {
for (i = 0; i < ARRAY_SIZE(ansi_colour); i++) {
diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c
index 326a536..fc91977 100644
--- a/drivers/serial/serial_arc.c
+++ b/drivers/serial/serial_arc.c
@@ -115,7 +115,7 @@
DECLARE_GLOBAL_DATA_PTR;
plat->reg = (struct arc_serial_regs *)dev_get_addr(dev);
- plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+ plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"clock-frequency", 0);
return 0;
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c
index 3884f74..e7ed899 100644
--- a/drivers/serial/serial_bcm283x_mu.c
+++ b/drivers/serial/serial_bcm283x_mu.c
@@ -164,8 +164,9 @@
return -EINVAL;
plat->base = addr;
- plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
- plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+ plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
+ 1);
+ plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"skip-init");
plat->disabled = false;
return 0;
diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c
index a7cab13..63b3006 100644
--- a/drivers/serial/serial_msm.c
+++ b/drivers/serial/serial_msm.c
@@ -146,7 +146,7 @@
static int msm_uart_clk_init(struct udevice *dev)
{
- uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+ uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
"clock-frequency", 115200);
uint clkd[2]; /* clk_id and clk_no */
int clk_offset;
@@ -154,8 +154,8 @@
struct clk clk;
int ret;
- ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "clock", clkd,
- 2);
+ ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "clock",
+ clkd, 2);
if (ret)
return ret;
diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 4fd2b1d..1cfcbf2 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -359,7 +359,7 @@
plat->reg = (struct mxc_uart *)addr;
- plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+ plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"fsl,dte-mode");
return 0;
}
diff --git a/drivers/serial/serial_pic32.c b/drivers/serial/serial_pic32.c
index c2141f0..b0e01aa 100644
--- a/drivers/serial/serial_pic32.c
+++ b/drivers/serial/serial_pic32.c
@@ -141,7 +141,8 @@
int ret;
/* get address */
- addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
+ addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg",
+ &size);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index a8d3d67..a49134a 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -354,9 +354,10 @@
return -EINVAL;
plat->base = addr;
- plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
+ plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
+ 1);
plat->type = dev_get_driver_data(dev);
- plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+ plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"skip-init");
return 0;
}
diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
index 6225479..96842de 100644
--- a/drivers/serial/serial_s5p.c
+++ b/drivers/serial/serial_s5p.c
@@ -187,7 +187,7 @@
return -EINVAL;
plat->reg = (struct s5p_uart *)addr;
- plat->port_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+ plat->port_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"id", dev->seq);
return 0;
}
diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
index ef7cf0f..51f7fbc 100644
--- a/drivers/serial/serial_sh.c
+++ b/drivers/serial/serial_sh.c
@@ -216,12 +216,13 @@
struct sh_serial_platdata *plat = dev_get_platdata(dev);
fdt_addr_t addr;
- addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+ addr = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "reg");
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
plat->base = addr;
- plat->clk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
+ plat->clk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
+ 1);
plat->type = dev_get_driver_data(dev);
return 0;
}
diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 4ea5304..0e25cba 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -105,7 +105,7 @@
priv->membase = port;
- priv->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+ priv->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"clock-frequency", 0);
tmp = readl(&port->lcr_mcr);