Skip to content

Commit

Permalink
net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_add…
Browse files Browse the repository at this point in the history
…ress()

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>
  • Loading branch information
Łukasz Stelmach authored and David S. Miller committed Oct 2, 2020
1 parent a3d0ba8 commit 4f359b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions drivers/net/usb/smsc75xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
13 changes: 7 additions & 6 deletions drivers/net/usb/smsc95xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 4f359b6

Please sign in to comment.