diff options
author | Ezequiel Garcia <ezequiel.garcia@free-electrons.com> | 2014-05-22 19:07:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-23 15:31:49 -0400 |
commit | e68de36072e1b9012bc07fe18f83a6c30ce3d260 (patch) | |
tree | c4151a7e3906f130ae4fe2efb1aba9fad9367664 /drivers | |
parent | 9672850be34c1c3db3b98605c0bee9c58545cdca (diff) |
net: mvneta: Use prepare/commit API to simplify MAC address setting
Use eth_prepare_mac_addr_change and eth_commit_mac_addr_change, instead
of manually checking and storing the MAC address, which makes the
code slightly more robust. This fixes the lack of valid MAC address check
in the driver's .ndo_set_mac_address hook.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/marvell/mvneta.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 66e46318e04f..dd84b6a639fa 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c | |||
@@ -2473,22 +2473,19 @@ static void mvneta_get_mac_addr(struct mvneta_port *pp, unsigned char *addr) | |||
2473 | static int mvneta_set_mac_addr(struct net_device *dev, void *addr) | 2473 | static int mvneta_set_mac_addr(struct net_device *dev, void *addr) |
2474 | { | 2474 | { |
2475 | struct mvneta_port *pp = netdev_priv(dev); | 2475 | struct mvneta_port *pp = netdev_priv(dev); |
2476 | u8 *mac = addr + 2; | 2476 | struct sockaddr *sockaddr = addr; |
2477 | int i; | 2477 | int ret; |
2478 | |||
2479 | if (netif_running(dev)) | ||
2480 | return -EBUSY; | ||
2481 | 2478 | ||
2479 | ret = eth_prepare_mac_addr_change(dev, addr); | ||
2480 | if (ret < 0) | ||
2481 | return ret; | ||
2482 | /* Remove previous address table entry */ | 2482 | /* Remove previous address table entry */ |
2483 | mvneta_mac_addr_set(pp, dev->dev_addr, -1); | 2483 | mvneta_mac_addr_set(pp, dev->dev_addr, -1); |
2484 | 2484 | ||
2485 | /* Set new addr in hw */ | 2485 | /* Set new addr in hw */ |
2486 | mvneta_mac_addr_set(pp, mac, rxq_def); | 2486 | mvneta_mac_addr_set(pp, sockaddr->sa_data, rxq_def); |
2487 | |||
2488 | /* Set addr in the device */ | ||
2489 | for (i = 0; i < ETH_ALEN; i++) | ||
2490 | dev->dev_addr[i] = mac[i]; | ||
2491 | 2487 | ||
2488 | eth_commit_mac_addr_change(dev, addr); | ||
2492 | return 0; | 2489 | return 0; |
2493 | } | 2490 | } |
2494 | 2491 | ||
@@ -2583,8 +2580,6 @@ static int mvneta_open(struct net_device *dev) | |||
2583 | struct mvneta_port *pp = netdev_priv(dev); | 2580 | struct mvneta_port *pp = netdev_priv(dev); |
2584 | int ret; | 2581 | int ret; |
2585 | 2582 | ||
2586 | mvneta_mac_addr_set(pp, dev->dev_addr, rxq_def); | ||
2587 | |||
2588 | pp->pkt_size = MVNETA_RX_PKT_SIZE(pp->dev->mtu); | 2583 | pp->pkt_size = MVNETA_RX_PKT_SIZE(pp->dev->mtu); |
2589 | pp->frag_size = SKB_DATA_ALIGN(MVNETA_RX_BUF_SIZE(pp->pkt_size)) + | 2584 | pp->frag_size = SKB_DATA_ALIGN(MVNETA_RX_BUF_SIZE(pp->pkt_size)) + |
2590 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); | 2585 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); |