[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250904100916.126571-3-wahrenst@gmx.net>
Date: Thu, 4 Sep 2025 12:09:16 +0200
From: Stefan Wahren <wahrenst@....net>
To: Parthiban Veerasooran <parthiban.veerasooran@...rochip.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org,
Stefan Wahren <wahrenst@....net>
Subject: [PATCH RFC 2/2 next] microchip: lan865x: Allow to fetch MAC from NVMEM
A lot of modern SoC have the ability to store MAC addresses in
their NVMEM. The generic function device_get_ethdev_address()
doesn't provide this feature. So try to fetch the MAC from
NVMEM if the generic function fails.
Signed-off-by: Stefan Wahren <wahrenst@....net>
--
drivers/net/ethernet/microchip/lan865x/lan865x.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan865x/lan865x.c b/drivers/net/ethernet/microchip/lan865x/lan865x.c
index 0277d9737369..70e6b38da2e6 100644
--- a/drivers/net/ethernet/microchip/lan865x/lan865x.c
+++ b/drivers/net/ethernet/microchip/lan865x/lan865x.c
@@ -9,6 +9,8 @@
#include <linux/kernel.h>
#include <linux/phy.h>
#include <linux/oa_tc6.h>
+#include <linux/of.h>
+#include <linux/of_net.h>
#define DRV_NAME "lan8650"
@@ -386,8 +388,11 @@ static int lan865x_probe(struct spi_device *spi)
}
/* Get the MAC address from the SPI device tree node */
- if (device_get_ethdev_address(&spi->dev, netdev))
- eth_hw_addr_random(netdev);
+ if (device_get_ethdev_address(&spi->dev, netdev)) {
+ /* Get the MAC address from NVMEM */
+ if (of_get_ethdev_address(spi->dev.of_node, netdev))
+ eth_hw_addr_random(netdev);
+ }
ret = lan865x_set_hw_macaddr(priv, netdev->dev_addr);
if (ret) {
--
2.34.1
Powered by blists - more mailing lists