Skip to content

Commit

Permalink
net: thunderx: Use fwnode_get_mac_address()
Browse files Browse the repository at this point in the history
Replace the custom implementation with fwnode_get_mac_address,
which works on both DT and ACPI platforms.

While here, replace memcpy() by ether_addr_copy().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andy Shevchenko authored and David S. Miller committed Jul 23, 2019
1 parent a261e37 commit d86afb8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions drivers/net/ethernet/cavium/thunder/thunder_bgx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1381,24 +1381,18 @@ static int acpi_get_mac_address(struct device *dev, struct acpi_device *adev,
u8 *dst)
{
u8 mac[ETH_ALEN];
int ret;
u8 *addr;

ret = fwnode_property_read_u8_array(acpi_fwnode_handle(adev),
"mac-address", mac, ETH_ALEN);
if (ret)
goto out;

if (!is_valid_ether_addr(mac)) {
addr = fwnode_get_mac_address(acpi_fwnode_handle(adev), mac, ETH_ALEN);
if (!addr) {
dev_err(dev, "MAC address invalid: %pM\n", mac);
ret = -EINVAL;
goto out;
return -EINVAL;
}

dev_info(dev, "MAC address set to: %pM\n", mac);

memcpy(dst, mac, ETH_ALEN);
out:
return ret;
ether_addr_copy(dst, mac);
return 0;
}

/* Currently only sets the MAC address. */
Expand Down

0 comments on commit d86afb8

Please sign in to comment.