[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1329412171-20704-3-git-send-email-danny.kukawka@bisect.de>
Date: Thu, 16 Feb 2012 18:09:31 +0100
From: Danny Kukawka <danny.kukawka@...ect.de>
To: "David S. Miller" <davem@...emloft.net>
Cc: Danny Kukawka <dkukawka@...e.de>,
Mike Frysinger <vapier@...too.org>,
Sonic Zhang <sonic.zhang@...log.com>,
Jeff Kirsher <jeffrey.t.kirsher@...el.com>,
Bob Liu <bob.liu@...log.com>,
uclinux-dist-devel@...ckfin.uclinux.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 2/2] 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@...ect.de>
---
drivers/net/ethernet/adi/bfin_mac.c | 15 +++++++++------
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 d812a10..905f0e1 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)
if (netif_running(dev))
return -EBUSY;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+ dev->addr_assign_type &= ~NET_ADDR_RANDOM;
setup_mac_addr(dev->dev_addr);
return 0;
}
@@ -1496,12 +1497,14 @@ static int __devinit bfin_mac_probe(struct platform_device *pdev)
* Grab the MAC from the board somehow
* this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c
*/
- if (!is_valid_ether_addr(ndev->dev_addr))
- bfin_get_ether_addr(ndev->dev_addr);
-
- /* If still not valid, get a random one */
- if (!is_valid_ether_addr(ndev->dev_addr))
- random_ether_addr(ndev->dev_addr);
+ if (!is_valid_ether_addr(ndev->dev_addr)) {
+ if (bfin_get_ether_addr(ndev->dev_addr) ||
+ !is_valid_ether_addr(ndev->dev_addr)) {
+ /* Still not valid, get a random one */
+ netdev_warn(ndev, "Setting Ethernet MAC to a random one\n");
+ eth_hw_addr_random(ndev);
+ }
+ }
setup_mac_addr(ndev->dev_addr);
diff --git a/drivers/net/ethernet/adi/bfin_mac.h b/drivers/net/ethernet/adi/bfin_mac.h
index f8559ac..960905c 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 {
#endif
};
-extern void bfin_get_ether_addr(char *addr);
+extern int bfin_get_ether_addr(char *addr);
#endif
--
1.7.8.3
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists