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/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c b/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c
index ace1028..cb6e03f 100644
--- a/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c
+++ b/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c
@@ -392,7 +392,7 @@
 	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) {
diff --git a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
index be3d713..89fd8e6 100644
--- a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
@@ -1016,7 +1016,7 @@
 #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 */
diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index 4f0f8fc..c1caa65 100644
--- a/arch/nios2/cpu/cpu.c
+++ b/arch/nios2/cpu/cpu.c
@@ -103,7 +103,7 @@
 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);
diff --git a/arch/x86/cpu/broadwell/cpu.c b/arch/x86/cpu/broadwell/cpu.c
index 6977e86..1b71d56 100644
--- a/arch/x86/cpu/broadwell/cpu.c
+++ b/arch/x86/cpu/broadwell/cpu.c
@@ -256,8 +256,8 @@
 	/* 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 @@
 	}
 	/* 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 @@
 	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 */
diff --git a/arch/x86/cpu/broadwell/pch.c b/arch/x86/cpu/broadwell/pch.c
index 317f57d..16eac3d 100644
--- a/arch/x86/cpu/broadwell/pch.c
+++ b/arch/x86/cpu/broadwell/pch.c
@@ -190,14 +190,14 @@
 	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;
diff --git a/arch/x86/cpu/broadwell/pinctrl_broadwell.c b/arch/x86/cpu/broadwell/pinctrl_broadwell.c
index 2a3fced..881413f 100644
--- a/arch/x86/cpu/broadwell/pinctrl_broadwell.c
+++ b/arch/x86/cpu/broadwell/pinctrl_broadwell.c
@@ -51,7 +51,7 @@
 	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 @@
 	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;
diff --git a/arch/x86/cpu/broadwell/sata.c b/arch/x86/cpu/broadwell/sata.c
index 2e47082..10461d9 100644
--- a/arch/x86/cpu/broadwell/sata.c
+++ b/arch/x86/cpu/broadwell/sata.c
@@ -235,7 +235,7 @@
 {
 	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,
diff --git a/arch/x86/cpu/cpu_x86.c b/arch/x86/cpu/cpu_x86.c
index 157f3de..8be14b5 100644
--- a/arch/x86/cpu/cpu_x86.c
+++ b/arch/x86/cpu/cpu_x86.c
@@ -17,7 +17,7 @@
 	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);
diff --git a/arch/x86/cpu/intel_common/lpc.c b/arch/x86/cpu/intel_common/lpc.c
index 03cb45b..696b630 100644
--- a/arch/x86/cpu/intel_common/lpc.c
+++ b/arch/x86/cpu/intel_common/lpc.c
@@ -50,7 +50,7 @@
 	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)
diff --git a/arch/x86/cpu/intel_common/mrc.c b/arch/x86/cpu/intel_common/mrc.c
index 01b6e86..f1a249a 100644
--- a/arch/x86/cpu/intel_common/mrc.c
+++ b/arch/x86/cpu/intel_common/mrc.c
@@ -149,7 +149,7 @@
 	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);
diff --git a/arch/x86/cpu/irq.c b/arch/x86/cpu/irq.c
index d2901de..f5654eb 100644
--- a/arch/x86/cpu/irq.c
+++ b/arch/x86/cpu/irq.c
@@ -96,7 +96,7 @@
 	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);
diff --git a/arch/x86/cpu/ivybridge/lpc.c b/arch/x86/cpu/ivybridge/lpc.c
index aef1206..4e254b3 100644
--- a/arch/x86/cpu/ivybridge/lpc.c
+++ b/arch/x86/cpu/ivybridge/lpc.c
@@ -86,7 +86,7 @@
 {
 	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 @@
 	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_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;
diff --git a/arch/x86/cpu/ivybridge/model_206ax.c b/arch/x86/cpu/ivybridge/model_206ax.c
index d5f3219..81dedee 100644
--- a/arch/x86/cpu/ivybridge/model_206ax.c
+++ b/arch/x86/cpu/ivybridge/model_206ax.c
@@ -288,8 +288,8 @@
 	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);
diff --git a/arch/x86/cpu/ivybridge/sata.c b/arch/x86/cpu/ivybridge/sata.c
index c7ffbc1..0f5e190 100644
--- a/arch/x86/cpu/ivybridge/sata.c
+++ b/arch/x86/cpu/ivybridge/sata.c
@@ -39,7 +39,7 @@
 {
 	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_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;
diff --git a/arch/x86/cpu/mp_init.c b/arch/x86/cpu/mp_init.c
index 2b6b3bd..988073c 100644
--- a/arch/x86/cpu/mp_init.c
+++ b/arch/x86/cpu/mp_init.c
@@ -568,7 +568,8 @@
 	 * 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;
 
diff --git a/arch/x86/lib/mpspec.c b/arch/x86/lib/mpspec.c
index 17e977c..a6e493d 100644
--- a/arch/x86/lib/mpspec.c
+++ b/arch/x86/lib/mpspec.c
@@ -304,7 +304,8 @@
 	}
 
 	/* 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;
 
diff --git a/arch/x86/lib/pinctrl_ich6.c b/arch/x86/lib/pinctrl_ich6.c
index fb2d294..406852d 100644
--- a/arch/x86/lib/pinctrl_ich6.c
+++ b/arch/x86/lib/pinctrl_ich6.c
@@ -187,7 +187,7 @@
 		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 */
diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
index 1fa5664..818ae04 100644
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
@@ -44,7 +44,8 @@
 
 	/* 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 @@
 	}
 
 	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 @@
 		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;
diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt
index 1b5ccec..fea324e 100644
--- a/doc/driver-model/README.txt
+++ b/doc/driver-model/README.txt
@@ -684,7 +684,7 @@
 
    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,
diff --git a/doc/driver-model/of-plat.txt b/doc/driver-model/of-plat.txt
index 86e5e25..0063bfe 100644
--- a/doc/driver-model/of-plat.txt
+++ b/doc/driver-model/of-plat.txt
@@ -205,7 +205,7 @@
             /* 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
diff --git a/doc/driver-model/spi-howto.txt b/doc/driver-model/spi-howto.txt
index ee4abf4..1955ffe 100644
--- a/doc/driver-model/spi-howto.txt
+++ b/doc/driver-model/spi-howto.txt
@@ -223,7 +223,7 @@
 {
 	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);
diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c
index 9233fcd..3e28a56 100644
--- a/drivers/adc/adc-uclass.c
+++ b/drivers/adc/adc-uclass.c
@@ -345,7 +345,7 @@
 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_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;
 
diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c
index d36f64f..ac27d3e 100644
--- a/drivers/clk/at91/clk-generated.c
+++ b/drivers/clk/at91/clk-generated.c
@@ -154,9 +154,8 @@
 	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;
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 76ba91a..c73156a 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -47,7 +47,7 @@
 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 @@
 		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;
 
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 153ceba..6fcfd69 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -65,7 +65,7 @@
 	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 @@
 
 	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);
diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c
index 9c4d2b3..3911bf6 100644
--- a/drivers/clk/clk_fixed_rate.c
+++ b/drivers/clk/clk_fixed_rate.c
@@ -32,7 +32,7 @@
 {
 #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
 
diff --git a/drivers/clk/clk_pic32.c b/drivers/clk/clk_pic32.c
index 70ec354..f6eef31 100644
--- a/drivers/clk/clk_pic32.c
+++ b/drivers/clk/clk_pic32.c
@@ -330,7 +330,7 @@
 	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 @@
 	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;
 
diff --git a/drivers/core/device.c b/drivers/core/device.c
index ed553d7..70fcfc2 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -355,7 +355,7 @@
 			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 @@
 	*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 @@
 {
 	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 @@
 		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 @@
 		 * 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 @@
 	 * 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 @@
 #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 @@
 {
 	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)
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index c68bcba..833cd78 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -71,12 +71,12 @@
 	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)
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 9edfc1e..175fd3f 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -227,10 +227,10 @@
 
 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);
 }
 
diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c
index 5c955da..6be269f 100644
--- a/drivers/core/simple-bus.c
+++ b/drivers/core/simple-bus.c
@@ -30,7 +30,7 @@
 	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);
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 60610e5..7de3706 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -278,7 +278,7 @@
 		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 @@
 	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 @@
 		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;
diff --git a/drivers/demo/demo-shape.c b/drivers/demo/demo-shape.c
index d908736..7e71f3b 100644
--- a/drivers/demo/demo-shape.c
+++ b/drivers/demo/demo-shape.c
@@ -151,7 +151,7 @@
 		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;
diff --git a/drivers/demo/demo-uclass.c b/drivers/demo/demo-uclass.c
index 725f068..3341572 100644
--- a/drivers/demo/demo-uclass.c
+++ b/drivers/demo/demo-uclass.c
@@ -66,7 +66,7 @@
 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);
diff --git a/drivers/gpio/74x164_gpio.c b/drivers/gpio/74x164_gpio.c
index 9ac10a7..750eedf 100644
--- a/drivers/gpio/74x164_gpio.c
+++ b/drivers/gpio/74x164_gpio.c
@@ -130,7 +130,7 @@
 	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);
diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c
index 6f42bf8..92849c5 100644
--- a/drivers/gpio/altera_pio.c
+++ b/drivers/gpio/altera_pio.c
@@ -92,9 +92,9 @@
 	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;
diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c
index cb90b02..81c3047 100644
--- a/drivers/gpio/atmel_pio4.c
+++ b/drivers/gpio/atmel_pio4.c
@@ -276,7 +276,7 @@
 
 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 @@
 	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;
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 85e0a86..7d1904c 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -112,13 +112,13 @@
 	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;
 	}
 
-	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)) {
 		if (!fdtdec_get_bool(blob, node, "gpio-controller"))
@@ -142,7 +142,7 @@
 		if (ret)
 			goto err;
 
-		subdev->of_offset = node;
+		dev_set_of_offset(subdev, node);
 		bank++;
 	}
 
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 4559739..9ab9df4 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -707,7 +707,7 @@
 	 * calls in gpio_request_by_name(), but we can do this until
 	 * gpio_request_by_name_nodev() can be dropped.
 	 */
-	return gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset,
+	return gpio_request_by_name_nodev(gd->fdt_blob, dev_of_offset(dev),
 					  list_name, index, desc, flags);
 }
 
@@ -746,7 +746,7 @@
 	 * calls in gpio_request_by_name(), but we can do this until
 	 * gpio_request_list_by_name_nodev() can be dropped.
 	 */
-	return gpio_request_list_by_name_nodev(gd->fdt_blob, dev->of_offset,
+	return gpio_request_list_by_name_nodev(gd->fdt_blob, dev_of_offset(dev),
 					       list_name, desc, max_count,
 					       flags);
 }
@@ -755,7 +755,7 @@
 {
 	int ret;
 
-	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),
 					     list_name, "#gpio-cells", 0, -1,
 					     NULL);
 	if (ret) {
diff --git a/drivers/gpio/intel_broadwell_gpio.c b/drivers/gpio/intel_broadwell_gpio.c
index 81ce446..790577a 100644
--- a/drivers/gpio/intel_broadwell_gpio.c
+++ b/drivers/gpio/intel_broadwell_gpio.c
@@ -149,14 +149,14 @@
 	if (ret)
 		return ret;
 
-	bank = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+	bank = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
 	if (bank == -1) {
 		debug("%s: Invalid bank number %d\n", __func__, bank);
 		return -EINVAL;
 	}
 	plat->bank = bank;
 	plat->base_addr = gpiobase;
-	plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 				      "bank-name", NULL);
 
 	return 0;
diff --git a/drivers/gpio/intel_ich6_gpio.c b/drivers/gpio/intel_ich6_gpio.c
index fd6181f..8b78226 100644
--- a/drivers/gpio/intel_ich6_gpio.c
+++ b/drivers/gpio/intel_ich6_gpio.c
@@ -94,14 +94,14 @@
 	if (ret)
 		return ret;
 
-	offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+	offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
 	if (offset == -1) {
 		debug("%s: Invalid register offset %d\n", __func__, offset);
 		return -EINVAL;
 	}
 	plat->offset = offset;
 	plat->base_addr = gpiobase + offset;
-	plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 				      "bank-name", NULL);
 
 	return 0;
diff --git a/drivers/gpio/lpc32xx_gpio.c b/drivers/gpio/lpc32xx_gpio.c
index 9674ee7..1bf945a 100644
--- a/drivers/gpio/lpc32xx_gpio.c
+++ b/drivers/gpio/lpc32xx_gpio.c
@@ -297,7 +297,7 @@
 	struct lpc32xx_gpio_priv *gpio_priv = dev_get_priv(dev);
 	struct gpio_dev_priv *uc_priv = dev->uclass_priv;
 
-	if (dev->of_offset == -1) {
+	if (dev_of_offset(dev) == -1) {
 		/* Tell the uclass how many GPIOs we have */
 		uc_priv->gpio_count = LPC32XX_GPIOS;
 	}
diff --git a/drivers/gpio/mpc85xx_gpio.c b/drivers/gpio/mpc85xx_gpio.c
index 168c696..cfeb6e7 100644
--- a/drivers/gpio/mpc85xx_gpio.c
+++ b/drivers/gpio/mpc85xx_gpio.c
@@ -169,13 +169,13 @@
 	fdt_addr_t addr;
 	fdt_size_t size;
 
-	addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset,
-						  "reg", 0, &size, false);
+	addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob,
+			dev_of_offset(dev), "reg", 0, &size, false);
 
 	plat->addr = addr;
 	plat->size = size;
-	plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-						  "ngpios", 32);
+	plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+				      "ngpios", 32);
 
 	return 0;
 }
diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c
index 0302979..01ce1d6 100644
--- a/drivers/gpio/msm_gpio.c
+++ b/drivers/gpio/msm_gpio.c
@@ -106,9 +106,9 @@
 {
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-	uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					     "gpio-count", 0);
-	uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 					 "gpio-bank-name", NULL);
 	if (uc_priv->bank_name == NULL)
 		uc_priv->bank_name = "soc";
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index f906b97..5338552 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -320,7 +320,7 @@
 		return -ENOMEM;
 
 	plat->base = base_addr;
-	plat->port_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL);
+	plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
 	dev->platdata = plat;
 
 	return 0;
diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c
index 0410add..b81f0fa 100644
--- a/drivers/gpio/pca953x_gpio.c
+++ b/drivers/gpio/pca953x_gpio.c
@@ -265,7 +265,7 @@
 		return -ENODEV;
 	}
 
-	addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", 0);
+	addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
 	if (addr == 0)
 		return -ENODEV;
 
diff --git a/drivers/gpio/pcf8575_gpio.c b/drivers/gpio/pcf8575_gpio.c
index 2bda0ff..2cbb9e6 100644
--- a/drivers/gpio/pcf8575_gpio.c
+++ b/drivers/gpio/pcf8575_gpio.c
@@ -131,15 +131,15 @@
 
 	int n_latch;
 
-	uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					     "gpio-count", 16);
-	uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 					 "gpio-bank-name", NULL);
 	if (!uc_priv->bank_name)
 		uc_priv->bank_name = fdt_get_name(gd->fdt_blob,
-						  dev->of_offset, NULL);
+						  dev_of_offset(dev), NULL);
 
-	n_latch = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	n_latch = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 				  "lines-initial-states", 0);
 	plat->out = ~n_latch;
 
diff --git a/drivers/gpio/pic32_gpio.c b/drivers/gpio/pic32_gpio.c
index 7a037f3..e838ad4 100644
--- a/drivers/gpio/pic32_gpio.c
+++ b/drivers/gpio/pic32_gpio.c
@@ -133,7 +133,8 @@
 	char *end;
 	int bank;
 
-	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/gpio/pm8916_gpio.c b/drivers/gpio/pm8916_gpio.c
index 0b61975..e38cee8 100644
--- a/drivers/gpio/pm8916_gpio.c
+++ b/drivers/gpio/pm8916_gpio.c
@@ -193,9 +193,9 @@
 {
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-	uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					     "gpio-count", 0);
-	uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 					 "gpio-bank-name", NULL);
 	if (uc_priv->bank_name == NULL)
 		uc_priv->bank_name = "pm8916";
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
index 377fed4..042996e 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -317,7 +317,7 @@
 		return 0;
 
 	base = (struct s5p_gpio_bank *)dev_get_addr(parent);
-	for (node = fdt_first_subnode(blob, parent->of_offset), bank = base;
+	for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base;
 	     node > 0;
 	     node = fdt_next_subnode(blob, node), bank++) {
 		struct exynos_gpio_platdata *plat;
@@ -337,7 +337,7 @@
 		if (ret)
 			return ret;
 
-		dev->of_offset = node;
+		dev_set_of_offset(dev, node);
 
 		reg = dev_get_addr(dev);
 		if (reg != FDT_ADDR_T_NONE)
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index f6435a0..ae6d930 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -197,9 +197,9 @@
 {
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-	uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					     "num-gpios", 0);
-	uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 					 "gpio-bank-name", NULL);
 
 	return 0;
@@ -209,7 +209,7 @@
 {
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-	if (dev->of_offset == -1) {
+	if (dev_of_offset(dev) == -1) {
 		/* Tell the uclass how many GPIOs we have */
 		uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT;
 	}
diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index e8accaa..8d2bb18 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -312,7 +312,7 @@
 					plat->bank_name, plat, -1, &dev);
 		if (ret)
 			return ret;
-		dev->of_offset = parent->of_offset;
+		dev_set_of_offset(dev, dev_of_offset(parent));
 	}
 
 	return 0;
diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c
index 1c68151..b0c22e5 100644
--- a/drivers/gpio/tegra186_gpio.c
+++ b/drivers/gpio/tegra186_gpio.c
@@ -197,7 +197,7 @@
 				  -1, &dev);
 		if (ret)
 			return ret;
-		dev->of_offset = parent->of_offset;
+		dev_set_of_offset(dev, dev_of_offset(parent));
 	}
 
 	return 0;
diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c
index 5a03115..b01968a 100644
--- a/drivers/gpio/tegra_gpio.c
+++ b/drivers/gpio/tegra_gpio.c
@@ -337,7 +337,8 @@
 	 * This driver does not make use of interrupts, other than to figure
 	 * out the number of GPIO banks
 	 */
-	if (!fdt_getprop(gd->fdt_blob, parent->of_offset, "interrupts", &len))
+	if (!fdt_getprop(gd->fdt_blob, dev_of_offset(parent), "interrupts",
+			 &len))
 		return -EINVAL;
 	bank_count = len / 3 / sizeof(u32);
 	ctlr = (struct gpio_ctlr *)dev_get_addr(parent);
@@ -363,7 +364,7 @@
 					  plat->port_name, plat, -1, &dev);
 			if (ret)
 				return ret;
-			dev->of_offset = parent->of_offset;
+			dev_set_of_offset(dev, dev_of_offset(parent));
 		}
 	}
 
diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c
index a30ba5d..458104e 100644
--- a/drivers/gpio/vybrid_gpio.c
+++ b/drivers/gpio/vybrid_gpio.c
@@ -129,7 +129,7 @@
 
 	plat->base = base_addr;
 	plat->chip = dev->req_seq;
-	plat->port_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL);
+	plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
 	dev->platdata = plat;
 
 	return 0;
diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c
index 4bc54ee..5a63669 100644
--- a/drivers/i2c/at91_i2c.c
+++ b/drivers/i2c/at91_i2c.c
@@ -242,7 +242,7 @@
 {
 	const void *blob = gd->fdt_blob;
 	struct at91_i2c_bus *bus = dev_get_priv(dev);
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 
 	bus->regs = (struct at91_i2c_regs *)dev_get_addr(dev);
 	bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev);
diff --git a/drivers/i2c/cros_ec_tunnel.c b/drivers/i2c/cros_ec_tunnel.c
index 9cf8e7d..86fa684 100644
--- a/drivers/i2c/cros_ec_tunnel.c
+++ b/drivers/i2c/cros_ec_tunnel.c
@@ -34,7 +34,7 @@
 {
 	struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 
 	i2c_bus->remote_bus = fdtdec_get_uint(blob, node, "google,remote-bus",
 					      0);
diff --git a/drivers/i2c/exynos_hs_i2c.c b/drivers/i2c/exynos_hs_i2c.c
index 9521aeb..2dd75fd 100644
--- a/drivers/i2c/exynos_hs_i2c.c
+++ b/drivers/i2c/exynos_hs_i2c.c
@@ -522,7 +522,7 @@
 	struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
 	int node;
 
-	node = dev->of_offset;
+	node = dev_of_offset(dev);
 
 	i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr(dev);
 
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index c3f826d..e9fbf82 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -585,21 +585,21 @@
 	struct fsl_i2c_dev *dev = dev_get_priv(bus);
 	fdt_addr_t addr;
 	fdt_size_t size;
+	int node = dev_of_offset(bus);
 
-	addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, bus->of_offset,
-						  "reg", 0, &size, false);
+	addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg", 0,
+						  &size, false);
 
 	dev->base = map_sysmem(CONFIG_SYS_IMMR + addr, size);
 
 	if (!dev->base)
 		return -ENOMEM;
 
-	dev->index = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
-				    "cell-index", -1);
-	dev->slaveadd = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+	dev->index = fdtdec_get_int(gd->fdt_blob, node, "cell-index", -1);
+	dev->slaveadd = fdtdec_get_int(gd->fdt_blob, node,
 				       "u-boot,i2c-slave-addr", 0x7f);
-	dev->speed = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
-				    "clock-frequency", 400000);
+	dev->speed = fdtdec_get_int(gd->fdt_blob, node, "clock-frequency",
+				    400000);
 
 	dev->i2c_clk = dev->index ? gd->arch.i2c2_clk : gd->arch.i2c1_clk;
 
diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index a8b83c5..aeeb304 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -309,7 +309,7 @@
 {
 	struct i2c_gpio_bus *bus = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	ret = gpio_request_list_by_name(dev, "gpios", bus->gpios,
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index dbd3789..f3184c7 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -489,7 +489,7 @@
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 	struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
 
-	i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 				     "clock-frequency", 100000);
 
 	return dm_i2c_set_bus_speed(dev, i2c->speed_hz);
@@ -503,10 +503,11 @@
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 	struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
 
-	if (dev->of_offset == -1)
+	if (dev_of_offset(dev) == -1)
 		return 0;
 
-	return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat);
+	return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev),
+					   plat);
 #else
 	return 0;
 #endif
diff --git a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
index 3f072c7..66ce7ec 100644
--- a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
+++ b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
@@ -89,7 +89,7 @@
 {
 	struct i2c_arbitrator_priv *priv = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	debug("%s: %s\n", __func__, dev->name);
diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c
index db086ef..d243b8e 100644
--- a/drivers/i2c/muxes/i2c-mux-uclass.c
+++ b/drivers/i2c/muxes/i2c-mux-uclass.c
@@ -40,7 +40,7 @@
 	struct i2c_mux_bus *plat = dev_get_parent_platdata(dev);
 	int channel;
 
-	channel = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+	channel = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
 	if (channel < 0)
 		return -EINVAL;
 	plat->channel = channel;
@@ -60,7 +60,7 @@
 	 * There is no compatible string in the sub-nodes, so we must manually
 	 * bind these
 	 */
-	for (offset = fdt_first_subnode(blob, mux->of_offset);
+	for (offset = fdt_first_subnode(blob, dev_of_offset(mux));
 	     offset > 0;
 	     offset = fdt_next_subnode(blob, offset)) {
 		struct udevice *dev;
diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
index 7e0d2da..1a67618 100644
--- a/drivers/i2c/muxes/pca954x.c
+++ b/drivers/i2c/muxes/pca954x.c
@@ -51,7 +51,7 @@
 {
 	struct pca954x_priv *priv = dev_get_priv(dev);
 
-	priv->addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", 0);
+	priv->addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
 	if (!priv->addr) {
 		debug("MUX not found\n");
 		return -ENODEV;
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index cea3da0..648a96e 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -775,11 +775,11 @@
 	if (!dev->base)
 		return -ENOMEM;
 
-	dev->index = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+	dev->index = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
 				    "cell-index", -1);
-	dev->slaveadd = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+	dev->slaveadd = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
 				       "u-boot,i2c-slave-addr", 0x0);
-	dev->speed = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+	dev->speed = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
 				    "clock-frequency", 100000);
 	return 0;
 }
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 94d9027..eb789f5 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -750,7 +750,7 @@
 {
 	struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus);
 	const void *fdt = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 	fdt_addr_t addr;
 	int ret, ret2;
 
diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index 363cd04..3c69dbf 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -312,7 +312,7 @@
 	struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
 	int node;
 
-	node = dev->of_offset;
+	node = dev_of_offset(dev);
 
 	i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev);
 
diff --git a/drivers/i2c/tegra186_bpmp_i2c.c b/drivers/i2c/tegra186_bpmp_i2c.c
index 513c414..931c6de 100644
--- a/drivers/i2c/tegra186_bpmp_i2c.c
+++ b/drivers/i2c/tegra186_bpmp_i2c.c
@@ -90,7 +90,7 @@
 {
 	struct tegra186_bpmp_i2c *priv = dev_get_priv(dev);
 
-	priv->bpmp_bus_id = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	priv->bpmp_bus_id = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 					    "nvidia,bpmp-bus-id", U32_MAX);
 	if (priv->bpmp_bus_id == U32_MAX) {
 		debug("%s: could not parse nvidia,bpmp-bus-id\n", __func__);
diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
index 9bc4555..00381dc 100644
--- a/drivers/input/cros_ec_keyb.c
+++ b/drivers/input/cros_ec_keyb.c
@@ -189,7 +189,7 @@
 	struct stdio_dev *sdev = &uc_priv->sdev;
 	struct input_config *input = &uc_priv->input;
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	if (cros_ec_keyb_decode_fdt(blob, node, priv))
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 03d4840..0fd25b1 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -315,7 +315,7 @@
 	struct input_config *input = &uc_priv->input;
 	int ret;
 
-	if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+	if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
 			    "intel,duplicate-por"))
 		priv->quirks |= QUIRK_DUP_POR;
 
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index c77f610..d36f1a1 100644
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -290,7 +290,7 @@
 	struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
 	struct stdio_dev *sdev = &uc_priv->sdev;
 	struct input_config *input = &uc_priv->input;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	priv->kbc = (struct kbc_tegra *)dev_get_addr(dev);
diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
index cb6e996..5b11990 100644
--- a/drivers/led/led_gpio.c
+++ b/drivers/led/led_gpio.c
@@ -62,7 +62,7 @@
 	int node;
 	int ret;
 
-	for (node = fdt_first_subnode(blob, parent->of_offset);
+	for (node = fdt_first_subnode(blob, dev_of_offset(parent));
 	     node > 0;
 	     node = fdt_next_subnode(blob, node)) {
 		struct led_uclass_plat *uc_plat;
diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c
index a7fcde5..38448de 100644
--- a/drivers/mailbox/mailbox-uclass.c
+++ b/drivers/mailbox/mailbox-uclass.c
@@ -41,7 +41,7 @@
 
 	debug("%s(dev=%p, index=%d, chan=%p)\n", __func__, dev, index, chan);
 
-	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),
 					     "mboxes", "#mbox-cells", 0,
 					     index, &args);
 	if (ret) {
@@ -85,7 +85,7 @@
 
 	debug("%s(dev=%p, name=%s, chan=%p)\n", __func__, dev, name, chan);
 
-	index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset,
+	index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
 				      "mbox-names", name);
 	if (index < 0) {
 		debug("fdt_stringlist_search() failed: %d\n", index);
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 759bb46..3d449b2 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -998,7 +998,7 @@
 {
 	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	char id[MSG_BYTES];
 
 	cdev->dev = dev;
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index c4fbca0..848c67b 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -522,7 +522,7 @@
 	int err;
 
 	memcpy(ec, &s_state, sizeof(*ec));
-	err = cros_ec_decode_ec_flash(blob, dev->of_offset, &ec->ec_config);
+	err = cros_ec_decode_ec_flash(blob, dev_of_offset(dev), &ec->ec_config);
 	if (err)
 		return err;
 
@@ -531,7 +531,7 @@
 	     keyb_dev;
 	     device_find_next_child(&keyb_dev)) {
 		if (device_get_uclass_id(keyb_dev) == UCLASS_KEYBOARD) {
-			node = keyb_dev->of_offset;
+			node = dev_of_offset(keyb_dev);
 			break;
 		}
 	}
diff --git a/drivers/misc/i2c_eeprom_emul.c b/drivers/misc/i2c_eeprom_emul.c
index 4410d03..02de8d7 100644
--- a/drivers/misc/i2c_eeprom_emul.c
+++ b/drivers/misc/i2c_eeprom_emul.c
@@ -115,9 +115,9 @@
 {
 	struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev);
 
-	plat->size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	plat->size = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 				    "sandbox,size", 32);
-	plat->filename = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	plat->filename = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 				     "sandbox,filename", NULL);
 	if (!plat->filename) {
 		debug("%s: No filename for device '%s'\n", __func__,
diff --git a/drivers/misc/tegra186_bpmp.c b/drivers/misc/tegra186_bpmp.c
index f4ddbea3..bd8b960 100644
--- a/drivers/misc/tegra186_bpmp.c
+++ b/drivers/misc/tegra186_bpmp.c
@@ -112,19 +112,19 @@
 	debug("%s(dev=%p)\n", __func__, dev);
 
 	ret = device_bind_driver_to_node(dev, "tegra186_clk", "tegra186_clk",
-					 dev->of_offset, &child);
+					 dev_of_offset(dev), &child);
 	if (ret)
 		return ret;
 
 	ret = device_bind_driver_to_node(dev, "tegra186_reset",
-					 "tegra186_reset", dev->of_offset,
+					 "tegra186_reset", dev_of_offset(dev),
 					 &child);
 	if (ret)
 		return ret;
 
 	ret = device_bind_driver_to_node(dev, "tegra186_power_domain",
 					 "tegra186_power_domain",
-					 dev->of_offset, &child);
+					 dev_of_offset(dev), &child);
 	if (ret)
 		return ret;
 
@@ -141,7 +141,7 @@
 	struct fdtdec_phandle_args args;
 	fdt_addr_t reg;
 
-	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),
 					      "shmem", NULL, 0, index, &args);
 	if (ret < 0) {
 		error("fdtdec_parse_phandle_with_args() failed: %d\n", ret);
diff --git a/drivers/misc/tegra_car.c b/drivers/misc/tegra_car.c
index 0eb0096..5db3c37 100644
--- a/drivers/misc/tegra_car.c
+++ b/drivers/misc/tegra_car.c
@@ -22,12 +22,12 @@
 	debug("%s(dev=%p)\n", __func__, dev);
 
 	ret = device_bind_driver_to_node(dev, "tegra_car_clk", "tegra_car_clk",
-					 dev->of_offset, &child);
+					 dev_of_offset(dev), &child);
 	if (ret)
 		return ret;
 
 	ret = device_bind_driver_to_node(dev, "tegra_car_reset",
-					 "tegra_car_reset", dev->of_offset,
+					 "tegra_car_reset", dev_of_offset(dev),
 					 &child);
 	if (ret)
 		return ret;
diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
index 62cb242..8522557 100644
--- a/drivers/mmc/atmel_sdhci.c
+++ b/drivers/mmc/atmel_sdhci.c
@@ -75,7 +75,7 @@
 	host->ioaddr = (void *)dev_get_addr(dev);
 
 	host->quirks = 0;
-	host->bus_width	= fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	host->bus_width	= fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					 "bus-width", 4);
 
 	caps = sdhci_readl(host, SDHCI_CAPABILITIES);
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
index c440399..40f7892 100644
--- a/drivers/mmc/exynos_dw_mmc.c
+++ b/drivers/mmc/exynos_dw_mmc.c
@@ -264,7 +264,7 @@
 	struct dwmci_host *host = &priv->host;
 	int err;
 
-	err = exynos_dwmci_get_config(gd->fdt_blob, dev->of_offset, host);
+	err = exynos_dwmci_get_config(gd->fdt_blob, dev_of_offset(dev), host);
 	if (err)
 		return err;
 	err = do_dwmci_init(host);
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 73473c5..adeb5df 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -954,7 +954,7 @@
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
 	struct fsl_esdhc_priv *priv = dev_get_priv(dev);
 	const void *fdt = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	fdt_addr_t addr;
 	unsigned int val;
 	int ret;
diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
index 1db683d..7a7e67f 100644
--- a/drivers/mmc/msm_sdhci.c
+++ b/drivers/mmc/msm_sdhci.c
@@ -50,16 +50,16 @@
 
 static int msm_sdc_clk_init(struct udevice *dev)
 {
-	uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
-					"clock-frequency", 400000);
+	int node = dev_of_offset(dev);
+	uint clk_rate = fdtdec_get_uint(gd->fdt_blob, node, "clock-frequency",
+					400000);
 	uint clkd[2]; /* clk_id and clk_no */
 	int clk_offset;
 	struct udevice *clk_dev;
 	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, node, "clock", clkd, 2);
 	if (ret)
 		return ret;
 
@@ -168,17 +168,14 @@
 	struct udevice *parent = dev->parent;
 	struct msm_sdhc *priv = dev_get_priv(dev);
 	struct sdhci_host *host = &priv->host;
+	int node = dev_of_offset(dev);
 
 	host->name = strdup(dev->name);
 	host->ioaddr = (void *)dev_get_addr(dev);
-	host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-					 "bus-width", 4);
-	host->index = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "index", 0);
+	host->bus_width = fdtdec_get_int(gd->fdt_blob, node, "bus-width", 4);
+	host->index = fdtdec_get_uint(gd->fdt_blob, node, "index", 0);
 	priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-							      parent->of_offset,
-							      dev->of_offset,
-							      "reg", 1, NULL,
-							      false);
+			dev_of_offset(parent), node, "reg", 1, NULL, false);
 	if (priv->base == (void *)FDT_ADDR_T_NONE ||
 	    host->ioaddr == (void *)FDT_ADDR_T_NONE)
 		return -EINVAL;
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index b326846..5bb628d 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -728,7 +728,7 @@
 {
 	struct omap_hsmmc_data *priv = dev_get_priv(dev);
 	const void *fdt = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	struct mmc_config *cfg;
 	int val;
 
diff --git a/drivers/mmc/pic32_sdhci.c b/drivers/mmc/pic32_sdhci.c
index 1e14fa1..9d8a392 100644
--- a/drivers/mmc/pic32_sdhci.c
+++ b/drivers/mmc/pic32_sdhci.c
@@ -38,18 +38,18 @@
 	fdt_size_t size;
 	int ret;
 
-	addr = fdtdec_get_addr_size(fdt, dev->of_offset, "reg", &size);
+	addr = fdtdec_get_addr_size(fdt, dev_of_offset(dev), "reg", &size);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
 	host->ioaddr	= ioremap(addr, size);
 	host->name	= dev->name;
 	host->quirks	= SDHCI_QUIRK_NO_HISPD_BIT;
-	host->bus_width	= fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	host->bus_width	= fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					"bus-width", 4);
 	host->ops = &pic32_sdhci_ops;
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
 				   "clock-freq-min-max", f_min_max, 2);
 	if (ret) {
 		printf("sdhci: clock-freq-min-max not found\n");
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 47db678..c36eda0 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -59,24 +59,24 @@
 
 	host->name = dev->name;
 	host->ioaddr = (void *)dev_get_addr(dev);
-	host->buswidth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					"bus-width", 4);
 	host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk;
 	host->priv = dev;
 
 	/* use non-removeable as sdcard and emmc as judgement */
-	if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "non-removable"))
+	if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "non-removable"))
 		host->dev_index = 0;
 	else
 		host->dev_index = 1;
 
-	priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 				    "fifo-depth", 0);
 	if (priv->fifo_depth < 0)
 		return -EINVAL;
-	priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+	priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
 					  "fifo-mode");
-	if (fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+	if (fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
 				 "clock-freq-min-max", priv->minmax, 2))
 		return -EINVAL;
 #endif
diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index 1358864..bd91f91 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -38,7 +38,7 @@
 	struct clk clk;
 
 
-	max_frequency = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	max_frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 			"max-frequency", 0);
 	ret = clk_get_by_index(dev, 0, &clk);
 	if (!ret) {
diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
index 28327d5..640ea02 100644
--- a/drivers/mmc/s5p_sdhci.c
+++ b/drivers/mmc/s5p_sdhci.c
@@ -247,7 +247,7 @@
 	struct sdhci_host *host = dev_get_priv(dev);
 	int ret;
 
-	ret = sdhci_get_config(gd->fdt_blob, dev->of_offset, host);
+	ret = sdhci_get_config(gd->fdt_blob, dev_of_offset(dev), host);
 	if (ret)
 		return ret;
 
diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c
index 0a22e58..d0c3c51 100644
--- a/drivers/mmc/socfpga_dw_mmc.c
+++ b/drivers/mmc/socfpga_dw_mmc.c
@@ -70,7 +70,7 @@
 		return -EINVAL;
 	}
 
-	fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	fifo_depth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 				    "fifo-depth", 0);
 	if (fifo_depth < 0) {
 		printf("DWMMC: Can't get FIFO depth\n");
@@ -79,7 +79,7 @@
 
 	host->name = dev->name;
 	host->ioaddr = (void *)dev_get_addr(dev);
-	host->buswidth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					"bus-width", 4);
 	host->clksel = socfpga_dwmci_clksel;
 
@@ -92,9 +92,9 @@
 	host->bus_hz = clk;
 	host->fifoth_val = MSIZE(0x2) |
 		RX_WMARK(fifo_depth / 2 - 1) | TX_WMARK(fifo_depth / 2);
-	priv->drvsel = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	priv->drvsel = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 				       "drvsel", 3);
-	priv->smplsel = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	priv->smplsel = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 					"smplsel", 0);
 	host->priv = priv;
 
diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c
index 0211dc7..0df74ef 100644
--- a/drivers/mmc/tegra_mmc.c
+++ b/drivers/mmc/tegra_mmc.c
@@ -578,8 +578,8 @@
 	priv->cfg.name = "Tegra SD/MMC";
 	priv->cfg.ops = &tegra_mmc_ops;
 
-	bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width",
-				   1);
+	bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+				   "bus-width", 1);
 
 	priv->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
 	priv->cfg.host_caps = 0;
diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
index 4af7fdb..7f20ef1 100644
--- a/drivers/mmc/uniphier-sd.c
+++ b/drivers/mmc/uniphier-sd.c
@@ -705,7 +705,8 @@
 	plat->cfg.name = dev->name;
 	plat->cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
-	switch (fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", 1)) {
+	switch (fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width",
+			       1)) {
 	case 8:
 		plat->cfg.host_caps |= MMC_MODE_8BIT;
 		break;
@@ -719,7 +720,7 @@
 		return -EINVAL;
 	}
 
-	if (fdt_get_property(gd->fdt_blob, dev->of_offset, "non-removable",
+	if (fdt_get_property(gd->fdt_blob, dev_of_offset(dev), "non-removable",
 			     NULL))
 		priv->caps |= UNIPHIER_SD_CAP_NONREMOVABLE;
 
diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c
index 828da11..f678110 100644
--- a/drivers/mmc/xenon_sdhci.c
+++ b/drivers/mmc/xenon_sdhci.c
@@ -405,7 +405,8 @@
 		armada_3700_soc_pad_voltage_set(host);
 
 	host->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_DDR_52MHz;
-	switch (fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", 1)) {
+	switch (fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width",
+		1)) {
 	case 8:
 		host->host_caps |= MMC_MODE_8BIT;
 		break;
@@ -455,7 +456,7 @@
 	if (of_device_is_compatible(dev, "marvell,armada-3700-sdhci"))
 		priv->pad_ctrl_reg = (void *)dev_get_addr_index(dev, 1);
 
-	name = fdt_getprop(gd->fdt_blob, dev->of_offset, "marvell,pad-type",
+	name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "marvell,pad-type",
 			   NULL);
 	if (name) {
 		if (0 == strncmp(name, "sd", 2)) {
diff --git a/drivers/mtd/altera_qspi.c b/drivers/mtd/altera_qspi.c
index a9148a7..e04964b 100644
--- a/drivers/mtd/altera_qspi.c
+++ b/drivers/mtd/altera_qspi.c
@@ -349,7 +349,7 @@
 {
 	struct altera_qspi_platdata *pdata = dev_get_platdata(dev);
 	void *blob = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const char *list, *end;
 	const fdt32_t *cell;
 	void *base;
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index e036b88..d440f5c 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -2441,7 +2441,7 @@
 static int cfi_flash_probe(struct udevice *dev)
 {
 	void *blob = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const fdt32_t *cell;
 	phys_addr_t addr;
 	int parent, addrc, sizec;
diff --git a/drivers/mtd/pic32_flash.c b/drivers/mtd/pic32_flash.c
index 9166fcd..8ed7874 100644
--- a/drivers/mtd/pic32_flash.c
+++ b/drivers/mtd/pic32_flash.c
@@ -371,7 +371,7 @@
 static int pic32_flash_probe(struct udevice *dev)
 {
 	void *blob = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const char *list, *end;
 	const fdt32_t *cell;
 	unsigned long addr, size;
diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c
index 4944059..36a50fe 100644
--- a/drivers/mtd/spi/sandbox.c
+++ b/drivers/mtd/spi/sandbox.c
@@ -516,7 +516,7 @@
 {
 	struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 
 	pdata->filename = fdt_getprop(blob, node, "sandbox,filename", NULL);
 	pdata->device_name = fdt_getprop(blob, node, "compatible", NULL);
@@ -641,7 +641,7 @@
 		debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ",
 		      __func__, busnum, cs);
 		ret = sandbox_sf_bind_emul(state, busnum, cs, bus,
-					   slave->of_offset, slave->name);
+					   dev_of_offset(slave), slave->name);
 		if (ret) {
 			debug("failed (err=%d)\n", ret);
 			return ret;
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 2e378dc..ab7910b 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -919,7 +919,7 @@
 #ifdef CONFIG_DM_SPI_FLASH
 	fdt_addr_t addr;
 	fdt_size_t size;
-	int node = flash->dev->of_offset;
+	int node = dev_of_offset(flash->dev);
 
 	addr = fdtdec_get_addr_size(blob, node, "memory-map", &size);
 	if (addr == FDT_ADDR_T_NONE) {
diff --git a/drivers/net/ag7xxx.c b/drivers/net/ag7xxx.c
index 346f138..f8782bc 100644
--- a/drivers/net/ag7xxx.c
+++ b/drivers/net/ag7xxx.c
@@ -857,7 +857,7 @@
 {
 	int offset;
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, "phy");
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "phy");
 	if (offset <= 0) {
 		debug("%s: PHY OF node not found (ret=%i)\n", __func__, offset);
 		return -EINVAL;
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index 92a1b64..d4d17dd 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -576,7 +576,7 @@
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct altera_tse_priv *priv = dev_get_priv(dev);
 	void *blob = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const char *list, *end;
 	const fdt32_t *cell;
 	void *base, *desc_mem = NULL;
@@ -676,7 +676,8 @@
 	const char *phy_mode;
 
 	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+			       NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
 	if (pdata->phy_interface == -1) {
diff --git a/drivers/net/cpsw-common.c b/drivers/net/cpsw-common.c
index e828e85..aa52503 100644
--- a/drivers/net/cpsw-common.c
+++ b/drivers/net/cpsw-common.c
@@ -20,7 +20,7 @@
 				       int slave, u8 *mac_addr)
 {
 	void *fdt = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	u32 macid_lsb;
 	u32 macid_msb;
 	fdt32_t gmii = 0;
@@ -60,7 +60,7 @@
 				    u8 *mac_addr)
 {
 	void *fdt = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	u32 macid_lo;
 	u32 macid_hi;
 	fdt32_t gmii = 0;
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index cbce683..5fbab9e 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -981,7 +981,7 @@
 
 #ifdef CONFIG_DM_ETH
 	if (slave->data->phy_of_handle)
-		phydev->dev->of_offset = slave->data->phy_of_handle;
+		dev_set_of_offset(phydev->dev, slave->data->phy_of_handle);
 #endif
 
 	priv->phydev = phydev;
@@ -1286,7 +1286,7 @@
 	const char *phy_mode;
 	const char *phy_sel_compat = NULL;
 	const void *fdt = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int subnode;
 	int slave_index = 0;
 	int active_slave;
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index e207bc6..eee4e09 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -728,7 +728,8 @@
 
 	pdata->iobase = dev_get_addr(dev);
 	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+			       NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
 	if (pdata->phy_interface == -1) {
@@ -737,19 +738,19 @@
 	}
 
 	pdata->max_speed = 0;
-	cell = fdt_getprop(gd->fdt_blob, dev->of_offset, "max-speed", NULL);
+	cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed", NULL);
 	if (cell)
 		pdata->max_speed = fdt32_to_cpu(*cell);
 
 #ifdef CONFIG_DM_GPIO
-	if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+	if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
 			    "snps,reset-active-low"))
 		reset_flags |= GPIOD_ACTIVE_LOW;
 
 	ret = gpio_request_by_name(dev, "snps,reset-gpio", 0,
 		&priv->reset_gpio, reset_flags);
 	if (ret == 0) {
-		ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+		ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
 			"snps,reset-delays-us", dw_pdata->reset_delays, 3);
 	} else if (ret == -ENOENT) {
 		ret = 0;
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 3304fddc..5f34c8f 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1277,7 +1277,8 @@
 	priv->eth = (struct ethernet_regs *)pdata->iobase;
 
 	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+			       NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
 	if (pdata->phy_interface == -1) {
diff --git a/drivers/net/gmac_rockchip.c b/drivers/net/gmac_rockchip.c
index 5f833fa..e9b202a 100644
--- a/drivers/net/gmac_rockchip.c
+++ b/drivers/net/gmac_rockchip.c
@@ -36,9 +36,9 @@
 {
 	struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev);
 
-	pdata->tx_delay = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	pdata->tx_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					 "tx-delay", 0x30);
-	pdata->rx_delay = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	pdata->rx_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					 "rx-delay", 0x10);
 
 	return designware_eth_ofdata_to_platdata(dev);
diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index a5120e0..1b781f4 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -1099,7 +1099,7 @@
 	struct ks2_eth_priv *priv = dev_get_priv(dev);
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	const void *fdt = gd->fdt_blob;
-	int slave = dev->of_offset;
+	int slave = dev_of_offset(dev);
 	int interfaces;
 	int gbe;
 	int netcp_devices;
@@ -1126,13 +1126,13 @@
 	int netcp_devices;
 	int gbe;
 
-	netcp_devices = fdt_subnode_offset(fdt, dev->of_offset,
+	netcp_devices = fdt_subnode_offset(fdt, dev_of_offset(dev),
 					   "netcp-devices");
 	gbe = fdt_subnode_offset(fdt, netcp_devices, "gbe");
 
 	ks2_eth_bind_slaves(dev, gbe, &gbe_0);
 
-	ks2_eth_parse_slave_interface(dev->of_offset, gbe_0, priv, pdata);
+	ks2_eth_parse_slave_interface(dev_of_offset(dev), gbe_0, priv, pdata);
 
 	pdata->iobase = dev_get_addr(dev);
 
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 01527f7..452fc3e 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -999,7 +999,8 @@
 #ifdef CONFIG_DM_ETH
 	const char *phy_mode;
 
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+			       NULL);
 	if (phy_mode)
 		macb->phy_interface = phy_get_interface_by_name(phy_mode);
 	if (macb->phy_interface == -1) {
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 00f378f..674075f 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1611,7 +1611,7 @@
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct mvneta_port *pp = dev_get_priv(dev);
 	void *blob = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	struct mii_dev *bus;
 	unsigned long addr;
 	void *bd_space;
@@ -1691,7 +1691,8 @@
 
 	/* Get phy-mode / phy_interface from DT */
 	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+			       NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
 	if (pdata->phy_interface == -1) {
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 405776a..88e88b9 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -4047,7 +4047,7 @@
 		return err;
 	}
 
-	return mvpp2_port_probe(dev, port, dev->of_offset, priv,
+	return mvpp2_port_probe(dev, port, dev_of_offset(dev), priv,
 				&buffer_loc.first_rxq);
 }
 
@@ -4138,7 +4138,7 @@
 static int mvpp2_base_bind(struct udevice *parent)
 {
 	const void *blob = gd->fdt_blob;
-	int node = parent->of_offset;
+	int node = dev_of_offset(parent);
 	struct uclass_driver *drv;
 	struct udevice *dev;
 	struct eth_pdata *plat;
@@ -4169,7 +4169,7 @@
 
 		/* Create child device UCLASS_ETH and bind it */
 		device_bind(parent, &mvpp2_driver, name, plat, subnode, &dev);
-		dev->of_offset = subnode;
+		dev_set_of_offset(dev, subnode);
 	}
 
 	return 0;
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 7163fa2..0e4a4eb 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -244,7 +244,7 @@
 		return -EOPNOTSUPP;
 
 	for (i = 0; i < ofcfg->grpsz; i++) {
-		val[i] = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+		val[i] = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 					 ofcfg->grp[i].name, -1);
 		offset = ofcfg->grp[i].off;
 		if (val[i] == -1) {
diff --git a/drivers/net/phy/ti.c b/drivers/net/phy/ti.c
index c55dd97..d1ce406 100644
--- a/drivers/net/phy/ti.c
+++ b/drivers/net/phy/ti.c
@@ -167,13 +167,13 @@
 	struct dp83867_private *dp83867 = phydev->priv;
 	struct udevice *dev = phydev->dev;
 
-	dp83867->rx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	dp83867->rx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 				 "ti,rx-internal-delay", -1);
 
-	dp83867->tx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	dp83867->tx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 				 "ti,tx-internal-delay", -1);
 
-	dp83867->fifo_depth = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	dp83867->fifo_depth = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 				 "ti,fifo-depth", -1);
 
 	return 0;
diff --git a/drivers/net/phy/xilinx_phy.c b/drivers/net/phy/xilinx_phy.c
index 920bfcb..3f80f04 100644
--- a/drivers/net/phy/xilinx_phy.c
+++ b/drivers/net/phy/xilinx_phy.c
@@ -104,7 +104,7 @@
 	u32 phytype;
 
 	debug("%s\n", __func__);
-	phytype = fdtdec_get_int(gd->fdt_blob, phydev->dev->of_offset,
+	phytype = fdtdec_get_int(gd->fdt_blob, dev_of_offset(phydev->dev),
 				 "phy-type", -1);
 	if (phytype == XAE_PHY_TYPE_1000BASE_X)
 		phydev->flags |= XAE_PHY_TYPE_1000BASE_X;
diff --git a/drivers/net/pic32_eth.c b/drivers/net/pic32_eth.c
index 167af8b..385aad5 100644
--- a/drivers/net/pic32_eth.c
+++ b/drivers/net/pic32_eth.c
@@ -535,7 +535,8 @@
 	int offset = 0;
 	int phy_addr = -1;
 
-	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;
 
@@ -544,7 +545,8 @@
 
 	/* get phy mode */
 	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+			       NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
 	if (pdata->phy_interface == -1) {
@@ -553,13 +555,13 @@
 	}
 
 	/* get phy addr */
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
 				       "phy-handle");
 	if (offset > 0)
 		phy_addr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
 
 	/* phy reset gpio */
-	gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset,
+	gpio_request_by_name_nodev(gd->fdt_blob, dev_of_offset(dev),
 				   "reset-gpios", 0,
 				   &priv->rst_gpio, GPIOD_IS_OUT);
 
diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c
index 5912427..9742c2c 100644
--- a/drivers/net/sandbox-raw.c
+++ b/drivers/net/sandbox-raw.c
@@ -26,7 +26,7 @@
 
 	debug("eth_sandbox_raw: Start\n");
 
-	interface = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	interface = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 					    "host-raw-interface", NULL);
 	if (interface == NULL)
 		return -EINVAL;
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
index d538d37..79d0ae6 100644
--- a/drivers/net/sandbox.c
+++ b/drivers/net/sandbox.c
@@ -60,8 +60,9 @@
 
 	debug("eth_sandbox: Start\n");
 
-	fdtdec_get_byte_array(gd->fdt_blob, dev->of_offset, "fake-host-hwaddr",
-			      priv->fake_host_hwaddr, ARP_HLEN);
+	fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(dev),
+			      "fake-host-hwaddr", priv->fake_host_hwaddr,
+			      ARP_HLEN);
 	priv->recv_packet_buffer = net_rx_packets[0];
 	return 0;
 }
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index abd9cc8..b87210b 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -442,7 +442,7 @@
 	const char *pin_name;
 	int drive, pull, i;
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
 				       "pinctrl-0");
 	if (offset < 0) {
 		printf("WARNING: emac: cannot find pinctrl-0 node\n");
@@ -716,6 +716,7 @@
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct emac_eth_dev *priv = dev_get_priv(dev);
 	const char *phy_mode;
+	int node = dev_of_offset(dev);
 	int offset = 0;
 
 	pdata->iobase = dev_get_addr_name(dev, "emac");
@@ -725,13 +726,13 @@
 	priv->phyaddr = -1;
 	priv->use_internal_phy = false;
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
 				       "phy");
 	if (offset > 0)
 		priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg",
 					       -1);
 
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
 
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
@@ -751,7 +752,7 @@
 	}
 
 	if (priv->variant == H3_EMAC) {
-		if (fdt_getprop(gd->fdt_blob, dev->of_offset,
+		if (fdt_getprop(gd->fdt_blob, node,
 				"allwinner,use-internal-phy", NULL))
 			priv->use_internal_phy = true;
 	}
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 7df4c63..f2ce4e2 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -783,7 +783,7 @@
 	pdata->iobase = (phys_addr_t)dev_get_addr(dev);
 	priv->regs = (struct tsec *)pdata->iobase;
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
 				       "phy-handle");
 	if (offset > 0) {
 		reg = fdtdec_get_int(gd->fdt_blob, offset, "reg", 0);
@@ -802,7 +802,7 @@
 		return -ENOENT;
 	}
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
 				       "tbi-handle");
 	if (offset > 0) {
 		reg = fdtdec_get_int(gd->fdt_blob, offset, "reg",
@@ -812,7 +812,7 @@
 		priv->tbiaddr = CONFIG_SYS_TBIPA_VALUE;
 	}
 
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset,
+	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
 			       "phy-connection-type", NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c
index 51c7426..a6f24b3 100644
--- a/drivers/net/xilinx_axi_emac.c
+++ b/drivers/net/xilinx_axi_emac.c
@@ -682,13 +682,14 @@
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct axidma_priv *priv = dev_get_priv(dev);
+	int node = dev_of_offset(dev);
 	int offset = 0;
 	const char *phy_mode;
 
 	pdata->iobase = (phys_addr_t)dev_get_addr(dev);
 	priv->iobase = (struct axi_regs *)pdata->iobase;
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
 				       "axistream-connected");
 	if (offset <= 0) {
 		printf("%s: axistream is not found\n", __func__);
@@ -705,12 +706,11 @@
 
 	priv->phyaddr = -1;
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
-				       "phy-handle");
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle");
 	if (offset > 0)
 		priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
 
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
 	if (pdata->phy_interface == -1) {
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index ea93cf9..7d4e14f 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -604,15 +604,15 @@
 
 	emaclite->phyaddr = -1;
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
 				      "phy-handle");
 	if (offset > 0)
 		emaclite->phyaddr = fdtdec_get_int(gd->fdt_blob, offset,
 						   "reg", -1);
 
-	emaclite->txpp = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	emaclite->txpp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					"xlnx,tx-ping-pong", 0);
-	emaclite->rxpp = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	emaclite->rxpp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					"xlnx,rx-ping-pong", 0);
 
 	printf("EMACLITE: %lx, phyaddr %d, %d/%d\n", (ulong)emaclite->regs,
diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index 6dd87cf..86dd03f 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -345,7 +345,7 @@
 	priv->phydev->advertising = priv->phydev->supported;
 
 	if (priv->phy_of_handle > 0)
-		priv->phydev->dev->of_offset = priv->phy_of_handle;
+		dev_set_of_offset(priv->phydev->dev, priv->phy_of_handle);
 
 	return phy_config(priv->phydev);
 }
@@ -684,6 +684,7 @@
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct zynq_gem_priv *priv = dev_get_priv(dev);
+	int node = dev_of_offset(dev);
 	const char *phy_mode;
 
 	pdata->iobase = (phys_addr_t)dev_get_addr(dev);
@@ -692,13 +693,13 @@
 	priv->emio = 0;
 	priv->phyaddr = -1;
 
-	priv->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob,
-					dev->of_offset, "phy-handle");
+	priv->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob, node,
+						    "phy-handle");
 	if (priv->phy_of_handle > 0)
 		priv->phyaddr = fdtdec_get_int(gd->fdt_blob,
 					priv->phy_of_handle, "reg", -1);
 
-	phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+	phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
 	if (pdata->phy_interface == -1) {
@@ -707,7 +708,7 @@
 	}
 	priv->interface = pdata->phy_interface;
 
-	priv->emio = fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "xlnx,emio");
+	priv->emio = fdtdec_get_bool(gd->fdt_blob, node, "xlnx,emio");
 
 	printf("ZYNQ GEM: %lx, phyaddr %x, interface %s\n", (ulong)priv->iobase,
 	       priv->phyaddr, phy_string_for_interface(priv->interface));
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 3b00e6a..a1408f5 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -839,8 +839,9 @@
 	/* For bridges, use the top-level PCI controller */
 	if (!device_is_on_pci_bus(bus)) {
 		hose->ctlr = bus;
-		ret = decode_regions(hose, gd->fdt_blob, bus->parent->of_offset,
-				bus->of_offset);
+		ret = decode_regions(hose, gd->fdt_blob,
+				     dev_of_offset(bus->parent),
+				     dev_of_offset(bus));
 		if (ret) {
 			debug("%s: Cannot decode regions\n", __func__);
 			return ret;
@@ -903,7 +904,7 @@
 	struct fdt_pci_addr addr;
 	int ret;
 
-	if (dev->of_offset == -1)
+	if (dev_of_offset(dev) == -1)
 		return 0;
 
 	/*
@@ -911,7 +912,7 @@
 	 * just check the address.
 	 */
 	pplat = dev_get_parent_platdata(dev);
-	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_CONFIG, "reg", &addr);
 
 	if (ret) {
diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c
index 430270e..7d9c63b 100644
--- a/drivers/pci/pci_tegra.c
+++ b/drivers/pci/pci_tegra.c
@@ -1099,7 +1099,7 @@
 
 	INIT_LIST_HEAD(&pcie->ports);
 
-	if (tegra_pcie_parse_dt(gd->fdt_blob, dev->of_offset, id, pcie))
+	if (tegra_pcie_parse_dt(gd->fdt_blob, dev_of_offset(dev), id, pcie))
 		return -EINVAL;
 
 	return 0;
diff --git a/drivers/pci/pcie_layerscape.c b/drivers/pci/pcie_layerscape.c
index 90b9fe2..b6806cf 100644
--- a/drivers/pci/pcie_layerscape.c
+++ b/drivers/pci/pcie_layerscape.c
@@ -438,7 +438,7 @@
 {
 	struct ls_pcie *pcie = dev_get_priv(dev);
 	const void *fdt = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	u8 header_type;
 	u16 link_sta;
 	bool ep_mode;
diff --git a/drivers/pci/pcie_xilinx.c b/drivers/pci/pcie_xilinx.c
index 5216001..08e2e93 100644
--- a/drivers/pci/pcie_xilinx.c
+++ b/drivers/pci/pcie_xilinx.c
@@ -186,7 +186,7 @@
 	DECLARE_GLOBAL_DATA_PTR;
 	int err;
 
-	err = fdt_get_resource(gd->fdt_blob, dev->of_offset, "reg",
+	err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",
 			       0, &reg_res);
 	if (err < 0) {
 		error("\"reg\" resource not found\n");
diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c
index bc2508b..caa1928 100644
--- a/drivers/phy/marvell/comphy_core.c
+++ b/drivers/phy/marvell/comphy_core.c
@@ -107,7 +107,7 @@
 static int comphy_probe(struct udevice *dev)
 {
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	struct chip_serdes_phy_config *chip_cfg = dev_get_priv(dev);
 	struct comphy_map comphy_map_data[MAX_LANE_OPTIONS];
 	int subnode;
diff --git a/drivers/pinctrl/ath79/pinctrl_ar933x.c b/drivers/pinctrl/ath79/pinctrl_ar933x.c
index e3f64b6..fccc7c4 100644
--- a/drivers/pinctrl/ath79/pinctrl_ar933x.c
+++ b/drivers/pinctrl/ath79/pinctrl_ar933x.c
@@ -75,7 +75,7 @@
 	u32 cell[2];
 	int ret;
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
 				   "interrupts", cell, ARRAY_SIZE(cell));
 	if (ret < 0)
 		return -EINVAL;
diff --git a/drivers/pinctrl/ath79/pinctrl_qca953x.c b/drivers/pinctrl/ath79/pinctrl_qca953x.c
index d02597e..a7f8c70 100644
--- a/drivers/pinctrl/ath79/pinctrl_qca953x.c
+++ b/drivers/pinctrl/ath79/pinctrl_qca953x.c
@@ -95,7 +95,7 @@
 	u32 cell[2];
 	int ret;
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
 				   "interrupts", cell, ARRAY_SIZE(cell));
 	if (ret < 0)
 		return -EINVAL;
diff --git a/drivers/pinctrl/exynos/pinctrl-exynos.c b/drivers/pinctrl/exynos/pinctrl-exynos.c
index dd0a16e..5b9a592 100644
--- a/drivers/pinctrl/exynos/pinctrl-exynos.c
+++ b/drivers/pinctrl/exynos/pinctrl-exynos.c
@@ -70,7 +70,7 @@
 int exynos_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
 	const void *fdt = gd->fdt_blob;
-	int node = config->of_offset;
+	int node = dev_of_offset(config);
 	unsigned int count, idx, pin_num;
 	unsigned int pinfunc, pinpud, pindrv;
 	unsigned long reg, value;
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 30f7cfc..b5486b8 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -142,19 +142,19 @@
 	int node, gpio = -1, len;
 	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 -EINVAL;
 	}
 
-	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 < 1) {
 		debug("bad #size-cells\n");
 		return -EINVAL;
 	}
 
-	fdt_for_each_subnode(node, gd->fdt_blob, dev->of_offset) {
+	fdt_for_each_subnode(node, gd->fdt_blob, dev_of_offset(dev)) {
 		if (fdt_getprop(gd->fdt_blob, node, "gpio-controller", &len)) {
 			gpio = node;
 			break;
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
index b077639..80f0dfa 100644
--- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c
+++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
@@ -28,7 +28,7 @@
 int mvebu_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
 	const void *blob = gd->fdt_blob;
-	int node = config->of_offset;
+	int node = dev_of_offset(config);
 	struct mvebu_pinctrl_priv *priv;
 	u32 pin_arr[MVEBU_MAX_PINS_PER_BANK];
 	u32 function;
@@ -82,7 +82,7 @@
 				       struct udevice *config)
 {
 	const void *blob = gd->fdt_blob;
-	int node = config->of_offset;
+	int node = dev_of_offset(config);
 	struct mvebu_pinctrl_priv *priv;
 	u32 func_arr[MVEBU_MAX_PINS_PER_BANK];
 	int pin, err;
@@ -128,7 +128,7 @@
 int mvebu_pinctl_probe(struct udevice *dev)
 {
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	struct mvebu_pinctrl_priv *priv;
 
 	priv = dev_get_priv(dev);
diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c b/drivers/pinctrl/nxp/pinctrl-imx.c
index 949d0f3..e130faf 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx.c
@@ -19,7 +19,7 @@
 {
 	struct imx_pinctrl_priv *priv = dev_get_priv(dev);
 	struct imx_pinctrl_soc_info *info = priv->info;
-	int node = config->of_offset;
+	int node = dev_of_offset(config);
 	const struct fdt_property *prop;
 	u32 *pin_data;
 	int npins, size, pin_size;
@@ -176,7 +176,7 @@
 		      struct imx_pinctrl_soc_info *info)
 {
 	struct imx_pinctrl_priv *priv = dev_get_priv(dev);
-	int node = dev->of_offset, ret;
+	int node = dev_of_offset(dev), ret;
 	struct fdtdec_phandle_args arg;
 	fdt_addr_t addr;
 	fdt_size_t size;
@@ -189,7 +189,8 @@
 	priv->dev = dev;
 	priv->info = info;
 
-	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/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index 6d4aadc..5c6bff5 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -109,7 +109,7 @@
 {
 	struct atmel_pio4_port *bank_base;
 	const void *blob = gd->fdt_blob;
-	int node = config->of_offset;
+	int node = dev_of_offset(config);
 	u32 offset, func, bank, line;
 	u32 cells[MAX_PINMUX_ENTRIES];
 	u32 i, conf;
diff --git a/drivers/pinctrl/pinctrl-generic.c b/drivers/pinctrl/pinctrl-generic.c
index 3629322..0272496 100644
--- a/drivers/pinctrl/pinctrl-generic.c
+++ b/drivers/pinctrl/pinctrl-generic.c
@@ -245,7 +245,7 @@
 					 bool is_group, unsigned selector)
 {
 	const void *fdt = gd->fdt_blob;
-	int node_offset = config->of_offset;
+	int node_offset = dev_of_offset(config);
 	const char *propname;
 	const void *value;
 	int prop_offset, len, func_selector, param, ret;
@@ -300,7 +300,7 @@
 					     struct udevice *config)
 {
 	const void *fdt = gd->fdt_blob;
-	int node = config->of_offset;
+	int node = dev_of_offset(config);
 	const char *subnode_target_type = "pins";
 	bool is_group = false;
 	const char *name;
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index 02ab9b4..49afe91 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -64,7 +64,7 @@
 static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
 {
 	const void *fdt = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	char propname[32]; /* long enough */
 	const fdt32_t *list;
 	uint32_t phandle;
@@ -122,7 +122,7 @@
 static int pinconfig_post_bind(struct udevice *dev)
 {
 	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;
diff --git a/drivers/pinctrl/pinctrl_pic32.c b/drivers/pinctrl/pinctrl_pic32.c
index 9acac29..59466ee 100644
--- a/drivers/pinctrl/pinctrl_pic32.c
+++ b/drivers/pinctrl/pinctrl_pic32.c
@@ -253,7 +253,7 @@
 	int ret;
 	u32 cell[2];
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
 				   "interrupts", cell, ARRAY_SIZE(cell));
 	if (ret < 0)
 		return -EINVAL;
@@ -310,7 +310,7 @@
 	struct pic32_pinctrl_priv *priv = dev_get_priv(dev);
 	struct fdt_resource res;
 	void *fdt = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	ret = fdt_get_named_resource(fdt, node, "reg", "reg-names",
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3036.c b/drivers/pinctrl/rockchip/pinctrl_rk3036.c
index 6aea856..8d42584 100644
--- a/drivers/pinctrl/rockchip/pinctrl_rk3036.c
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3036.c
@@ -205,7 +205,7 @@
 	u32 cell[3];
 	int ret;
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
 				   "interrupts", cell, ARRAY_SIZE(cell));
 	if (ret < 0)
 		return -EINVAL;
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3288.c b/drivers/pinctrl/rockchip/pinctrl_rk3288.c
index 0322264..cb13d30 100644
--- a/drivers/pinctrl/rockchip/pinctrl_rk3288.c
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3288.c
@@ -479,7 +479,7 @@
 	u32 cell[3];
 	int ret;
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
 				   "interrupts", cell, ARRAY_SIZE(cell));
 	if (ret < 0)
 		return -EINVAL;
@@ -644,7 +644,7 @@
 	u32 cell[60], *ptr;
 
 	debug("%s: %s %s\n", __func__, dev->name, config->name);
-	ret = fdtdec_get_int_array_count(blob, config->of_offset,
+	ret = fdtdec_get_int_array_count(blob, dev_of_offset(config),
 					 "rockchip,pins", cell,
 					 ARRAY_SIZE(cell));
 	if (ret < 0) {
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3399.c b/drivers/pinctrl/rockchip/pinctrl_rk3399.c
index 17ea165..da30154 100644
--- a/drivers/pinctrl/rockchip/pinctrl_rk3399.c
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3399.c
@@ -362,7 +362,7 @@
 	u32 cell[3];
 	int ret;
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
 				   "interrupts", cell, ARRAY_SIZE(cell));
 	if (ret < 0)
 		return -EINVAL;
diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index 1bb6262..3dabbe4 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -41,7 +41,7 @@
 
 	debug("%s(dev=%p, power_domain=%p)\n", __func__, dev, power_domain);
 
-	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),
 					     "power-domains",
 					     "#power-domain-cells", 0, 0,
 					     &args);
diff --git a/drivers/power/pmic/act8846.c b/drivers/power/pmic/act8846.c
index e8164bf..15da12e 100644
--- a/drivers/power/pmic/act8846.c
+++ b/drivers/power/pmic/act8846.c
@@ -52,7 +52,7 @@
 	int regulators_node;
 	int children;
 
-	regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+	regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
 					     "regulators");
 	if (regulators_node <= 0) {
 		debug("%s: %s regulators subnode not found!", __func__,
diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c
index aeab5c9..4f92e3d 100644
--- a/drivers/power/pmic/i2c_pmic_emul.c
+++ b/drivers/power/pmic/i2c_pmic_emul.c
@@ -108,9 +108,9 @@
 
 	debug("%s:%d Setting PMIC default registers\n", __func__, __LINE__);
 
-	reg_defaults = fdtdec_locate_byte_array(gd->fdt_blob, emul->of_offset,
-						"reg-defaults",
-						SANDBOX_PMIC_REG_COUNT);
+	reg_defaults = fdtdec_locate_byte_array(gd->fdt_blob,
+			dev_of_offset(emul), "reg-defaults",
+			SANDBOX_PMIC_REG_COUNT);
 
 	if (!reg_defaults) {
 		error("Property \"reg-defaults\" not found for device: %s!",
diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c
index 307f96b..d8f30df 100644
--- a/drivers/power/pmic/lp873x.c
+++ b/drivers/power/pmic/lp873x.c
@@ -49,7 +49,7 @@
 	int regulators_node;
 	const void *blob = gd->fdt_blob;
 	int children;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 
 	regulators_node = fdt_subnode_offset(blob, node, "regulators");
 
diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c
index dc5a54a..8295fab 100644
--- a/drivers/power/pmic/max77686.c
+++ b/drivers/power/pmic/max77686.c
@@ -54,7 +54,7 @@
 	const void *blob = gd->fdt_blob;
 	int children;
 
-	regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+	regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
 					     "voltage-regulators");
 	if (regulators_node <= 0) {
 		debug("%s: %s regulators subnode not found!", __func__,
diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c
index 0ab425e..f5a2307 100644
--- a/drivers/power/pmic/palmas.c
+++ b/drivers/power/pmic/palmas.c
@@ -49,7 +49,7 @@
 	int pmic_node = -1, regulators_node;
 	const void *blob = gd->fdt_blob;
 	int children;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int subnode, len;
 
 	fdt_for_each_subnode(subnode, blob, node) {
diff --git a/drivers/power/pmic/pfuze100.c b/drivers/power/pmic/pfuze100.c
index 3beb48e..90a43f2 100644
--- a/drivers/power/pmic/pfuze100.c
+++ b/drivers/power/pmic/pfuze100.c
@@ -56,7 +56,7 @@
 	int regulators_node;
 	const void *blob = gd->fdt_blob;
 
-	regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+	regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
 					     "regulators");
 	if (regulators_node <= 0) {
 		debug("%s: %s regulators subnode not found!", __func__,
diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c
index 7211026..0f7fa51 100644
--- a/drivers/power/pmic/pmic-uclass.c
+++ b/drivers/power/pmic/pmic-uclass.c
@@ -33,7 +33,7 @@
 	int ret;
 
 	debug("%s for '%s' at node offset: %d\n", __func__, pmic->name,
-	      pmic->of_offset);
+	      dev_of_offset(pmic));
 
 	for (node = fdt_first_subnode(blob, offset);
 	     node > 0;
diff --git a/drivers/power/pmic/rk808.c b/drivers/power/pmic/rk808.c
index 770f471..3f5f316 100644
--- a/drivers/power/pmic/rk808.c
+++ b/drivers/power/pmic/rk808.c
@@ -61,7 +61,7 @@
 	int regulators_node;
 	int children;
 
-	regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+	regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
 					     "regulators");
 	if (regulators_node <= 0) {
 		debug("%s: %s regulators subnode not found!", __func__,
diff --git a/drivers/power/pmic/s5m8767.c b/drivers/power/pmic/s5m8767.c
index 075fe7e..25d673b 100644
--- a/drivers/power/pmic/s5m8767.c
+++ b/drivers/power/pmic/s5m8767.c
@@ -58,7 +58,7 @@
 	const void *blob = gd->fdt_blob;
 	int children;
 
-	node = fdt_subnode_offset(blob, dev->of_offset, "regulators");
+	node = fdt_subnode_offset(blob, dev_of_offset(dev), "regulators");
 	if (node <= 0) {
 		debug("%s: %s regulators subnode not found!", __func__,
 		      dev->name);
diff --git a/drivers/power/pmic/sandbox.c b/drivers/power/pmic/sandbox.c
index 3e56acd..b4e412e 100644
--- a/drivers/power/pmic/sandbox.c
+++ b/drivers/power/pmic/sandbox.c
@@ -51,7 +51,7 @@
 
 static int sandbox_pmic_bind(struct udevice *dev)
 {
-	if (!pmic_bind_children(dev, dev->of_offset, pmic_children_info))
+	if (!pmic_bind_children(dev, dev_of_offset(dev), pmic_children_info))
 		error("%s:%d PMIC: %s - no child found!", __func__, __LINE__,
 							  dev->name);
 
diff --git a/drivers/power/pmic/tps65090.c b/drivers/power/pmic/tps65090.c
index 4797f32..b30a7f0 100644
--- a/drivers/power/pmic/tps65090.c
+++ b/drivers/power/pmic/tps65090.c
@@ -56,7 +56,7 @@
 	const void *blob = gd->fdt_blob;
 	int children;
 
-	regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+	regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
 					     "regulators");
 	if (regulators_node <= 0) {
 		debug("%s: %s regulators subnode not found!", __func__,
diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index 3d2d908..cd52137 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -28,7 +28,7 @@
 	struct fixed_regulator_platdata *dev_pdata;
 	struct gpio_desc *gpio;
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset, flags = GPIOD_IS_OUT;
+	int node = dev_of_offset(dev), flags = GPIOD_IS_OUT;
 	int ret;
 
 	dev_pdata = dev_get_platdata(dev);
@@ -54,7 +54,7 @@
 
 	/* Get optional ramp up delay */
 	dev_pdata->startup_delay_us = fdtdec_get_uint(gd->fdt_blob,
-						      dev->of_offset,
+						      dev_of_offset(dev),
 						      "startup-delay-us", 0);
 
 	return 0;
diff --git a/drivers/power/regulator/gpio-regulator.c b/drivers/power/regulator/gpio-regulator.c
index 0a60a9c..42391c6 100644
--- a/drivers/power/regulator/gpio-regulator.c
+++ b/drivers/power/regulator/gpio-regulator.c
@@ -30,7 +30,7 @@
 	struct gpio_regulator_platdata *dev_pdata;
 	struct gpio_desc *gpio;
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret, count, i, j;
 	u32 states_array[8];
 
diff --git a/drivers/power/regulator/pwm_regulator.c b/drivers/power/regulator/pwm_regulator.c
index b0a4c5d..4875238 100644
--- a/drivers/power/regulator/pwm_regulator.c
+++ b/drivers/power/regulator/pwm_regulator.c
@@ -88,7 +88,7 @@
 	struct pwm_regulator_info *priv = dev_get_priv(dev);
 	struct fdtdec_phandle_args args;
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	ret = fdtdec_parse_phandle_with_args(blob, node, "pwms", "#pwm-cells",
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 52a1070..2e0b5ed 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -278,7 +278,7 @@
 static int regulator_post_bind(struct udevice *dev)
 {
 	struct dm_regulator_uclass_platdata *uc_pdata;
-	int offset = dev->of_offset;
+	int offset = dev_of_offset(dev);
 	const void *blob = gd->fdt_blob;
 	const char *property = "regulator-name";
 
@@ -308,7 +308,7 @@
 static int regulator_pre_probe(struct udevice *dev)
 {
 	struct dm_regulator_uclass_platdata *uc_pdata;
-	int offset = dev->of_offset;
+	int offset = dev_of_offset(dev);
 
 	uc_pdata = dev_get_uclass_platdata(dev);
 	if (!uc_pdata)
diff --git a/drivers/remoteproc/rproc-uclass.c b/drivers/remoteproc/rproc-uclass.c
index 200cf61..b6e67f2 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -116,7 +116,7 @@
 
 	if (!dev->platdata) {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-		int node = dev->of_offset;
+		int node = dev_of_offset(dev);
 		const void *blob = gd->fdt_blob;
 		bool tmp;
 		if (!blob) {
diff --git a/drivers/remoteproc/ti_power_proc.c b/drivers/remoteproc/ti_power_proc.c
index 76ac3be..bb7a145 100644
--- a/drivers/remoteproc/ti_power_proc.c
+++ b/drivers/remoteproc/ti_power_proc.c
@@ -33,7 +33,7 @@
 static int ti_of_to_priv(struct udevice *dev,
 			 struct ti_powerproc_privdata *priv)
 {
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const void *blob = gd->fdt_blob;
 	int tmp;
 
diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index d3744ef..e92b24f 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -43,7 +43,7 @@
 	debug("%s(dev=%p, index=%d, reset_ctl=%p)\n", __func__, dev, index,
 	      reset_ctl);
 
-	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),
 					     "resets", "#reset-cells", 0,
 					     index, &args);
 	if (ret) {
@@ -88,7 +88,7 @@
 	debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name,
 	      reset_ctl);
 
-	index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset,
+	index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
 				      "reset-names", name);
 	if (index < 0) {
 		debug("fdt_stringlist_search() failed: %d\n", index);
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);
diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index f16f90d..9a6e41f 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -282,7 +282,7 @@
 {
 	struct cadence_spi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 	int subnode;
 	u32 data[4];
 	int ret;
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index 20aa99a..65d37b0 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -540,7 +540,7 @@
 {
 	struct davinci_spi_slave *ds = dev_get_priv(bus);
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 
 	ds->regs = dev_map_physmem(bus, sizeof(struct davinci_spi_regs));
 	if (!ds->regs) {
diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index 24a6e98..9d5e29c 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -132,7 +132,7 @@
 {
 	struct dw_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 dw_spi *)dev_get_addr(bus);
 
diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c
index 44948c3..aa0784c 100644
--- a/drivers/spi/exynos_spi.c
+++ b/drivers/spi/exynos_spi.c
@@ -253,7 +253,7 @@
 {
 	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 *)dev_get_addr(bus);
 	plat->periph_id = pinmux_decode_periph_id(blob, node);
diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
index f213587..e09985e 100644
--- a/drivers/spi/fsl_dspi.c
+++ b/drivers/spi/fsl_dspi.c
@@ -646,7 +646,7 @@
 	fdt_addr_t addr;
 	struct fsl_dspi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 
 	if (fdtdec_get_bool(blob, node, "big-endian"))
 		plat->flags |= DSPI_FLAG_REGMAP_ENDIAN_BIG;
diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c
index 4d378c2..b2a0583 100644
--- a/drivers/spi/fsl_qspi.c
+++ b/drivers/spi/fsl_qspi.c
@@ -1078,7 +1078,7 @@
 	struct fdt_resource res_regs, res_mem;
 	struct fsl_qspi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 	int ret, flash_num = 0, subnode;
 
 	if (fdtdec_get_bool(blob, node, "big-endian"))
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index caf0103..893fe33 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -658,14 +658,14 @@
 static int ich_spi_ofdata_to_platdata(struct udevice *dev)
 {
 	struct ich_spi_platdata *plat = dev_get_platdata(dev);
+	int node = dev_of_offset(dev);
 	int ret;
 
-	ret = fdt_node_check_compatible(gd->fdt_blob, dev->of_offset,
-					"intel,ich7-spi");
+	ret = fdt_node_check_compatible(gd->fdt_blob, node, "intel,ich7-spi");
 	if (ret == 0) {
 		plat->ich_version = ICHV_7;
 	} else {
-		ret = fdt_node_check_compatible(gd->fdt_blob, dev->of_offset,
+		ret = fdt_node_check_compatible(gd->fdt_blob, node,
 						"intel,ich9-spi");
 		if (ret == 0)
 			plat->ich_version = ICHV_9;
diff --git a/drivers/spi/mvebu_a3700_spi.c b/drivers/spi/mvebu_a3700_spi.c
index 7c58c36..ee847e4 100644
--- a/drivers/spi/mvebu_a3700_spi.c
+++ b/drivers/spi/mvebu_a3700_spi.c
@@ -261,9 +261,9 @@
 	 * it should be used to read the input clock and the DT property
 	 * can be removed.
 	 */
-	plat->clock = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+	plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
 				     "clock-frequency", 160000);
-	plat->frequency = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+	plat->frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
 					 "spi-max-frequency", 40000);
 
 	return 0;
diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index 60e9d6e..8a89450 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -627,7 +627,7 @@
 {
 	struct omap3_spi_priv *priv = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 
 	struct omap2_mcspi_platform_config* data =
 		(struct omap2_mcspi_platform_config*)dev_get_driver_data(dev);
diff --git a/drivers/spi/pic32_spi.c b/drivers/spi/pic32_spi.c
index 25ca1f3..78d78bc 100644
--- a/drivers/spi/pic32_spi.c
+++ b/drivers/spi/pic32_spi.c
@@ -377,13 +377,14 @@
 {
 	struct pic32_spi_priv *priv = dev_get_priv(bus);
 	struct dm_spi_bus *dm_spi = dev_get_uclass_priv(bus);
+	int node = dev_of_offset(bus);
 	struct udevice *clkdev;
 	fdt_addr_t addr;
 	fdt_size_t size;
 	int ret;
 
 	debug("%s: %d, bus: %i\n", __func__, __LINE__, bus->seq);
-	addr = fdtdec_get_addr_size(gd->fdt_blob, bus->of_offset, "reg", &size);
+	addr = fdtdec_get_addr_size(gd->fdt_blob, node, "reg", &size);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
@@ -391,8 +392,8 @@
 	if (!priv->regs)
 		return -EINVAL;
 
-	dm_spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
-					"spi-max-frequency", 250000000);
+	dm_spi->max_hz = fdtdec_get_int(gd->fdt_blob, node, "spi-max-frequency",
+					250000000);
 	/* get clock rate */
 	ret = clk_get_by_index(bus, 0, &clkdev);
 	if (ret < 0) {
@@ -413,8 +414,7 @@
 	 * of the ongoing transfer. To avoid this sort of error we will drive
 	 * /CS manually by toggling cs-gpio pins.
 	 */
-	ret = gpio_request_by_name_nodev(gd->fdt_blob, bus->of_offset,
-					 "cs-gpios", 0,
+	ret = gpio_request_by_name_nodev(gd->fdt_blob, node, "cs-gpios", 0,
 					 &priv->cs_gpio, GPIOD_IS_OUT);
 	if (ret) {
 		printf("pic32-spi: error, cs-gpios not found\n");
diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c
index 15cf0bd..3e44f17 100644
--- a/drivers/spi/rk_spi.c
+++ b/drivers/spi/rk_spi.c
@@ -164,7 +164,7 @@
 	struct rockchip_spi_platdata *plat = dev_get_platdata(bus);
 	struct rockchip_spi_priv *priv = dev_get_priv(bus);
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 	int ret;
 
 	plat->base = dev_get_addr(bus);
diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c
index d23dc81..1690cd7 100644
--- a/drivers/spi/soft_spi.c
+++ b/drivers/spi/soft_spi.c
@@ -202,7 +202,7 @@
 {
 	struct soft_spi_platdata *plat = dev->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 
 	plat->spi_delay_us = fdtdec_get_int(blob, node, "spi-delay-us", 0);
 
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 1ab5b75..ac17da0 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -113,10 +113,11 @@
 {
 	struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
 
-	if (dev->of_offset == -1)
+	if (dev_of_offset(dev) == -1)
 		return 0;
 
-	return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat);
+	return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev),
+					    plat);
 }
 #endif
 
@@ -125,7 +126,7 @@
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct dm_spi_bus *spi = dev_get_uclass_priv(bus);
 
-	spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+	spi->max_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
 				     "spi-max-frequency", 0);
 #endif
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
index 123a1f3..05358eb 100644
--- a/drivers/spi/stm32_qspi.c
+++ b/drivers/spi/stm32_qspi.c
@@ -411,7 +411,7 @@
 	struct fdt_resource res_regs, res_mem;
 	struct stm32_qspi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 	int ret;
 
 	ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
diff --git a/drivers/spi/tegra114_spi.c b/drivers/spi/tegra114_spi.c
index 509afba..897409c 100644
--- a/drivers/spi/tegra114_spi.c
+++ b/drivers/spi/tegra114_spi.c
@@ -101,7 +101,7 @@
 {
 	struct tegra_spi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 
 	plat->base = dev_get_addr(bus);
 	plat->periph_id = clock_decode_periph_id(blob, node);
diff --git a/drivers/spi/tegra20_sflash.c b/drivers/spi/tegra20_sflash.c
index ce3a2d3..ecbf4c1 100644
--- a/drivers/spi/tegra20_sflash.c
+++ b/drivers/spi/tegra20_sflash.c
@@ -88,7 +88,7 @@
 {
 	struct tegra_spi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 
 	plat->base = dev_get_addr(bus);
 	plat->periph_id = clock_decode_periph_id(blob, node);
diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c
index e1da23b..1d99a1e 100644
--- a/drivers/spi/tegra20_slink.c
+++ b/drivers/spi/tegra20_slink.c
@@ -94,7 +94,7 @@
 {
 	struct tegra_spi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 
 	plat->base = dev_get_addr(bus);
 	plat->periph_id = clock_decode_periph_id(blob, node);
diff --git a/drivers/spi/tegra210_qspi.c b/drivers/spi/tegra210_qspi.c
index 026cff0..1e094cb 100644
--- a/drivers/spi/tegra210_qspi.c
+++ b/drivers/spi/tegra210_qspi.c
@@ -97,7 +97,7 @@
 {
 	struct tegra_spi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 
 	plat->base = dev_get_addr(bus);
 	plat->periph_id = clock_decode_periph_id(blob, node);
diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index 6f9f983..79955d7 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -553,7 +553,7 @@
 {
 	struct ti_qspi_priv *priv = dev_get_priv(bus);
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 	fdt_addr_t addr;
 	void *mmap;
 
diff --git a/drivers/spi/zynq_qspi.c b/drivers/spi/zynq_qspi.c
index b98663c..255e02f 100644
--- a/drivers/spi/zynq_qspi.c
+++ b/drivers/spi/zynq_qspi.c
@@ -101,7 +101,7 @@
 {
 	struct zynq_qspi_platdata *plat = bus->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = bus->of_offset;
+	int node = dev_of_offset(bus);
 
 	plat->regs = (struct zynq_qspi_regs *)fdtdec_get_addr(blob,
 							      node, "reg");
diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c
index 15ca271..5a9b1f0 100644
--- a/drivers/spi/zynq_spi.c
+++ b/drivers/spi/zynq_spi.c
@@ -71,7 +71,7 @@
 {
 	struct zynq_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 zynq_spi_regs *)dev_get_addr(bus);
 
diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c
index 48bc157..605683f 100644
--- a/drivers/spmi/spmi-msm.c
+++ b/drivers/spmi/spmi-msm.c
@@ -147,18 +147,14 @@
 {
 	struct udevice *parent = dev->parent;
 	struct msm_spmi_priv *priv = dev_get_priv(dev);
+	int node = dev_of_offset(dev);
 	int i;
 
 	priv->arb_chnl = dev_get_addr(dev);
 	priv->spmi_core = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-							   parent->of_offset,
-							   dev->of_offset,
-							   "reg", 1, NULL,
-							   false);
+			dev_of_offset(parent), node, "reg", 1, NULL, false);
 	priv->spmi_obs = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-							  parent->of_offset,
-							  dev->of_offset, "reg",
-							  2, NULL, false);
+			dev_of_offset(parent), node, "reg", 2, NULL, false);
 	if (priv->arb_chnl == FDT_ADDR_T_NONE ||
 	    priv->spmi_core == FDT_ADDR_T_NONE ||
 	    priv->spmi_obs == FDT_ADDR_T_NONE)
diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c
index 7ae7f38..0c4e2e1 100644
--- a/drivers/sysreset/sysreset_sandbox.c
+++ b/drivers/sysreset/sysreset_sandbox.c
@@ -41,7 +41,7 @@
 	 * (see the U_BOOT_DEVICE() declaration below) should not do anything.
 	 * If we are that device, return an error.
 	 */
-	if (state->fdt_fname && dev->of_offset == -1)
+	if (state->fdt_fname && dev_of_offset(dev) == -1)
 		return -ENODEV;
 
 	switch (type) {
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 5c63e6b..1caf3cd 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -55,7 +55,7 @@
 		uc_priv->clock_rate = ret;
 	} else
 		uc_priv->clock_rate = fdtdec_get_int(gd->fdt_blob,
-				dev->of_offset,	"clock-frequency", 0);
+				dev_of_offset(dev),	"clock-frequency", 0);
 
 	return 0;
 }
diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c
index 0965ad0..9abb323 100644
--- a/drivers/usb/emul/sandbox_flash.c
+++ b/drivers/usb/emul/sandbox_flash.c
@@ -373,8 +373,8 @@
 	struct sandbox_flash_plat *plat = dev_get_platdata(dev);
 	const void *blob = gd->fdt_blob;
 
-	plat->pathname = fdt_getprop(blob, dev->of_offset, "sandbox,filepath",
-				     NULL);
+	plat->pathname = fdt_getprop(blob, dev_of_offset(dev),
+				     "sandbox,filepath", NULL);
 
 	return 0;
 }
diff --git a/drivers/usb/emul/sandbox_hub.c b/drivers/usb/emul/sandbox_hub.c
index 624fbde..c3a8e73 100644
--- a/drivers/usb/emul/sandbox_hub.c
+++ b/drivers/usb/emul/sandbox_hub.c
@@ -277,7 +277,8 @@
 {
 	struct sandbox_hub_platdata *plat = dev_get_parent_platdata(dev);
 
-	plat->port = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+	plat->port = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg",
+				    -1);
 
 	return 0;
 }
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index d08879d..d253b94 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -1199,8 +1199,8 @@
 		return -EINVAL;
 	priv->regs = (struct dwc2_core_regs *)addr;
 
-	prop = fdt_getprop(gd->fdt_blob, dev->of_offset, "disable-over-current",
-			   NULL);
+	prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
+			   "disable-over-current", NULL);
 	if (prop)
 		priv->oc_disable = true;
 
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 53281d7..981543e 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -59,7 +59,7 @@
 	}
 
 	depth = 0;
-	node = fdtdec_next_compatible_subnode(blob, dev->of_offset,
+	node = fdtdec_next_compatible_subnode(blob, dev_of_offset(dev),
 				COMPAT_SAMSUNG_EXYNOS_USB_PHY, &depth);
 	if (node <= 0) {
 		debug("XHCI: Can't get device node for usb3-phy controller\n");
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 9c32921..7ad50fc 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -61,7 +61,7 @@
 	struct ehci_fsl_priv *priv = dev_get_priv(dev);
 	const void *prop;
 
-	prop = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy_type",
+	prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy_type",
 			   NULL);
 	if (prop) {
 		priv->phy_type = (char *)prop;
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 7b309b7..55ac162 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -437,7 +437,7 @@
 	void *__iomem addr = (void *__iomem)dev_get_addr(dev);
 	void *__iomem phy_ctrl, *__iomem phy_status;
 	const void *blob = gd->fdt_blob;
-	int offset = dev->of_offset, phy_off;
+	int offset = dev_of_offset(dev), phy_off;
 	u32 val;
 
 	/*
@@ -484,7 +484,7 @@
 	struct usb_platdata *plat = dev_get_platdata(dev);
 	const char *mode;
 
-	mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "dr_mode", NULL);
+	mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "dr_mode", NULL);
 	if (mode) {
 		if (strcmp(mode, "peripheral") == 0)
 			plat->init_type = USB_INIT_DEVICE;
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index e3620da..beb3b02 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -696,7 +696,7 @@
 static int fdt_decode_usb(struct udevice *dev, struct fdt_usb *config)
 {
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const char *phy, *mode;
 
 	config->reg = (struct usb_ctlr *)dev_get_addr(dev);
diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
index f389bff..84241cd 100644
--- a/drivers/usb/host/ehci-vf.c
+++ b/drivers/usb/host/ehci-vf.c
@@ -218,7 +218,7 @@
 {
 	struct ehci_vf_priv_data *priv = dev_get_priv(dev);
 	const void *dt_blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const char *mode;
 
 	priv->portnr = dev->seq;
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index be114fc..5cf1e9a 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -686,16 +686,17 @@
 	const void *blob = gd->fdt_blob;
 	int val;
 
-	if (dev->of_offset == -1)
+	if (dev_of_offset(dev) == -1)
 		return 0;
 
 	/* We only support matching a few things */
-	val = fdtdec_get_int(blob, dev->of_offset, "usb,device-class", -1);
+	val = fdtdec_get_int(blob, dev_of_offset(dev), "usb,device-class", -1);
 	if (val != -1) {
 		plat->id.match_flags |= USB_DEVICE_ID_MATCH_DEV_CLASS;
 		plat->id.bDeviceClass = val;
 	}
-	val = fdtdec_get_int(blob, dev->of_offset, "usb,interface-class", -1);
+	val = fdtdec_get_int(blob, dev_of_offset(dev), "usb,interface-class",
+			     -1);
 	if (val != -1) {
 		plat->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS;
 		plat->id.bInterfaceClass = val;
diff --git a/drivers/usb/host/xhci-exynos5.c b/drivers/usb/host/xhci-exynos5.c
index 82fcd84..b3f48b3 100644
--- a/drivers/usb/host/xhci-exynos5.c
+++ b/drivers/usb/host/xhci-exynos5.c
@@ -68,7 +68,7 @@
 	}
 
 	depth = 0;
-	node = fdtdec_next_compatible_subnode(blob, dev->of_offset,
+	node = fdtdec_next_compatible_subnode(blob, dev_of_offset(dev),
 				COMPAT_SAMSUNG_EXYNOS5_USB3_PHY, &depth);
 	if (node <= 0) {
 		debug("XHCI: Can't get device node for usb3-phy controller\n");
diff --git a/drivers/usb/host/xhci-rockchip.c b/drivers/usb/host/xhci-rockchip.c
index 8cbcb8f..f559830 100644
--- a/drivers/usb/host/xhci-rockchip.c
+++ b/drivers/usb/host/xhci-rockchip.c
@@ -90,11 +90,11 @@
 	/* Set dwc3 usb2 phy config */
 	reg = readl(&dwc3_reg->g_usb2phycfg[0]);
 
-	if (fdtdec_get_bool(blob, dev->of_offset,
+	if (fdtdec_get_bool(blob, dev_of_offset(dev),
 			    "snps,dis-enblslpm-quirk"))
 		reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
 
-	utmi_bits = fdtdec_get_int(blob, dev->of_offset,
+	utmi_bits = fdtdec_get_int(blob, dev_of_offset(dev),
 				   "snps,phyif-utmi-bits", -1);
 	if (utmi_bits == 16) {
 		reg |= DWC3_GUSB2PHYCFG_PHYIF;
@@ -106,11 +106,11 @@
 		reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT;
 	}
 
-	if (fdtdec_get_bool(blob, dev->of_offset,
+	if (fdtdec_get_bool(blob, dev_of_offset(dev),
 			    "snps,dis-u2-freeclk-exists-quirk"))
 		reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
 
-	if (fdtdec_get_bool(blob, dev->of_offset,
+	if (fdtdec_get_bool(blob, dev_of_offset(dev),
 			    "snps,dis-u2-susphy-quirk"))
 		reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
 
diff --git a/drivers/usb/musb-new/pic32.c b/drivers/usb/musb-new/pic32.c
index c888c64..ed6da19 100644
--- a/drivers/usb/musb-new/pic32.c
+++ b/drivers/usb/musb-new/pic32.c
@@ -219,7 +219,7 @@
 	struct musb_host_data *mdata = &pdata->mdata;
 	struct fdt_resource mc, glue;
 	void *fdt = (void *)gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	void __iomem *mregs;
 	int ret;
 
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 1c15aa2..852f07f 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -83,7 +83,7 @@
 {
 	struct ti_musb_platdata *platdata = dev_get_platdata(dev);
 	const void *fdt = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int phys;
 	int ctrl_mod;
 	int usb_index;
@@ -178,7 +178,7 @@
 {
 	struct ti_musb_platdata *platdata = dev_get_platdata(dev);
 	const void *fdt = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	ret = ti_musb_ofdata_to_platdata(dev);
@@ -209,7 +209,7 @@
 	int node;
 	int ret;
 
-	for (node = fdt_first_subnode(fdt, parent->of_offset); node > 0;
+	for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
 	     node = fdt_next_subnode(fdt, node)) {
 		struct udevice *dev;
 		const char *name = fdt_get_name(fdt, node, NULL);
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 39cd7ca..ed2bd30 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -276,7 +276,7 @@
 	struct display_timing *timing = &priv->timing;
 	const void *blob = gd->fdt_blob;
 
-	if (fdtdec_decode_display_timing(blob, dev->of_offset,
+	if (fdtdec_decode_display_timing(blob, dev_of_offset(dev),
 					 plat->timing_index, timing)) {
 		debug("%s: Failed to decode display timing\n", __func__);
 		return -EINVAL;
diff --git a/drivers/video/bridge/ps862x.c b/drivers/video/bridge/ps862x.c
index 80f63e3..46aacca 100644
--- a/drivers/video/bridge/ps862x.c
+++ b/drivers/video/bridge/ps862x.c
@@ -86,7 +86,8 @@
 	if (ret)
 		return ret;
 
-	params = fdt_getprop(gd->fdt_blob, dev->of_offset, "parade,regs", &len);
+	params = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "parade,regs",
+			     &len);
 	if (!params || len % 3) {
 		debug("%s: missing/invalid params=%p, len=%x\n", __func__,
 		      params, len);
diff --git a/drivers/video/broadwell_igd.c b/drivers/video/broadwell_igd.c
index beef770..4612d04 100644
--- a/drivers/video/broadwell_igd.c
+++ b/drivers/video/broadwell_igd.c
@@ -705,7 +705,7 @@
 {
 	struct broadwell_igd_plat *plat = dev_get_platdata(dev);
 	struct broadwell_igd_priv *priv = dev_get_priv(dev);
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const void *blob = gd->fdt_blob;
 
 	if (fdtdec_get_int_array(blob, node, "intel,dp-hotplug",
diff --git a/drivers/video/exynos/exynos_dp.c b/drivers/video/exynos/exynos_dp.c
index fc39f2c..c5039e7 100644
--- a/drivers/video/exynos/exynos_dp.c
+++ b/drivers/video/exynos/exynos_dp.c
@@ -880,7 +880,7 @@
 {
 	struct exynos_dp_priv *priv = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
-	unsigned int node = dev->of_offset;
+	unsigned int node = dev_of_offset(dev);
 	fdt_addr_t addr;
 
 	addr = dev_get_addr(dev);
diff --git a/drivers/video/exynos/exynos_fb.c b/drivers/video/exynos/exynos_fb.c
index 5483d66..46320e7 100644
--- a/drivers/video/exynos/exynos_fb.c
+++ b/drivers/video/exynos/exynos_fb.c
@@ -383,7 +383,7 @@
 	unsigned int offset;
 	unsigned int node;
 
-	node = dev->of_offset;
+	node = dev_of_offset(dev);
 	if (fdtdec_get_bool(gd->fdt_blob, node, "samsung,disable-sysmmu"))
 		exynos_fimd_disable_sysmmu();
 
@@ -482,7 +482,7 @@
 int exynos_fb_ofdata_to_platdata(struct udevice *dev)
 {
 	struct exynos_fb_priv *priv = dev_get_priv(dev);
-	unsigned int node = dev->of_offset;
+	unsigned int node = dev_of_offset(dev);
 	const void *blob = gd->fdt_blob;
 	fdt_addr_t addr;
 
diff --git a/drivers/video/ivybridge_igd.c b/drivers/video/ivybridge_igd.c
index f16d725..d8af2e1 100644
--- a/drivers/video/ivybridge_igd.c
+++ b/drivers/video/ivybridge_igd.c
@@ -517,7 +517,7 @@
 static int gma_pm_init_post_vbios(struct udevice *dev, int rev, void *gtt_bar)
 {
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	u32 reg32, cycle_delay;
 
 	debug("GT Power Management Init (post VBIOS)\n");
diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c
index de6277f..3697f49 100644
--- a/drivers/video/pwm_backlight.c
+++ b/drivers/video/pwm_backlight.c
@@ -61,7 +61,7 @@
 	struct pwm_backlight_priv *priv = dev_get_priv(dev);
 	struct fdtdec_phandle_args args;
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int index, ret, count, len;
 	const u32 *cell;
 
diff --git a/drivers/video/rockchip/rk_lvds.c b/drivers/video/rockchip/rk_lvds.c
index fcbb4d6..ee43255 100644
--- a/drivers/video/rockchip/rk_lvds.c
+++ b/drivers/video/rockchip/rk_lvds.c
@@ -162,7 +162,7 @@
 int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing)
 {
 	if (fdtdec_decode_display_timing
-	    (gd->fdt_blob, dev->of_offset, 0, timing)) {
+	    (gd->fdt_blob, dev_of_offset(dev), 0, timing)) {
 		debug("%s: Failed to decode display timing\n", __func__);
 		return -EINVAL;
 	}
@@ -174,7 +174,7 @@
 {
 	struct rk_lvds_priv *priv = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 	priv->regs = (void *)dev_get_addr(dev);
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c
index eab5486..aeecb58 100644
--- a/drivers/video/rockchip/rk_vop.c
+++ b/drivers/video/rockchip/rk_vop.c
@@ -321,7 +321,7 @@
 	 * clock so it is currently not possible to use more than one display
 	 * device simultaneously.
 	 */
-	port = fdt_subnode_offset(blob, dev->of_offset, "port");
+	port = fdt_subnode_offset(blob, dev_of_offset(dev), "port");
 	if (port < 0)
 		return -EINVAL;
 	for (node = fdt_first_subnode(blob, port);
diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c
index dc5a220..18afe2f 100644
--- a/drivers/video/sandbox_sdl.c
+++ b/drivers/video/sandbox_sdl.c
@@ -46,7 +46,7 @@
 	struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
 	struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret = 0;
 
 	plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c
index 92214d6..0ba3f2c 100644
--- a/drivers/video/tegra.c
+++ b/drivers/video/tegra.c
@@ -338,7 +338,7 @@
 	struct tegra_lcd_priv *priv = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
 	struct display_timing *timing;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int panel_node;
 	int rgb;
 	int ret;
@@ -392,7 +392,7 @@
 {
 	struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int rgb;
 
 	rgb = fdt_subnode_offset(blob, node, "rgb");
diff --git a/drivers/video/tegra124/display.c b/drivers/video/tegra124/display.c
index 28db96c..bbbca13b 100644
--- a/drivers/video/tegra124/display.c
+++ b/drivers/video/tegra124/display.c
@@ -363,9 +363,9 @@
 		return ret;
 	}
 
-	dc_ctlr = (struct dc_ctlr *)fdtdec_get_addr(blob, dev->of_offset,
+	dc_ctlr = (struct dc_ctlr *)fdtdec_get_addr(blob, dev_of_offset(dev),
 						    "reg");
-	if (fdtdec_decode_display_timing(blob, dev->of_offset, 0, timing)) {
+	if (fdtdec_decode_display_timing(blob, dev_of_offset(dev), 0, timing)) {
 		debug("%s: Failed to decode display timing\n", __func__);
 		return -EINVAL;
 	}
diff --git a/drivers/video/tegra124/sor.c b/drivers/video/tegra124/sor.c
index e5cea51..5e4140f 100644
--- a/drivers/video/tegra124/sor.c
+++ b/drivers/video/tegra124/sor.c
@@ -757,7 +757,7 @@
 
 	/* Use the first display controller */
 	debug("%s\n", __func__);
-	node = dc_dev->of_offset;
+	node = dev_of_offset(dc_dev);
 	disp_ctrl = (struct dc_ctlr *)fdtdec_get_addr(blob, node, "reg");
 
 	tegra_dc_sor_enable_dc(disp_ctrl);
@@ -973,7 +973,7 @@
 
 	debug("%s\n", __func__);
 	/* Use the first display controller */
-	node = dc_dev->of_offset;
+	node = dev_of_offset(dc_dev);
 	disp_ctrl = (struct dc_ctlr *)fdtdec_get_addr(blob, node, "reg");
 
 	/* Sleep mode */
@@ -1045,7 +1045,7 @@
 	int node;
 	int ret;
 
-	priv->base = (void *)fdtdec_get_addr(blob, dev->of_offset, "reg");
+	priv->base = (void *)fdtdec_get_addr(blob, dev_of_offset(dev), "reg");
 
 	node = fdtdec_next_compatible(blob, 0, COMPAT_NVIDIA_TEGRA124_PMC);
 	if (node < 0) {
diff --git a/include/dm/device.h b/include/dm/device.h
index 9948bd4..4e95fb7 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -121,6 +121,16 @@
 /* Returns non-zero if the device is active (probed and not removed) */
 #define device_active(dev)	((dev)->flags & DM_FLAG_ACTIVATED)
 
+static inline int dev_of_offset(const struct udevice *dev)
+{
+	return dev->of_offset;
+}
+
+static inline void dev_set_of_offset(struct udevice *dev, int of_offset)
+{
+	dev->of_offset = of_offset;
+}
+
 /**
  * struct udevice_id - Lists the compatible strings supported by a driver
  * @compatible: Compatible string
diff --git a/test/dm/spi.c b/test/dm/spi.c
index 5733096..f52cb73 100644
--- a/test/dm/spi.c
+++ b/test/dm/spi.c
@@ -35,7 +35,7 @@
 	 */
 	ut_asserteq(0, uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus));
 	ut_assertok(spi_cs_info(bus, cs, &info));
-	of_offset = info.dev->of_offset;
+	of_offset = dev_of_offset(info.dev);
 	device_remove(info.dev);
 	device_unbind(info.dev);
 
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 49a36cb..3048a7b 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -37,9 +37,9 @@
 {
 	struct dm_test_pdata *pdata = dev_get_platdata(dev);
 
-	pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					"ping-add", -1);
-	pdata->base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset,
+	pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev),
 				      "ping-expect");
 
 	return 0;
@@ -121,10 +121,10 @@
 		 * want to test the code that sets that up
 		 * (testfdt_drv_probe()).
 		 */
-		base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset,
+		base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev),
 				       "ping-expect");
 		debug("dev=%d, base=%d: %s\n", i, base,
-		      fdt_get_name(gd->fdt_blob, dev->of_offset, NULL));
+		      fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL));
 
 		ut_assert(!dm_check_operations(uts, dev, base,
 					       dev_get_priv(dev)));