mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net/eth: read default mac-address default from dts
@ 2021-06-15 17:17 Michael Grzeschik
  2021-06-16  7:14 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Grzeschik @ 2021-06-15 17:17 UTC (permalink / raw)
  To: barebox

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 <m.grzeschik@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH] net/eth: read default mac-address default from dts
@ 2021-06-15 15:32 Michael Grzeschik
  2021-06-15 20:32 ` Trent Piepho
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Grzeschik @ 2021-06-15 15:32 UTC (permalink / raw)
  To: barebox

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-21  6:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 17:17 [PATCH] net/eth: read default mac-address default from dts Michael Grzeschik
2021-06-16  7:14 ` Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2021-06-15 15:32 Michael Grzeschik
2021-06-15 20:32 ` Trent Piepho
2021-06-21  6:42   ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox