[PATCH] of: net: Add option for random mac address
From: Iulian Gilca
Date: Thu Oct 10 2024 - 15:28:14 EST
Embedded devices that may not have fixed mac address
may want to use a randomly generated one.
DSA switch ports are some of these.
Signed-off-by: Iulian Gilca <igilca1980@xxxxxxxxx>
---
net/core/of_net.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/core/of_net.c b/net/core/of_net.c
index 93ea425b9248..aa4acdffc710 100644
--- a/net/core/of_net.c
+++ b/net/core/of_net.c
@@ -142,6 +142,10 @@ int of_get_mac_address(struct device_node *np, u8 *addr)
if (!ret)
return 0;
+ ret = of_get_mac_addr(np, "random-address", addr);
+ if (!ret)
+ return 0;
+
return of_get_mac_address_nvmem(np, addr);
}
EXPORT_SYMBOL(of_get_mac_address);
--
2.43.0