treewide: backport support for nvmem on non platform devices
[openwrt/openwrt.git] / target / linux / bcm4908 / patches-5.4 / 074-v5.13-0001-net-broadcom-bcm4908_enet-read-MAC-from-OF.patch
index 4b8e1f83b883219593dd82aa0787ce3128fefde7..df004c0480af2f2073e11f382d45f8b0de73132a 100644 (file)
@@ -25,23 +25,13 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
  #include <linux/platform_device.h>
  #include <linux/slab.h>
  #include <linux/string.h>
-@@ -620,6 +621,7 @@ static int bcm4908_enet_probe(struct pla
-       struct device *dev = &pdev->dev;
-       struct net_device *netdev;
-       struct bcm4908_enet *enet;
-+      const u8 *mac;
-       int err;
-       netdev = devm_alloc_etherdev(dev, sizeof(*enet));
-@@ -647,7 +649,11 @@ static int bcm4908_enet_probe(struct pla
+@@ -647,7 +649,9 @@ static int bcm4908_enet_probe(struct pla
                return err;
  
        SET_NETDEV_DEV(netdev, &pdev->dev);
 -      eth_hw_addr_random(netdev);
-+      mac = of_get_mac_address(dev->of_node);
-+      if (!IS_ERR(mac))
-+              ether_addr_copy(netdev->dev_addr, mac);
-+      else
++      of_get_mac_address(dev->of_node, netdev->dev_addr);
++      if (!is_valid_ether_addr(netdev->dev_addr))
 +              eth_hw_addr_random(netdev);
        netdev->netdev_ops = &bcm4908_enet_netdev_ops;
        netdev->min_mtu = ETH_ZLEN;