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