Commit 894b0fb0 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

ethernet: make more use of device_get_ethdev_address()

Convert a few drivers to device_get_ethdev_address(),
saving a few LoC.

The check if addr is valid in netsec is superfluous,
device_get_ethdev_addr() already checks that (in
fwnode_get_mac_addr()).
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b8eeac56
......@@ -183,10 +183,9 @@ static void ftgmac100_initial_mac(struct ftgmac100 *priv)
unsigned int m;
unsigned int l;
if (!device_get_mac_address(priv->dev, mac)) {
eth_hw_addr_set(priv->netdev, mac);
if (!device_get_ethdev_address(priv->dev, priv->netdev)) {
dev_info(priv->dev, "Read MAC address %pM from device tree\n",
mac);
priv->netdev->dev_addr);
return;
}
......
......@@ -1539,7 +1539,6 @@ static const struct net_device_ops enc28j60_netdev_ops = {
static int enc28j60_probe(struct spi_device *spi)
{
unsigned char macaddr[ETH_ALEN];
struct net_device *dev;
struct enc28j60_net *priv;
int ret = 0;
......@@ -1572,9 +1571,7 @@ static int enc28j60_probe(struct spi_device *spi)
goto error_irq;
}
if (!device_get_mac_address(&spi->dev, macaddr))
eth_hw_addr_set(dev, macaddr);
else
if (device_get_ethdev_address(&spi->dev, dev))
eth_hw_addr_random(dev);
enc28j60_set_hw_macaddr(dev);
......
......@@ -545,13 +545,10 @@ static int emac_probe_resources(struct platform_device *pdev,
struct emac_adapter *adpt)
{
struct net_device *netdev = adpt->netdev;
char maddr[ETH_ALEN];
int ret = 0;
/* get mac address */
if (!device_get_mac_address(&pdev->dev, maddr))
eth_hw_addr_set(netdev, maddr);
else
if (device_get_ethdev_address(&pdev->dev, netdev))
eth_hw_addr_random(netdev);
/* Core 0 interrupt */
......
......@@ -1981,7 +1981,6 @@ static int netsec_probe(struct platform_device *pdev)
struct netsec_priv *priv;
u32 hw_ver, phy_addr = 0;
struct net_device *ndev;
u8 macbuf[ETH_ALEN];
int ret;
mmio_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
......@@ -2034,12 +2033,8 @@ static int netsec_probe(struct platform_device *pdev)
goto free_ndev;
}
ret = device_get_mac_address(&pdev->dev, macbuf);
if (!ret)
eth_hw_addr_set(ndev, macbuf);
if (priv->eeprom_base &&
(ret || !is_valid_ether_addr(ndev->dev_addr))) {
ret = device_get_ethdev_address(&pdev->dev, ndev);
if (ret && priv->eeprom_base) {
void __iomem *macp = priv->eeprom_base +
NETSEC_EEPROM_MAC_ADDRESS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment