Skip to content

Commit

Permalink
net: ethernet: improve eth_platform_get_mac_address
Browse files Browse the repository at this point in the history
pci_device_to_OF_node(to_pci_dev(dev)) is the same as dev->of_node,
so we can simplify the code. In addition add an empty line before
the return statement.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
hkallweit authored and davem330 committed Jun 3, 2019
1 parent feb3cf2 commit db4bad0
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions net/ethernet/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,24 +549,18 @@ unsigned char * __weak arch_get_platform_mac_address(void)

int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr)
{
const unsigned char *addr;
struct device_node *dp;
const unsigned char *addr = NULL;

if (dev_is_pci(dev))
dp = pci_device_to_OF_node(to_pci_dev(dev));
else
dp = dev->of_node;

addr = NULL;
if (dp)
addr = of_get_mac_address(dp);
if (dev->of_node)
addr = of_get_mac_address(dev->of_node);
if (IS_ERR_OR_NULL(addr))
addr = arch_get_platform_mac_address();

if (!addr)
return -ENODEV;

ether_addr_copy(mac_addr, addr);

return 0;
}
EXPORT_SYMBOL(eth_platform_get_mac_address);
Expand Down

0 comments on commit db4bad0

Please sign in to comment.