Skip to content

Commit

Permalink
davinci_emac: use eth_hw_addr_random() instead of random_ether_addr()
Browse files Browse the repository at this point in the history
Use eth_hw_addr_random() instead of calling random_ether_addr()
to set addr_assign_type correctly to NET_ADDR_RANDOM.

Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.

Remove one memcpy from emac_dev_setmac_addr() since this is a
duplicate: it's already done some lines above.

v2: use bitops, adapt to eth_hw_addr_random, remove a memcpy

Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Danny Kukawka authored and David S. Miller committed Feb 17, 2012
1 parent 43aabec commit baf1d37
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/ethernet/ti/davinci_emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,10 +1259,10 @@ static int emac_dev_setmac_addr(struct net_device *ndev, void *addr)
/* Store mac addr in priv and rx channel and set it in EMAC hw */
memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len);
memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len);
ndev->addr_assign_type &= ~NET_ADDR_RANDOM;

/* MAC address is configured only after the interface is enabled. */
if (netif_running(ndev)) {
memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len);
emac_setmac(priv, EMAC_DEF_RX_CH, priv->mac_addr);
}

Expand Down Expand Up @@ -1896,7 +1896,8 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)

if (!is_valid_ether_addr(priv->mac_addr)) {
/* Use random MAC if none passed */
random_ether_addr(priv->mac_addr);
eth_hw_addr_random(ndev);
memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
priv->mac_addr);
}
Expand Down

0 comments on commit baf1d37

Please sign in to comment.