Thread (6 messages) 6 messages, 2 authors, 2025-09-01
STALE298d

[PATCH net-next 1/2] net: lan966x: use of_get_mac_address

From: Rosen Penev <hidden>
Date: 2025-08-27 21:50:45
Also in: lkml
Subsystem: microchip lan966x ethernet driver, networking drivers, the rest · Maintainers: Horatiu Vultur, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

As lan966x is an OF driver, switching to the OF version allows usage of
NVMEM to override the MAC address of the interface.

Handle EPROBE_DEFER in the case that NVMEM loads after lan966x.

Signed-off-by: Rosen Penev <redacted>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 7001584f1b7a..8bf28915c030 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -1083,7 +1083,6 @@ static int lan966x_probe(struct platform_device *pdev)
 {
 	struct fwnode_handle *ports, *portnp;
 	struct lan966x *lan966x;
-	u8 mac_addr[ETH_ALEN];
 	int err;
 
 	lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL);
@@ -1093,9 +1092,11 @@ static int lan966x_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, lan966x);
 	lan966x->dev = &pdev->dev;
 
-	if (!device_get_mac_address(&pdev->dev, mac_addr)) {
-		ether_addr_copy(lan966x->base_mac, mac_addr);
-	} else {
+	err = of_get_mac_address(pdev->dev.of_node, lan966x->base_mac);
+	if (err == -EPROBE_DEFER)
+		return err;
+
+	if (err) {
 		pr_info("MAC addr was not set, use random MAC\n");
 		eth_random_addr(lan966x->base_mac);
 		lan966x->base_mac[5] &= 0xf0;
-- 
2.51.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help