Commit 4f359b65 authored by Łukasz Stelmach's avatar Łukasz Stelmach Committed by David S. Miller
Browse files

net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address()



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: default avatarŁukasz Stelmach <l.stelmach@samsung.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a3d0ba88
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -757,14 +757,15 @@ 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);
	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 */
	if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
+7 −6
Original line number Diff line number Diff line
@@ -755,14 +755,15 @@ 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);
	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 */
	if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,