]> www.infradead.org Git - users/hch/misc.git/commitdiff
ethernet: Extend device_get_mac_address() to use NVMEM
authorStefan Wahren <wahrenst@gmx.net>
Fri, 12 Sep 2025 14:03:32 +0000 (16:03 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 16 Sep 2025 01:34:08 +0000 (18:34 -0700)
A lot of modern SoC have the ability to store MAC addresses in their
NVMEM. So extend the generic function device_get_mac_address() to
obtain the MAC address from an nvmem cell named 'mac-address' in
case there is no firmware node which contains the MAC address directly.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20250912140332.35395-3-wahrenst@gmx.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ethernet/eth.c

index 4e3651101b8660064a29a24b74263c1d522c9d01..43e211e611b1698cbec5f6256ffd59975584bf04 100644 (file)
@@ -613,7 +613,10 @@ EXPORT_SYMBOL(fwnode_get_mac_address);
  */
 int device_get_mac_address(struct device *dev, char *addr)
 {
-       return fwnode_get_mac_address(dev_fwnode(dev), addr);
+       if (!fwnode_get_mac_address(dev_fwnode(dev), addr))
+               return 0;
+
+       return nvmem_get_mac_address(dev, addr);
 }
 EXPORT_SYMBOL(device_get_mac_address);