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/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;