[PATCH v2 07/13] net: fec_imx: use of_get_mac_address() to get mac address out of DT

Oleksij Rempel o.rempel at pengutronix.de
Wed Aug 5 06:16:22 EDT 2020


A mac address can be provided by the DT over nvmem cell. Start to use
of_get_mac_address() since it will be able to read nvmem cell for us.

Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
---
 drivers/net/fec_imx.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 0c2d600d12..65dbb1d9c0 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -628,6 +628,7 @@ static void fec_free_receive_packets(struct fec_priv *fec, int count, int size)
 static int fec_probe_dt(struct device_d *dev, struct fec_priv *fec)
 {
 	struct device_node *mdiobus;
+	const char *mac_addr;
 	int ret;
 
 	ret = of_get_phy_mode(dev->device_node);
@@ -640,6 +641,19 @@ static int fec_probe_dt(struct device_d *dev, struct fec_priv *fec)
 	if (mdiobus)
 		fec->miibus.dev.device_node = mdiobus;
 
+	mac_addr = of_get_mac_address(dev->device_node);
+	if (IS_ERR(mac_addr)) {
+		if (PTR_ERR(mac_addr) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		else
+			dev_err(fec->dev, "Failed on of_get_mac_address: %li\n",
+				PTR_ERR(mac_addr));
+	} else {
+		of_eth_register_ethaddr(dev->device_node, mac_addr);
+
+		kfree(mac_addr);
+	}
+
 	return 0;
 }
 #else
-- 
2.28.0




More information about the barebox mailing list