]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address()
authorŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 30 Sep 2020 14:25:25 +0000 (16:25 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Oct 2020 22:21:17 +0000 (15:21 -0700)
Use more generic eth_platform_get_mac_address() which can get a MAC
address from other than DT platform specific sources too. Check if the
obtained address is valid.

Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/smsc75xx.c
drivers/net/usb/smsc95xx.c

index 9556d431885f53634d303ed93bc5a8d6643f97a9..8689835a52145208517d04d7465103babf4571f1 100644 (file)
@@ -757,13 +757,14 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 
 static void smsc75xx_init_mac_address(struct usbnet *dev)
 {
-       const u8 *mac_addr;
-
        /* maybe the boot loader passed the MAC address in devicetree */
-       mac_addr = of_get_mac_address(dev->udev->dev.of_node);
-       if (!IS_ERR(mac_addr)) {
-               ether_addr_copy(dev->net->dev_addr, mac_addr);
-               return;
+       if (!eth_platform_get_mac_address(&dev->udev->dev,
+                       dev->net->dev_addr)) {
+               if (is_valid_ether_addr(dev->net->dev_addr)) {
+                       /* device tree values are valid so use them */
+                       netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
+                       return;
+               }
        }
 
        /* try reading mac address from EEPROM */
index 601fb40a2a0a89fd824ec8976f23113bcc63ae2c..ea0d5f04dc3a80c2703c03c92a57bd0de903b626 100644 (file)
@@ -755,13 +755,14 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 
 static void smsc95xx_init_mac_address(struct usbnet *dev)
 {
-       const u8 *mac_addr;
-
        /* maybe the boot loader passed the MAC address in devicetree */
-       mac_addr = of_get_mac_address(dev->udev->dev.of_node);
-       if (!IS_ERR(mac_addr)) {
-               ether_addr_copy(dev->net->dev_addr, mac_addr);
-               return;
+       if (!eth_platform_get_mac_address(&dev->udev->dev,
+                       dev->net->dev_addr)) {
+               if (is_valid_ether_addr(dev->net->dev_addr)) {
+                       /* device tree values are valid so use them */
+                       netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
+                       return;
+               }
        }
 
        /* try reading mac address from EEPROM */