Thread (2 messages) 2 messages, 2 authors, 2021-06-16
STALE1867d

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

From: Michael Grzeschik <hidden>
Date: 2021-06-15 21:10:59
Subsystem: networking [general], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

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

Signed-off-by: Michael Grzeschik <redacted>
---
 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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help