diff options
author | Danny Kukawka <danny.kukawka@bisect.de> | 2012-02-16 02:09:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-02-19 19:03:04 -0500 |
commit | 5055d2f236e1495d68c468eeb684fd5789673f1d (patch) | |
tree | 603d6ce83fc899461ab1e7862c9e2ad94ef73023 /drivers/net/ethernet/adi | |
parent | fa63c6da22b4a6ea6e7d04e3dc9178dd72304903 (diff) |
adi: adapt to eth_hw_addr_random() and changes in arch/blackfin
Adapt adi ethernet driver to changes in bfin_get_ether_addr()
from arch/blackfin. bfin_get_ether_addr() returns now a state.
Set a random mac address via new eth_hw_addr_random() in case
the return value is not 0.
Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.
v2: change the logic to reduce unneeded checks
Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/adi')
-rw-r--r-- | drivers/net/ethernet/adi/bfin_mac.c | 15 | ||||
-rw-r--r-- | drivers/net/ethernet/adi/bfin_mac.h | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c index 49733696703a..ab4daeccdf98 100644 --- a/drivers/net/ethernet/adi/bfin_mac.c +++ b/drivers/net/ethernet/adi/bfin_mac.c | |||
@@ -621,6 +621,7 @@ static int bfin_mac_set_mac_address(struct net_device *dev, void *p) | |||
621 | if (netif_running(dev)) | 621 | if (netif_running(dev)) |
622 | return -EBUSY; | 622 | return -EBUSY; |
623 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | 623 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); |
624 | dev->addr_assign_type &= ~NET_ADDR_RANDOM; | ||
624 | setup_mac_addr(dev->dev_addr); | 625 | setup_mac_addr(dev->dev_addr); |
625 | return 0; | 626 | return 0; |
626 | } | 627 | } |
@@ -1494,12 +1495,14 @@ static int __devinit bfin_mac_probe(struct platform_device *pdev) | |||
1494 | * Grab the MAC from the board somehow | 1495 | * Grab the MAC from the board somehow |
1495 | * this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c | 1496 | * this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c |
1496 | */ | 1497 | */ |
1497 | if (!is_valid_ether_addr(ndev->dev_addr)) | 1498 | if (!is_valid_ether_addr(ndev->dev_addr)) { |
1498 | bfin_get_ether_addr(ndev->dev_addr); | 1499 | if (bfin_get_ether_addr(ndev->dev_addr) || |
1499 | 1500 | !is_valid_ether_addr(ndev->dev_addr)) { | |
1500 | /* If still not valid, get a random one */ | 1501 | /* Still not valid, get a random one */ |
1501 | if (!is_valid_ether_addr(ndev->dev_addr)) | 1502 | netdev_warn(ndev, "Setting Ethernet MAC to a random one\n"); |
1502 | random_ether_addr(ndev->dev_addr); | 1503 | eth_hw_addr_random(ndev); |
1504 | } | ||
1505 | } | ||
1503 | 1506 | ||
1504 | setup_mac_addr(ndev->dev_addr); | 1507 | setup_mac_addr(ndev->dev_addr); |
1505 | 1508 | ||
diff --git a/drivers/net/ethernet/adi/bfin_mac.h b/drivers/net/ethernet/adi/bfin_mac.h index f8559ac9a403..960905c08223 100644 --- a/drivers/net/ethernet/adi/bfin_mac.h +++ b/drivers/net/ethernet/adi/bfin_mac.h | |||
@@ -101,6 +101,6 @@ struct bfin_mac_local { | |||
101 | #endif | 101 | #endif |
102 | }; | 102 | }; |
103 | 103 | ||
104 | extern void bfin_get_ether_addr(char *addr); | 104 | extern int bfin_get_ether_addr(char *addr); |
105 | 105 | ||
106 | #endif | 106 | #endif |