aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorDanny Kukawka <danny.kukawka@bisect.de>2012-02-15 01:45:40 -0500
committerDavid S. Miller <davem@davemloft.net>2012-02-15 15:34:17 -0500
commit7ce5d222190cb3ce3ae88bafde7c4fa52a5103e0 (patch)
tree2b284365b7a2e11d4ba286a589bd35bc39918805 /drivers/net/ethernet
parentf2cedb63df14342ad40a8b5b324fc5d94a60b665 (diff)
net: use eth_hw_addr_random() and reset addr_assign_type
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. v2: adapt to renamed eth_hw_addr_random() Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c2
-rw-r--r--drivers/net/ethernet/calxeda/xgmac.c3
-rw-r--r--drivers/net/ethernet/marvell/pxa168_eth.c3
-rw-r--r--drivers/net/ethernet/micrel/ks8842.c3
-rw-r--r--drivers/net/ethernet/micrel/ks8851.c3
-rw-r--r--drivers/net/ethernet/micrel/ks8851_mll.c1
-rw-r--r--drivers/net/ethernet/microchip/enc28j60.c3
-rw-r--r--drivers/net/ethernet/nvidia/forcedeth.c3
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c3
-rw-r--r--drivers/net/ethernet/tile/tilepro.c3
11 files changed, 19 insertions, 9 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 5d15efc2a9e2..aa14502289ce 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -3007,6 +3007,7 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p)
3007 return rc; 3007 return rc;
3008 } 3008 }
3009 3009
3010 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
3010 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 3011 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
3011 3012
3012 if (netif_running(dev)) 3013 if (netif_running(dev))
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index b9afd26cfbe6..8e809c1408b4 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -9683,7 +9683,7 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
9683 9683
9684 if (BP_NOMCP(bp)) { 9684 if (BP_NOMCP(bp)) {
9685 BNX2X_ERROR("warning: random MAC workaround active\n"); 9685 BNX2X_ERROR("warning: random MAC workaround active\n");
9686 random_ether_addr(bp->dev->dev_addr); 9686 eth_hw_addr_random(bp->dev);
9687 } else if (IS_MF(bp)) { 9687 } else if (IS_MF(bp)) {
9688 val2 = MF_CFG_RD(bp, func_mf_config[func].mac_upper); 9688 val2 = MF_CFG_RD(bp, func_mf_config[func].mac_upper);
9689 val = MF_CFG_RD(bp, func_mf_config[func].mac_lower); 9689 val = MF_CFG_RD(bp, func_mf_config[func].mac_lower);
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index 1fce186a9031..11f667f6131a 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -1012,7 +1012,7 @@ static int xgmac_open(struct net_device *dev)
1012 * address using the following linux command: 1012 * address using the following linux command:
1013 * ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx */ 1013 * ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx */
1014 if (!is_valid_ether_addr(dev->dev_addr)) { 1014 if (!is_valid_ether_addr(dev->dev_addr)) {
1015 random_ether_addr(dev->dev_addr); 1015 eth_hw_addr_random(dev);
1016 netdev_dbg(priv->dev, "generated random MAC address %pM\n", 1016 netdev_dbg(priv->dev, "generated random MAC address %pM\n",
1017 dev->dev_addr); 1017 dev->dev_addr);
1018 } 1018 }
@@ -1482,6 +1482,7 @@ static int xgmac_set_mac_address(struct net_device *dev, void *p)
1482 if (!is_valid_ether_addr(addr->sa_data)) 1482 if (!is_valid_ether_addr(addr->sa_data))
1483 return -EADDRNOTAVAIL; 1483 return -EADDRNOTAVAIL;
1484 1484
1485 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
1485 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 1486 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
1486 1487
1487 xgmac_set_mac_addr(ioaddr, dev->dev_addr, 0); 1488 xgmac_set_mac_addr(ioaddr, dev->dev_addr, 0);
diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 75df2091bd2e..83e37ad113e0 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -629,6 +629,7 @@ static int pxa168_eth_set_mac_address(struct net_device *dev, void *addr)
629 if (!is_valid_ether_addr(sa->sa_data)) 629 if (!is_valid_ether_addr(sa->sa_data))
630 return -EINVAL; 630 return -EINVAL;
631 memcpy(oldMac, dev->dev_addr, ETH_ALEN); 631 memcpy(oldMac, dev->dev_addr, ETH_ALEN);
632 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
632 memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN); 633 memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
633 netif_addr_lock_bh(dev); 634 netif_addr_lock_bh(dev);
634 update_hash_table_mac_address(pep, oldMac, dev->dev_addr); 635 update_hash_table_mac_address(pep, oldMac, dev->dev_addr);
@@ -1520,7 +1521,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1520 INIT_WORK(&pep->tx_timeout_task, pxa168_eth_tx_timeout_task); 1521 INIT_WORK(&pep->tx_timeout_task, pxa168_eth_tx_timeout_task);
1521 1522
1522 printk(KERN_INFO "%s:Using random mac address\n", DRIVER_NAME); 1523 printk(KERN_INFO "%s:Using random mac address\n", DRIVER_NAME);
1523 random_ether_addr(dev->dev_addr); 1524 eth_hw_addr_random(dev);
1524 1525
1525 pep->pd = pdev->dev.platform_data; 1526 pep->pd = pdev->dev.platform_data;
1526 pep->rx_ring_size = NUM_RX_DESCS; 1527 pep->rx_ring_size = NUM_RX_DESCS;
diff --git a/drivers/net/ethernet/micrel/ks8842.c b/drivers/net/ethernet/micrel/ks8842.c
index 0a85690a1321..0686b93f1857 100644
--- a/drivers/net/ethernet/micrel/ks8842.c
+++ b/drivers/net/ethernet/micrel/ks8842.c
@@ -1080,6 +1080,7 @@ static int ks8842_set_mac(struct net_device *netdev, void *p)
1080 if (!is_valid_ether_addr(addr->sa_data)) 1080 if (!is_valid_ether_addr(addr->sa_data))
1081 return -EADDRNOTAVAIL; 1081 return -EADDRNOTAVAIL;
1082 1082
1083 netdev->addr_assign_type &= ~NET_ADDR_RANDOM;
1083 memcpy(netdev->dev_addr, mac, netdev->addr_len); 1084 memcpy(netdev->dev_addr, mac, netdev->addr_len);
1084 1085
1085 ks8842_write_mac_addr(adapter, mac); 1086 ks8842_write_mac_addr(adapter, mac);
@@ -1211,7 +1212,7 @@ static int __devinit ks8842_probe(struct platform_device *pdev)
1211 ks8842_read_mac_addr(adapter, netdev->dev_addr); 1212 ks8842_read_mac_addr(adapter, netdev->dev_addr);
1212 1213
1213 if (!is_valid_ether_addr(netdev->dev_addr)) 1214 if (!is_valid_ether_addr(netdev->dev_addr))
1214 random_ether_addr(netdev->dev_addr); 1215 eth_hw_addr_random(netdev);
1215 } 1216 }
1216 1217
1217 id = ks8842_read16(adapter, 32, REG_SW_ID_AND_ENABLE); 1218 id = ks8842_read16(adapter, 32, REG_SW_ID_AND_ENABLE);
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index 0930b9c950d0..42a6a20efb15 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -439,7 +439,7 @@ static void ks8851_init_mac(struct ks8851_net *ks)
439 dev->dev_addr); 439 dev->dev_addr);
440 } 440 }
441 441
442 random_ether_addr(dev->dev_addr); 442 eth_hw_addr_random(dev);
443 ks8851_write_mac_addr(dev); 443 ks8851_write_mac_addr(dev);
444} 444}
445 445
@@ -1050,6 +1050,7 @@ static int ks8851_set_mac_address(struct net_device *dev, void *addr)
1050 if (!is_valid_ether_addr(sa->sa_data)) 1050 if (!is_valid_ether_addr(sa->sa_data))
1051 return -EADDRNOTAVAIL; 1051 return -EADDRNOTAVAIL;
1052 1052
1053 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
1053 memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN); 1054 memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
1054 return ks8851_write_mac_addr(dev); 1055 return ks8851_write_mac_addr(dev);
1055} 1056}
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index 3d9a04e7b49d..180460f4e41f 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -1241,6 +1241,7 @@ static int ks_set_mac_address(struct net_device *netdev, void *paddr)
1241 struct sockaddr *addr = paddr; 1241 struct sockaddr *addr = paddr;
1242 u8 *da; 1242 u8 *da;
1243 1243
1244 netdev->addr_assign_type &= ~NET_ADDR_RANDOM;
1244 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 1245 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
1245 1246
1246 da = (u8 *)netdev->dev_addr; 1247 da = (u8 *)netdev->dev_addr;
diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c
index 1d6b7ce3e1ee..6118bdad244f 100644
--- a/drivers/net/ethernet/microchip/enc28j60.c
+++ b/drivers/net/ethernet/microchip/enc28j60.c
@@ -527,6 +527,7 @@ static int enc28j60_set_mac_address(struct net_device *dev, void *addr)
527 if (!is_valid_ether_addr(address->sa_data)) 527 if (!is_valid_ether_addr(address->sa_data))
528 return -EADDRNOTAVAIL; 528 return -EADDRNOTAVAIL;
529 529
530 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
530 memcpy(dev->dev_addr, address->sa_data, dev->addr_len); 531 memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
531 return enc28j60_set_hw_macaddr(dev); 532 return enc28j60_set_hw_macaddr(dev);
532} 533}
@@ -1575,7 +1576,7 @@ static int __devinit enc28j60_probe(struct spi_device *spi)
1575 ret = -EIO; 1576 ret = -EIO;
1576 goto error_irq; 1577 goto error_irq;
1577 } 1578 }
1578 random_ether_addr(dev->dev_addr); 1579 eth_hw_addr_random(dev);
1579 enc28j60_set_hw_macaddr(dev); 1580 enc28j60_set_hw_macaddr(dev);
1580 1581
1581 /* Board setup must set the relevant edge trigger type; 1582 /* Board setup must set the relevant edge trigger type;
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index 5eeb92f87380..8561dd25db66 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -3022,6 +3022,7 @@ static int nv_set_mac_address(struct net_device *dev, void *addr)
3022 3022
3023 /* synchronized against open : rtnl_lock() held by caller */ 3023 /* synchronized against open : rtnl_lock() held by caller */
3024 memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN); 3024 memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN);
3025 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
3025 3026
3026 if (netif_running(dev)) { 3027 if (netif_running(dev)) {
3027 netif_tx_lock_bh(dev); 3028 netif_tx_lock_bh(dev);
@@ -5741,7 +5742,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5741 dev_err(&pci_dev->dev, 5742 dev_err(&pci_dev->dev,
5742 "Invalid MAC address detected: %pM - Please complain to your hardware vendor.\n", 5743 "Invalid MAC address detected: %pM - Please complain to your hardware vendor.\n",
5743 dev->dev_addr); 5744 dev->dev_addr);
5744 random_ether_addr(dev->dev_addr); 5745 eth_hw_addr_random(dev);
5745 dev_err(&pci_dev->dev, 5746 dev_err(&pci_dev->dev,
5746 "Using random MAC address: %pM\n", dev->dev_addr); 5747 "Using random MAC address: %pM\n", dev->dev_addr);
5747 } 5748 }
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 6a1cd2360818..4a6971027076 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1833,6 +1833,7 @@ static int smsc911x_set_mac_address(struct net_device *dev, void *p)
1833 if (!is_valid_ether_addr(addr->sa_data)) 1833 if (!is_valid_ether_addr(addr->sa_data))
1834 return -EADDRNOTAVAIL; 1834 return -EADDRNOTAVAIL;
1835 1835
1836 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
1836 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 1837 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
1837 1838
1838 spin_lock_irq(&pdata->mac_lock); 1839 spin_lock_irq(&pdata->mac_lock);
@@ -2485,7 +2486,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
2485 "Mac Address is read from LAN911x EEPROM"); 2486 "Mac Address is read from LAN911x EEPROM");
2486 } else { 2487 } else {
2487 /* eeprom values are invalid, generate random MAC */ 2488 /* eeprom values are invalid, generate random MAC */
2488 random_ether_addr(dev->dev_addr); 2489 eth_hw_addr_random(dev);
2489 smsc911x_set_hw_mac_address(pdata, dev->dev_addr); 2490 smsc911x_set_hw_mac_address(pdata, dev->dev_addr);
2490 SMSC_TRACE(pdata, probe, 2491 SMSC_TRACE(pdata, probe,
2491 "MAC Address is set to random_ether_addr"); 2492 "MAC Address is set to random_ether_addr");
diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c
index a8e5daaef6fa..948c4f2a2d67 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -2190,6 +2190,7 @@ static int tile_net_set_mac_address(struct net_device *dev, void *p)
2190 2190
2191 /* ISSUE: Note that "dev_addr" is now a pointer. */ 2191 /* ISSUE: Note that "dev_addr" is now a pointer. */
2192 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 2192 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
2193 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
2193 2194
2194 return 0; 2195 return 0;
2195} 2196}
@@ -2254,7 +2255,7 @@ static int tile_net_get_mac(struct net_device *dev)
2254 * can't get its MAC address, we are most likely running 2255 * can't get its MAC address, we are most likely running
2255 * the simulator, so let's generate a random MAC address. 2256 * the simulator, so let's generate a random MAC address.
2256 */ 2257 */
2257 random_ether_addr(dev->dev_addr); 2258 eth_hw_addr_random(dev);
2258 } 2259 }
2259 2260
2260 return 0; 2261 return 0;