Commit e160f7d4 authored by Simon Glass's avatar Simon Glass

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: 's avatarSimon Glass <sjg@chromium.org>
parent 8aa41363
......@@ -392,7 +392,7 @@ static int ast2500_sdrammc_ofdata_to_platdata(struct udevice *dev)
priv->regs = regmap_get_range(map, 0);
priv->phy = regmap_get_range(map, 1);
priv->clock_rate = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
priv->clock_rate = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"clock-frequency", 0);
if (!priv->clock_rate) {
......
......@@ -1016,7 +1016,7 @@ static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev)
#if !CONFIG_IS_ENABLED(OF_PLATDATA)
struct rk3288_sdram_params *params = dev_get_platdata(dev);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int node = dev_of_offset(dev);
int ret;
/* Rk3288 supports dual-channel, set default channel num to 2 */
......
......@@ -103,7 +103,7 @@ static int altera_nios2_get_count(struct udevice *dev)
static int altera_nios2_probe(struct udevice *dev)
{
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int node = dev_of_offset(dev);
gd->cpu_clk = fdtdec_get_int(blob, node,
"clock-frequency", 0);
......
......@@ -256,8 +256,8 @@ static void initialize_vr_config(struct udevice *dev)
/* Set the slow ramp rate */
msr.hi &= ~(0x3 << (53 - 32));
/* Configure the C-state exit ramp rate */
ramp = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "intel,slow-ramp",
-1);
ramp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"intel,slow-ramp", -1);
if (ramp != -1) {
/* Configured slow ramp rate */
msr.hi |= ((ramp & 0x3) << (53 - 32));
......@@ -271,8 +271,8 @@ static void initialize_vr_config(struct udevice *dev)
}
/* Set MIN_VID (31:24) to allow CPU to have full control */
msr.lo &= ~0xff000000;
min_vid = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "intel,min-vid",
0);
min_vid = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"intel,min-vid", 0);
msr.lo |= (min_vid & 0xff) << 24;
msr_write(MSR_VR_MISC_CONFIG, msr);
......@@ -562,7 +562,7 @@ static void configure_thermal_target(struct udevice *dev)
int tcc_offset;
msr_t msr;
tcc_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
tcc_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"intel,tcc-offset", 0);
/* Set TCC activaiton offset if supported */
......
......@@ -190,14 +190,14 @@ static int pch_power_options(struct udevice *dev)
debug("Set power %s after power failure.\n", state);
/* GPE setup based on device tree configuration */
ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
"intel,gpe0-en", enable, ARRAY_SIZE(enable));
if (ret)
return -EINVAL;
enable_all_gpe(enable[0], enable[1], enable[2], enable[3]);
/* SMI setup based on device tree configuration */
enable_alt_smi(dev, fdtdec_get_int(gd->fdt_blob, dev->of_offset,
enable_alt_smi(dev, fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"intel,alt-gp-smi-enable", 0));
return 0;
......
......@@ -51,7 +51,7 @@ static int broadwell_pinctrl_read_configs(struct udevice *dev,
int node;
debug("%s: starting\n", __func__);
for (node = fdt_first_subnode(blob, dev->of_offset);
for (node = fdt_first_subnode(blob, dev_of_offset(dev));
node > 0;
node = fdt_next_subnode(blob, node)) {
int phandle = fdt_get_phandle(blob, node);
......@@ -115,7 +115,7 @@ static int broadwell_pinctrl_read_pins(struct udevice *dev,
int count = 0;
int node;
for (node = fdt_first_subnode(blob, dev->of_offset);
for (node = fdt_first_subnode(blob, dev_of_offset(dev));
node > 0;
node = fdt_next_subnode(blob, node)) {
int len, i;
......
......@@ -235,7 +235,7 @@ static int broadwell_sata_ofdata_to_platdata(struct udevice *dev)
{
struct sata_platdata *plat = dev_get_platdata(dev);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int node = dev_of_offset(dev);
plat->port_map = fdtdec_get_int(blob, node, "intel,sata-port-map", 0);
plat->port0_gen3_tx = fdtdec_get_int(blob, node,
......
......@@ -17,7 +17,7 @@ int cpu_x86_bind(struct udevice *dev)
struct cpu_platdata *plat = dev_get_parent_platdata(dev);
struct cpuid_result res;
plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"intel,apic-id", -1);
plat->family = gd->arch.x86;
res = cpuid(1);
......
......@@ -50,7 +50,7 @@ int lpc_common_early_init(struct udevice *dev)
int count;
int i;
count = fdtdec_get_int_array_count(gd->fdt_blob, dev->of_offset,
count = fdtdec_get_int_array_count(gd->fdt_blob, dev_of_offset(dev),
"intel,gen-dec", (u32 *)values,
sizeof(values) / sizeof(u32));
if (count < 0)
......
......@@ -149,7 +149,7 @@ int mrc_locate_spd(struct udevice *dev, int size, const void **spd_datap)
spd_index = dm_gpio_get_values_as_int(desc, ret);
debug("spd index %d\n", spd_index);
node = fdt_first_subnode(blob, dev->of_offset);
node = fdt_first_subnode(blob, dev_of_offset(dev));
if (node < 0)
return -EINVAL;
for (spd_node = fdt_first_subnode(blob, node);
......
......@@ -96,7 +96,7 @@ static int create_pirq_routing_table(struct udevice *dev)
int i;
int ret;
node = dev->of_offset;
node = dev_of_offset(dev);
/* extract the bdf from fdt_pci_addr */
priv->bdf = dm_pci_get_bdf(dev->parent);
......
......@@ -86,7 +86,7 @@ static int pch_pirq_init(struct udevice *pch)
{
uint8_t route[8], *ptr;
if (fdtdec_get_byte_array(gd->fdt_blob, pch->of_offset,
if (fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(pch),
"intel,pirq-routing", route, sizeof(route)))
return -EINVAL;
ptr = route;
......@@ -113,7 +113,7 @@ static int pch_gpi_routing(struct udevice *pch)
u32 reg;
int gpi;
if (fdtdec_get_byte_array(gd->fdt_blob, pch->of_offset,
if (fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(pch),
"intel,gpi-routing", route, sizeof(route)))
return -EINVAL;
......@@ -128,7 +128,7 @@ static int pch_gpi_routing(struct udevice *pch)
static int pch_power_options(struct udevice *pch)
{
const void *blob = gd->fdt_blob;
int node = pch->of_offset;
int node = dev_of_offset(pch);
u8 reg8;
u16 reg16, pmbase;
u32 reg32;
......
......@@ -288,8 +288,8 @@ static int configure_thermal_target(struct udevice *dev)
int tcc_offset;
msr_t msr;
tcc_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "tcc-offset",
0);
tcc_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"tcc-offset", 0);
/* Set TCC activaiton offset if supported */
msr = msr_read(MSR_PLATFORM_INFO);
......
......@@ -39,7 +39,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
{
unsigned int port_map, speed_support, port_tx;
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int node = dev_of_offset(dev);
const char *mode;
u32 reg32;
u16 reg16;
......@@ -190,7 +190,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
static void bd82x6x_sata_enable(struct udevice *dev)
{
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int node = dev_of_offset(dev);
unsigned port_map;
const char *mode;
u16 map = 0;
......
......@@ -568,7 +568,8 @@ int mp_init_cpu(struct udevice *cpu, void *unused)
* seq num in the uclass_resolve_seq() during device_probe(). To avoid
* this, set req_seq to the reg number in the device tree in advance.
*/
cpu->req_seq = fdtdec_get_int(gd->fdt_blob, cpu->of_offset, "reg", -1);
cpu->req_seq = fdtdec_get_int(gd->fdt_blob, dev_of_offset(cpu), "reg",
-1);
plat->ucode_version = microcode_read_rev();
plat->device_id = gd->arch.x86_device;
......
......@@ -304,7 +304,8 @@ static int mptable_add_intsrc(struct mp_config_table *mc,
}
/* Get I/O interrupt information from device tree */
cell = fdt_getprop(blob, dev->of_offset, "intel,pirq-routing", &len);
cell = fdt_getprop(blob, dev_of_offset(dev), "intel,pirq-routing",
&len);
if (!cell)
return -ENOENT;
......
......@@ -187,7 +187,7 @@ static int ich6_pinctrl_probe(struct udevice *dev)
return -EINVAL;
}
for (pin_node = fdt_first_subnode(gd->fdt_blob, dev->of_offset);
for (pin_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
pin_node > 0;
pin_node = fdt_next_subnode(gd->fdt_blob, pin_node)) {
/* Configure the pin */
......
......@@ -44,7 +44,8 @@ int board_prepare_usb(enum usb_init_type type)
/* Try to request gpios needed to start usb host on dragonboard */
if (!dm_gpio_is_valid(&hub_reset)) {
node = fdt_subnode_offset(gd->fdt_blob, pmic_gpio->of_offset,
node = fdt_subnode_offset(gd->fdt_blob,
dev_of_offset(pmic_gpio),
"usb_hub_reset_pm");
if (node < 0) {
printf("Failed to find usb_hub_reset_pm dt node.\n");
......@@ -59,7 +60,8 @@ int board_prepare_usb(enum usb_init_type type)
}
if (!dm_gpio_is_valid(&usb_sel)) {
node = fdt_subnode_offset(gd->fdt_blob, pmic_gpio->of_offset,
node = fdt_subnode_offset(gd->fdt_blob,
dev_of_offset(pmic_gpio),
"usb_sw_sel_pm");
if (node < 0) {
printf("Failed to find usb_sw_sel_pm dt node.\n");
......@@ -110,7 +112,8 @@ int misc_init_r(void)
return 0;
}
node = fdt_subnode_offset(gd->fdt_blob, pon->of_offset, "key_vol_down");
node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
"key_vol_down");
if (node < 0) {
printf("Failed to find key_vol_down node. Check device tree\n");
return 0;
......
......@@ -684,7 +684,7 @@ steps (see device_probe()):
g. If the driver provides an ofdata_to_platdata() method, then this is
called to convert the device tree data into platform data. This should
do various calls like fdtdec_get_int(gd->fdt_blob, dev->of_offset, ...)
do various calls like fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), ...)
to access the node and store the resulting information into dev->platdata.
After this point, the device works the same way whether it was bound
using a device tree node or U_BOOT_DEVICE() structure. In either case,
......
......@@ -205,7 +205,7 @@ For example:
/* Decode the device tree data */
struct mmc_platdata *plat = dev_get_platdata(dev);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int node = dev_of_offset(dev);
plat->fifo_depth = fdtdec_get_int(blob, node, "fifo-depth", 0);
#endif
......
......@@ -223,7 +223,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus)
{
struct exynos_spi_platdata *plat = bus->platdata;
const void *blob = gd->fdt_blob;
int node = bus->of_offset;
int node = dev_of_offset(bus);
plat->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, "reg");
plat->periph_id = pinmux_decode_periph_id(blob, node);
......
......@@ -345,7 +345,7 @@ nodev:
static int adc_vdd_platdata_set(struct udevice *dev)
{
struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev);
int ret, offset = dev->of_offset;
int ret, offset = dev_of_offset(dev);
const void *fdt = gd->fdt_blob;
char *prop;
......@@ -366,7 +366,7 @@ static int adc_vdd_platdata_set(struct udevice *dev)
static int adc_vss_platdata_set(struct udevice *dev)
{
struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev);
int ret, offset = dev->of_offset;
int ret, offset = dev_of_offset(dev);
const void *fdt = gd->fdt_blob;
char *prop;
......
......@@ -154,9 +154,8 @@ static int generic_clk_ofdata_to_platdata(struct udevice *dev)
u32 num_parents;
num_parents = fdtdec_get_int_array_count(gd->fdt_blob,
dev_get_parent(dev)->of_offset,
"clocks", cells,
GENERATED_SOURCE_MAX);
dev_of_offset(dev_get_parent(dev)), "clocks", cells,
GENERATED_SOURCE_MAX);
if (!num_parents)
return -1;
......
......@@ -47,7 +47,7 @@ int at91_pmc_core_probe(struct udevice *dev)
int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name)
{
const void *fdt = gd->fdt_blob;
int offset = dev->of_offset;
int offset = dev_of_offset(dev);
bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);
const char *name;
int ret;
......@@ -90,7 +90,8 @@ int at91_clk_of_xlate(struct clk *clk, struct fdtdec_phandle_args *args)
return -EINVAL;
}
periph = fdtdec_get_uint(gd->fdt_blob, clk->dev->of_offset, "reg", -1);
periph = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(clk->dev), "reg",
-1);
if (periph < 0)
return -EINVAL;
......
......@@ -65,7 +65,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk);
assert(clk);
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
"clocks", "#clock-cells", 0, index,
&args);
if (ret) {
......@@ -104,7 +104,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)
debug("%s(dev=%p, name=%s, clk=%p)\n", __func__, dev, name, clk);
index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset,
index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
"clock-names", name);
if (index < 0) {
debug("fdt_stringlist_search() failed: %d\n", index);
......
......@@ -32,7 +32,7 @@ static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
{
#if !CONFIG_IS_ENABLED(OF_PLATDATA)
to_clk_fixed_rate(dev)->fixed_rate =
fdtdec_get_int(gd->fdt_blob, dev->of_offset,
fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"clock-frequency", 0);
#endif
......
......@@ -330,7 +330,7 @@ static void pic32_clk_init(struct udevice *dev)
for (i = REF1CLK; i <= REF5CLK; i++) {
snprintf(propname, sizeof(propname),
"microchip,refo%d-frequency", i - REF1CLK + 1);
rate = fdtdec_get_int(blob, dev->of_offset, propname, 0);
rate = fdtdec_get_int(blob, dev_of_offset(dev), propname, 0);
if (rate)
pic32_set_refclk(priv, i, pll_hz, rate, ROCLK_SRC_SPLL);
}
......@@ -393,7 +393,8 @@ static int pic32_clk_probe(struct udevice *dev)
fdt_addr_t addr;
fdt_size_t size;
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;
......
......@@ -355,7 +355,7 @@ int device_probe(struct udevice *dev)
goto fail;
}
if (drv->ofdata_to_platdata && dev->of_offset >= 0) {
if (drv->ofdata_to_platdata && dev_of_offset(dev) >= 0) {
ret = drv->ofdata_to_platdata(dev);
if (ret)
goto fail;
......@@ -524,7 +524,7 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset,
*devp = NULL;
list_for_each_entry(dev, &parent->child_head, sibling_node) {
if (dev->of_offset == of_offset) {
if (dev_of_offset(dev) == of_offset) {
*devp = dev;
return 0;
}
......@@ -549,7 +549,7 @@ static struct udevice *_device_find_global_by_of_offset(struct udevice *parent,
{
struct udevice *dev, *found;
if (parent->of_offset == of_offset)
if (dev_of_offset(parent) == of_offset)
return parent;
list_for_each_entry(dev, &parent->child_head, sibling_node) {
......@@ -637,19 +637,21 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
int len = 0;
int na, ns;
na = fdt_address_cells(gd->fdt_blob, dev->parent->of_offset);
na = fdt_address_cells(gd->fdt_blob,
dev_of_offset(dev->parent));
if (na < 1) {
debug("bad #address-cells\n");
return FDT_ADDR_T_NONE;
}
ns = fdt_size_cells(gd->fdt_blob, dev->parent->of_offset);
ns = fdt_size_cells(gd->fdt_blob, dev_of_offset(dev->parent));
if (ns < 0) {
debug("bad #size-cells\n");
return FDT_ADDR_T_NONE;
}
reg = fdt_getprop(gd->fdt_blob, dev->of_offset, "reg", &len);
reg = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "reg",
&len);
if (!reg || (len <= (index * sizeof(fdt32_t) * (na + ns)))) {
debug("Req index out of range\n");
return FDT_ADDR_T_NONE;
......@@ -662,16 +664,15 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
* bus setups.
*/
addr = fdt_translate_address((void *)gd->fdt_blob,
dev->of_offset, reg);
dev_of_offset(dev), reg);
} else {
/*
* Use the "simple" translate function for less complex
* bus setups.
*/
addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
dev->parent->of_offset,
dev->of_offset, "reg",
index, NULL, false);
dev_of_offset(dev->parent), dev_of_offset(dev),
"reg", index, NULL, false);
if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
if (device_get_uclass_id(dev->parent) ==
UCLASS_SIMPLE_BUS)
......@@ -702,7 +703,7 @@ fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
* next call to the exisiting dev_get_xxx function which handles
* all config options.
*/
fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset,
fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev_of_offset(dev),
"reg", index, size, false);
/*
......@@ -720,7 +721,7 @@ fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name)
#if CONFIG_IS_ENABLED(OF_CONTROL)
int index;
index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset,
index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
"reg-names", name);
if (index < 0)
return index;
......@@ -799,7 +800,7 @@ bool of_device_is_compatible(struct udevice *dev, const char *compat)
{
const void *fdt = gd->fdt_blob;
return !fdt_node_check_compatible(fdt, dev->of_offset, compat);
return !fdt_node_check_compatible(fdt, dev_of_offset(dev), compat);
}
bool of_machine_is_compatible(const char *compat)
......
......@@ -71,12 +71,12 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
int parent;
int len;
parent = dev->parent->of_offset;
parent = dev_of_offset(dev->parent);
addr_len = fdt_address_cells(blob, parent);
size_len = fdt_size_cells(blob, parent);
both_len = addr_len + size_len;
cell = fdt_getprop(blob, dev->of_offset, "reg", &len);
cell = fdt_getprop(blob, dev_of_offset(dev), "reg", &len);
len /= sizeof(*cell);
count = len / both_len;
if (!cell || !count)
......
......@@ -227,10 +227,10 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
int dm_scan_fdt_dev(struct udevice *dev)
{
if (dev->of_offset == -1)
if (dev_of_offset(dev) == -1)
return 0;
return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset,
return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev),
gd->flags & GD_FLG_RELOC ? false : true);
}
......
......@@ -30,7 +30,7 @@ static int simple_bus_post_bind(struct udevice *dev)
u32 cell[3];
int ret;
ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "ranges",
ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "ranges",
cell, ARRAY_SIZE(cell));
if (!ret) {
struct simple_bus_plat *plat = dev_get_uclass_platdata(dev);
......
......@@ -278,7 +278,7 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node,
return ret;
list_for_each_entry(dev, &uc->dev_head, uclass_node) {
if (dev->of_offset == node) {
if (dev_of_offset(dev) == node) {
*devp = dev;
return 0;
}
......@@ -299,7 +299,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id,
int ret;
*devp = NULL;
find_phandle = fdtdec_get_int(gd->fdt_blob, parent->of_offset, name,
find_phandle = fdtdec_get_int(gd->fdt_blob, dev_of_offset(parent), name,
-1);
if (find_phandle <= 0)
return -ENOENT;
......@@ -308,7 +308,9 @@ static int uclass_find_device_by_phandle(enum uclass_id id,
return ret;
list_for_each_entry(dev, &uc->dev_head, uclass_node) {
uint phandle = fdt_get_phandle(gd->fdt_blob, dev->of_offset);
uint phandle;
phandle = fdt_get_phandle(gd->fdt_blob, dev_of_offset(dev));
if (phandle == find_phandle) {
*devp = dev;
......
......@@ -151,7 +151,7 @@ static int shape_ofdata_to_platdata(struct udevice *dev)
return ret;
/* Parse the data that only we need */
pdata->default_char = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
pdata->default_char = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"character", '@');
return 0;
......
......@@ -66,7 +66,7 @@ int demo_set_light(struct udevice *dev, int light)
int demo_parse_dt(struct udevice *dev)
{
struct dm_demo_pdata *pdata = dev_get_platdata(dev);
int dn = dev->of_offset;
int dn = dev_of_offset(dev);
pdata->sides = fdtdec_get_int(gd->fdt_blob, dn, "sides", 0);
pdata->colour = fdt_getprop(gd->fdt_blob, dn, "colour", NULL);
......
......@@ -130,7 +130,7 @@ static int gen_74x164_probe(struct udevice *dev)
char *str, name[32];
int ret;
const void *fdt = gd->fdt_blob;
int node = dev->of_offset;
int node = dev_of_offset(dev);
snprintf(name, sizeof(name), "%s_", dev->name);
str = strdup(name);
......
......@@ -92,9 +92,9 @@ static int altera_pio_ofdata_to_platdata(struct udevice *dev)
plat->regs = map_physmem(dev_get_addr(dev),
sizeof(struct altera_pio_regs),
MAP_NOCACHE);
plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"altr,gpio-bank-width", 32);
plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
"gpio-bank-name", NULL);
return 0;
......
......@@ -276,7 +276,7 @@ static const struct dm_gpio_ops atmel_pio4_ops = {
static int atmel_pio4_bind(struct udevice *dev)
{
return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev), false);
}
static int atmel_pio4_probe(struct udevice *dev)
......@@ -308,7 +308,8 @@ static int atmel_pio4_probe(struct udevice *dev)
pioctrl_data = (struct atmel_pioctrl_data *)dev_get_driver_data(dev);
nbanks = pioctrl_data->nbanks;
uc_priv->bank_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL);
uc_priv->bank_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev),
NULL);
uc_priv->gpio_count = nbanks * ATMEL_PIO_NPINS_PER_BANK;
return 0;
......
......@@ -112,13 +112,13 @@ static int gpio_dwapb_bind(struct udevice *dev)
if (plat)
return 0;
base = fdtdec_get_addr(blob, dev->of_offset, "reg");
base = fdtdec_get_addr(blob, dev_of_offset(dev), "reg");
if (base == FDT_ADDR_T_NONE) {
debug("Can't get the GPIO register base address\n");
return -ENXIO;
}