[PATCH] net/eth: read default mac-address default from dts

Michael Grzeschik m.grzeschik at pengutronix.de
Tue Jun 15 08:32:23 PDT 2021


Since we have the functino of_get_mac_address we can
use it to set the default mac address vom the dts.

Signed-off-by: Michael Grzeschik <m.grzeschik at pengutronix.de>
---
 net/eth.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/eth.c b/net/eth.c
index 84f99d3aa8..baebf89d89 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -11,6 +11,7 @@
 #include <net.h>
 #include <dma.h>
 #include <of.h>
+#include <of_net.h>
 #include <linux/phy.h>
 #include <errno.h>
 #include <malloc.h>
@@ -431,6 +432,14 @@ int eth_register(struct eth_device *edev)
 	if (!ret)
 		found = 1;
 
+	if (!found && edev->parent) {
+		const u8 *maddr = of_get_mac_address(edev->parent->device_node);
+		if (maddr) {
+			memcpy(ethaddr, maddr, ETH_ALEN);
+			found = 1;
+		}
+	}
+
 	if (!found) {
 		ret = edev->get_ethaddr(edev, ethaddr);
 		if (!ret)
-- 
2.29.2




More information about the barebox mailing list