blob: 4b8e1f83b883219593dd82aa0787ce3128fefde7 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 3559c1ea4336636c886002996d50805365d3055c Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3Date: Wed, 10 Mar 2021 09:48:13 +0100
4Subject: [PATCH] net: broadcom: bcm4908_enet: read MAC from OF
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9BCM4908 devices have MAC address accessible using NVMEM so it's needed
10to use OF helper for reading it.
11
12Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
13Signed-off-by: David S. Miller <davem@davemloft.net>
14---
15 drivers/net/ethernet/broadcom/bcm4908_enet.c | 8 +++++++-
16 1 file changed, 7 insertions(+), 1 deletion(-)
17
18--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
19+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
20@@ -9,6 +9,7 @@
21 #include <linux/interrupt.h>
22 #include <linux/module.h>
23 #include <linux/of.h>
24+#include <linux/of_net.h>
25 #include <linux/platform_device.h>
26 #include <linux/slab.h>
27 #include <linux/string.h>
28@@ -620,6 +621,7 @@ static int bcm4908_enet_probe(struct pla
29 struct device *dev = &pdev->dev;
30 struct net_device *netdev;
31 struct bcm4908_enet *enet;
32+ const u8 *mac;
33 int err;
34
35 netdev = devm_alloc_etherdev(dev, sizeof(*enet));
36@@ -647,7 +649,11 @@ static int bcm4908_enet_probe(struct pla
37 return err;
38
39 SET_NETDEV_DEV(netdev, &pdev->dev);
40- eth_hw_addr_random(netdev);
41+ mac = of_get_mac_address(dev->of_node);
42+ if (!IS_ERR(mac))
43+ ether_addr_copy(netdev->dev_addr, mac);
44+ else
45+ eth_hw_addr_random(netdev);
46 netdev->netdev_ops = &bcm4908_enet_netdev_ops;
47 netdev->min_mtu = ETH_ZLEN;
48 netdev->mtu = ETH_DATA_LEN;