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:
parent
b8eeac565b
commit
894b0fb092
|
@ -183,10 +183,9 @@ static void ftgmac100_initial_mac(struct ftgmac100 *priv)
|
||||||
unsigned int m;
|
unsigned int m;
|
||||||
unsigned int l;
|
unsigned int l;
|
||||||
|
|
||||||
if (!device_get_mac_address(priv->dev, mac)) {
|
if (!device_get_ethdev_address(priv->dev, priv->netdev)) {
|
||||||
eth_hw_addr_set(priv->netdev, mac);
|
|
||||||
dev_info(priv->dev, "Read MAC address %pM from device tree\n",
|
dev_info(priv->dev, "Read MAC address %pM from device tree\n",
|
||||||
mac);
|
priv->netdev->dev_addr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1539,7 +1539,6 @@ static const struct net_device_ops enc28j60_netdev_ops = {
|
||||||
|
|
||||||
static int enc28j60_probe(struct spi_device *spi)
|
static int enc28j60_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
unsigned char macaddr[ETH_ALEN];
|
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct enc28j60_net *priv;
|
struct enc28j60_net *priv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -1572,9 +1571,7 @@ static int enc28j60_probe(struct spi_device *spi)
|
||||||
goto error_irq;
|
goto error_irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device_get_mac_address(&spi->dev, macaddr))
|
if (device_get_ethdev_address(&spi->dev, dev))
|
||||||
eth_hw_addr_set(dev, macaddr);
|
|
||||||
else
|
|
||||||
eth_hw_addr_random(dev);
|
eth_hw_addr_random(dev);
|
||||||
enc28j60_set_hw_macaddr(dev);
|
enc28j60_set_hw_macaddr(dev);
|
||||||
|
|
||||||
|
|
|
@ -545,13 +545,10 @@ static int emac_probe_resources(struct platform_device *pdev,
|
||||||
struct emac_adapter *adpt)
|
struct emac_adapter *adpt)
|
||||||
{
|
{
|
||||||
struct net_device *netdev = adpt->netdev;
|
struct net_device *netdev = adpt->netdev;
|
||||||
char maddr[ETH_ALEN];
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* get mac address */
|
/* get mac address */
|
||||||
if (!device_get_mac_address(&pdev->dev, maddr))
|
if (device_get_ethdev_address(&pdev->dev, netdev))
|
||||||
eth_hw_addr_set(netdev, maddr);
|
|
||||||
else
|
|
||||||
eth_hw_addr_random(netdev);
|
eth_hw_addr_random(netdev);
|
||||||
|
|
||||||
/* Core 0 interrupt */
|
/* Core 0 interrupt */
|
||||||
|
|
|
@ -1981,7 +1981,6 @@ static int netsec_probe(struct platform_device *pdev)
|
||||||
struct netsec_priv *priv;
|
struct netsec_priv *priv;
|
||||||
u32 hw_ver, phy_addr = 0;
|
u32 hw_ver, phy_addr = 0;
|
||||||
struct net_device *ndev;
|
struct net_device *ndev;
|
||||||
u8 macbuf[ETH_ALEN];
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mmio_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
mmio_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
|
@ -2034,12 +2033,8 @@ static int netsec_probe(struct platform_device *pdev)
|
||||||
goto free_ndev;
|
goto free_ndev;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = device_get_mac_address(&pdev->dev, macbuf);
|
ret = device_get_ethdev_address(&pdev->dev, ndev);
|
||||||
if (!ret)
|
if (ret && priv->eeprom_base) {
|
||||||
eth_hw_addr_set(ndev, macbuf);
|
|
||||||
|
|
||||||
if (priv->eeprom_base &&
|
|
||||||
(ret || !is_valid_ether_addr(ndev->dev_addr))) {
|
|
||||||
void __iomem *macp = priv->eeprom_base +
|
void __iomem *macp = priv->eeprom_base +
|
||||||
NETSEC_EEPROM_MAC_ADDRESS;
|
NETSEC_EEPROM_MAC_ADDRESS;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue