dm: core: Replace of_offset with accessor

At present devices use a simple integer offset to record the device tree
node associated with the device. In preparation for supporting a live
device tree, which uses a node pointer instead, refactor existing code to
access this field through an inline function.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/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) {