aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/octeon/octeon_mgmt.c
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2012-08-21 14:45:10 -0400
committerDavid Daney <david.daney@cavium.com>2012-08-31 14:49:54 -0400
commitf321238b17040ce9ba671d5aff7ad540c6c6ace4 (patch)
tree022122d6886e3bb8b78fe58a3c0e3703bf913d12 /drivers/net/ethernet/octeon/octeon_mgmt.c
parent052958e347a0219313730ee7c437edfab0611ec1 (diff)
netdev: octeon_mgmt: Cleanup and modernize MAC address handling.
Use eth_mac_addr(), and generate a random address if none is otherwise assigned. Signed-off-by: David Daney <david.daney@cavium.com> Acked-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/octeon/octeon_mgmt.c')
-rw-r--r--drivers/net/ethernet/octeon/octeon_mgmt.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/net/ethernet/octeon/octeon_mgmt.c b/drivers/net/ethernet/octeon/octeon_mgmt.c
index 3bae01f4669b..9b526da79af7 100644
--- a/drivers/net/ethernet/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/octeon/octeon_mgmt.c
@@ -648,12 +648,10 @@ static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
648 648
649static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr) 649static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
650{ 650{
651 struct sockaddr *sa = addr; 651 int r = eth_mac_addr(netdev, addr);
652 652
653 if (!is_valid_ether_addr(sa->sa_data)) 653 if (r)
654 return -EADDRNOTAVAIL; 654 return r;
655
656 memcpy(netdev->dev_addr, sa->sa_data, ETH_ALEN);
657 655
658 octeon_mgmt_set_rx_filtering(netdev); 656 octeon_mgmt_set_rx_filtering(netdev);
659 657
@@ -1545,8 +1543,12 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
1545 1543
1546 mac = of_get_mac_address(pdev->dev.of_node); 1544 mac = of_get_mac_address(pdev->dev.of_node);
1547 1545
1548 if (mac) 1546 if (mac && is_valid_ether_addr(mac)) {
1549 memcpy(netdev->dev_addr, mac, 6); 1547 memcpy(netdev->dev_addr, mac, ETH_ALEN);
1548 netdev->addr_assign_type &= ~NET_ADDR_RANDOM;
1549 } else {
1550 eth_hw_addr_random(netdev);
1551 }
1550 1552
1551 p->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); 1553 p->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
1552 1554