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: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jakub Kicinski 2021-10-06 18:07:02 -07:00 committed by David S. Miller
parent b8eeac565b
commit 894b0fb092
4 changed files with 6 additions and 18 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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 */

View File

@ -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;