aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2010-02-23 04:19:49 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-26 05:07:30 -0500
commitf9dcbcc9e338d08c0f7de7eba4eaafbbb7f81249 (patch)
tree8a1d9a37bc057440220a5ad23231e0fe974b93f6
parent52c793f24054f5dc30d228e37e0e19cc8313f086 (diff)
net: convert multiple drivers to use netdev_for_each_mc_addr, part5 V2
removed some needless checks and also corrected bug in lp486e (dmi was passed instead of dmi->dmi_addr) Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/jme.c6
-rw-r--r--drivers/net/korina.c6
-rw-r--r--drivers/net/ks8851.c5
-rw-r--r--drivers/net/ks8851_mll.c3
-rw-r--r--drivers/net/ksz884x.c4
-rw-r--r--drivers/net/lib82596.c7
-rw-r--r--drivers/net/lib8390.c15
-rw-r--r--drivers/net/ll_temac_main.c7
-rw-r--r--drivers/net/lp486e.c4
-rw-r--r--drivers/net/mac89x0.c4
-rw-r--r--drivers/net/macb.c7
-rw-r--r--drivers/net/mace.c11
-rw-r--r--drivers/net/macmace.c12
-rw-r--r--drivers/net/mv643xx_eth.c2
-rw-r--r--drivers/net/myri10ge/myri10ge.c2
-rw-r--r--drivers/net/natsemi.c4
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c19
-rw-r--r--drivers/net/ni5010.c3
-rw-r--r--drivers/net/ni52.c8
-rw-r--r--drivers/net/niu.c2
-rw-r--r--drivers/net/pci-skeleton.c6
-rw-r--r--drivers/net/pcnet32.c5
-rw-r--r--drivers/net/ps3_gelic_net.c2
-rw-r--r--drivers/net/qlcnic/qlcnic_hw.c3
-rw-r--r--drivers/net/qlge/qlge_main.c6
-rw-r--r--drivers/net/r6040.c30
-rw-r--r--drivers/net/r8169.c4
27 files changed, 82 insertions, 105 deletions
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 558b6a0b15fc..0f31497833df 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -1997,7 +1997,6 @@ jme_set_multi(struct net_device *netdev)
1997{ 1997{
1998 struct jme_adapter *jme = netdev_priv(netdev); 1998 struct jme_adapter *jme = netdev_priv(netdev);
1999 u32 mc_hash[2] = {}; 1999 u32 mc_hash[2] = {};
2000 int i;
2001 2000
2002 spin_lock_bh(&jme->rxmcs_lock); 2001 spin_lock_bh(&jme->rxmcs_lock);
2003 2002
@@ -2012,10 +2011,7 @@ jme_set_multi(struct net_device *netdev)
2012 int bit_nr; 2011 int bit_nr;
2013 2012
2014 jme->reg_rxmcs |= RXMCS_MULFRAME | RXMCS_MULFILTERED; 2013 jme->reg_rxmcs |= RXMCS_MULFRAME | RXMCS_MULFILTERED;
2015 for (i = 0, mclist = netdev->mc_list; 2014 netdev_for_each_mc_addr(mclist, netdev) {
2016 mclist && i < netdev_mc_count(netdev);
2017 ++i, mclist = mclist->next) {
2018
2019 bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3F; 2015 bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3F;
2020 mc_hash[bit_nr >> 5] |= 1 << (bit_nr & 0x1F); 2016 mc_hash[bit_nr >> 5] |= 1 << (bit_nr & 0x1F);
2021 } 2017 }
diff --git a/drivers/net/korina.c b/drivers/net/korina.c
index af0c764130e6..300c2249812d 100644
--- a/drivers/net/korina.c
+++ b/drivers/net/korina.c
@@ -482,7 +482,7 @@ static void korina_multicast_list(struct net_device *dev)
482{ 482{
483 struct korina_private *lp = netdev_priv(dev); 483 struct korina_private *lp = netdev_priv(dev);
484 unsigned long flags; 484 unsigned long flags;
485 struct dev_mc_list *dmi = dev->mc_list; 485 struct dev_mc_list *dmi;
486 u32 recognise = ETH_ARC_AB; /* always accept broadcasts */ 486 u32 recognise = ETH_ARC_AB; /* always accept broadcasts */
487 int i; 487 int i;
488 488
@@ -502,11 +502,9 @@ static void korina_multicast_list(struct net_device *dev)
502 for (i = 0; i < 4; i++) 502 for (i = 0; i < 4; i++)
503 hash_table[i] = 0; 503 hash_table[i] = 0;
504 504
505 for (i = 0; i < netdev_mc_count(dev); i++) { 505 netdev_for_each_mc_addr(dmi, dev) {
506 char *addrs = dmi->dmi_addr; 506 char *addrs = dmi->dmi_addr;
507 507
508 dmi = dmi->next;
509
510 if (!(*addrs & 1)) 508 if (!(*addrs & 1))
511 continue; 509 continue;
512 510
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index 9845ab1e5573..b5219cce12ed 100644
--- a/drivers/net/ks8851.c
+++ b/drivers/net/ks8851.c
@@ -966,13 +966,12 @@ static void ks8851_set_rx_mode(struct net_device *dev)
966 rxctrl.rxcr1 = (RXCR1_RXME | RXCR1_RXAE | 966 rxctrl.rxcr1 = (RXCR1_RXME | RXCR1_RXAE |
967 RXCR1_RXPAFMA | RXCR1_RXMAFMA); 967 RXCR1_RXPAFMA | RXCR1_RXMAFMA);
968 } else if (dev->flags & IFF_MULTICAST && !netdev_mc_empty(dev)) { 968 } else if (dev->flags & IFF_MULTICAST && !netdev_mc_empty(dev)) {
969 struct dev_mc_list *mcptr = dev->mc_list; 969 struct dev_mc_list *mcptr;
970 u32 crc; 970 u32 crc;
971 int i;
972 971
973 /* accept some multicast */ 972 /* accept some multicast */
974 973
975 for (i = netdev_mc_count(dev); i > 0; i--) { 974 netdev_for_each_mc_addr(mcptr, dev) {
976 crc = ether_crc(ETH_ALEN, mcptr->dmi_addr); 975 crc = ether_crc(ETH_ALEN, mcptr->dmi_addr);
977 crc >>= (32 - 6); /* get top six bits */ 976 crc >>= (32 - 6); /* get top six bits */
978 977
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index ffffb3889704..84b0e15831f9 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -1196,7 +1196,8 @@ static void ks_set_rx_mode(struct net_device *netdev)
1196 if ((netdev->flags & IFF_MULTICAST) && netdev_mc_count(netdev)) { 1196 if ((netdev->flags & IFF_MULTICAST) && netdev_mc_count(netdev)) {
1197 if (netdev_mc_count(netdev) <= MAX_MCAST_LST) { 1197 if (netdev_mc_count(netdev) <= MAX_MCAST_LST) {
1198 int i = 0; 1198 int i = 0;
1199 for (ptr = netdev->mc_list; ptr; ptr = ptr->next) { 1199
1200 netdev_for_each_mc_addr(ptr, netdev) {
1200 if (!(*ptr->dmi_addr & 1)) 1201 if (!(*ptr->dmi_addr & 1))
1201 continue; 1202 continue;
1202 if (i >= MAX_MCAST_LST) 1203 if (i >= MAX_MCAST_LST)
diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c
index 6f187c7e61fa..7264a3e5c2c0 100644
--- a/drivers/net/ksz884x.c
+++ b/drivers/net/ksz884x.c
@@ -5777,7 +5777,7 @@ static void netdev_set_rx_mode(struct net_device *dev)
5777 if (hw_priv->hw.dev_count > 1) 5777 if (hw_priv->hw.dev_count > 1)
5778 return; 5778 return;
5779 5779
5780 if ((dev->flags & IFF_MULTICAST) && dev->mc_count) { 5780 if ((dev->flags & IFF_MULTICAST) && !netdev_mc_empty(dev)) {
5781 int i = 0; 5781 int i = 0;
5782 5782
5783 /* List too big to support so turn on all multicast mode. */ 5783 /* List too big to support so turn on all multicast mode. */
@@ -5790,7 +5790,7 @@ static void netdev_set_rx_mode(struct net_device *dev)
5790 return; 5790 return;
5791 } 5791 }
5792 5792
5793 for (mc_ptr = dev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) { 5793 netdev_for_each_mc_addr(mc_ptr, dev) {
5794 if (!(*mc_ptr->dmi_addr & 1)) 5794 if (!(*mc_ptr->dmi_addr & 1))
5795 continue; 5795 continue;
5796 if (i >= MAX_MULTICAST_LIST) 5796 if (i >= MAX_MULTICAST_LIST)
diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c
index 371b58b1d151..443c39a3732f 100644
--- a/drivers/net/lib82596.c
+++ b/drivers/net/lib82596.c
@@ -1396,15 +1396,16 @@ static void set_multicast_list(struct net_device *dev)
1396 cmd->cmd.command = SWAP16(CmdMulticastList); 1396 cmd->cmd.command = SWAP16(CmdMulticastList);
1397 cmd->mc_cnt = SWAP16(netdev_mc_count(dev) * 6); 1397 cmd->mc_cnt = SWAP16(netdev_mc_count(dev) * 6);
1398 cp = cmd->mc_addrs; 1398 cp = cmd->mc_addrs;
1399 for (dmi = dev->mc_list; 1399 netdev_for_each_mc_addr(dmi, dev) {
1400 cnt && dmi != NULL; 1400 if (!cnt--)
1401 dmi = dmi->next, cnt--, cp += 6) { 1401 break;
1402 memcpy(cp, dmi->dmi_addr, 6); 1402 memcpy(cp, dmi->dmi_addr, 6);
1403 if (i596_debug > 1) 1403 if (i596_debug > 1)
1404 DEB(DEB_MULTI, 1404 DEB(DEB_MULTI,
1405 printk(KERN_DEBUG 1405 printk(KERN_DEBUG
1406 "%s: Adding address %pM\n", 1406 "%s: Adding address %pM\n",
1407 dev->name, cp)); 1407 dev->name, cp));
1408 cp += 6;
1408 } 1409 }
1409 DMA_WBACK_INV(dev, &dma->mc_cmd, sizeof(struct mc_cmd)); 1410 DMA_WBACK_INV(dev, &dma->mc_cmd, sizeof(struct mc_cmd));
1410 i596_add_cmd(dev, &cmd->cmd); 1411 i596_add_cmd(dev, &cmd->cmd);
diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c
index 57f25848fe80..56f66f485400 100644
--- a/drivers/net/lib8390.c
+++ b/drivers/net/lib8390.c
@@ -907,15 +907,8 @@ static inline void make_mc_bits(u8 *bits, struct net_device *dev)
907{ 907{
908 struct dev_mc_list *dmi; 908 struct dev_mc_list *dmi;
909 909
910 for (dmi=dev->mc_list; dmi; dmi=dmi->next) 910 netdev_for_each_mc_addr(dmi, dev) {
911 { 911 u32 crc = ether_crc(ETH_ALEN, dmi->dmi_addr);
912 u32 crc;
913 if (dmi->dmi_addrlen != ETH_ALEN)
914 {
915 printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name);
916 continue;
917 }
918 crc = ether_crc(ETH_ALEN, dmi->dmi_addr);
919 /* 912 /*
920 * The 8390 uses the 6 most significant bits of the 913 * The 8390 uses the 6 most significant bits of the
921 * CRC to index the multicast table. 914 * CRC to index the multicast table.
@@ -941,7 +934,7 @@ static void do_set_multicast_list(struct net_device *dev)
941 if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) 934 if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI)))
942 { 935 {
943 memset(ei_local->mcfilter, 0, 8); 936 memset(ei_local->mcfilter, 0, 8);
944 if (dev->mc_list) 937 if (!netdev_mc_empty(dev))
945 make_mc_bits(ei_local->mcfilter, dev); 938 make_mc_bits(ei_local->mcfilter, dev);
946 } 939 }
947 else 940 else
@@ -975,7 +968,7 @@ static void do_set_multicast_list(struct net_device *dev)
975 968
976 if(dev->flags&IFF_PROMISC) 969 if(dev->flags&IFF_PROMISC)
977 ei_outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR); 970 ei_outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR);
978 else if(dev->flags&IFF_ALLMULTI || dev->mc_list) 971 else if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev))
979 ei_outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR); 972 ei_outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR);
980 else 973 else
981 ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); 974 ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
index e53440253748..a18e3485476e 100644
--- a/drivers/net/ll_temac_main.c
+++ b/drivers/net/ll_temac_main.c
@@ -250,9 +250,10 @@ static void temac_set_multicast_list(struct net_device *ndev)
250 temac_indirect_out32(lp, XTE_AFM_OFFSET, XTE_AFM_EPPRM_MASK); 250 temac_indirect_out32(lp, XTE_AFM_OFFSET, XTE_AFM_EPPRM_MASK);
251 dev_info(&ndev->dev, "Promiscuous mode enabled.\n"); 251 dev_info(&ndev->dev, "Promiscuous mode enabled.\n");
252 } else if (!netdev_mc_empty(ndev)) { 252 } else if (!netdev_mc_empty(ndev)) {
253 struct dev_mc_list *mclist = ndev->mc_list; 253 struct dev_mc_list *mclist;
254 for (i = 0; mclist && i < netdev_mc_count(ndev); i++) {
255 254
255 i = 0;
256 netdev_for_each_mc_addr(mclist, ndev) {
256 if (i >= MULTICAST_CAM_TABLE_NUM) 257 if (i >= MULTICAST_CAM_TABLE_NUM)
257 break; 258 break;
258 multi_addr_msw = ((mclist->dmi_addr[3] << 24) | 259 multi_addr_msw = ((mclist->dmi_addr[3] << 24) |
@@ -265,7 +266,7 @@ static void temac_set_multicast_list(struct net_device *ndev)
265 (mclist->dmi_addr[4]) | (i << 16)); 266 (mclist->dmi_addr[4]) | (i << 16));
266 temac_indirect_out32(lp, XTE_MAW1_OFFSET, 267 temac_indirect_out32(lp, XTE_MAW1_OFFSET,
267 multi_addr_lsw); 268 multi_addr_lsw);
268 mclist = mclist->next; 269 i++;
269 } 270 }
270 } else { 271 } else {
271 val = temac_indirect_in32(lp, XTE_AFM_OFFSET); 272 val = temac_indirect_in32(lp, XTE_AFM_OFFSET);
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c
index b1f5d79af61f..3e3cc04defd0 100644
--- a/drivers/net/lp486e.c
+++ b/drivers/net/lp486e.c
@@ -1267,8 +1267,8 @@ static void set_multicast_list(struct net_device *dev) {
1267 cmd->command = CmdMulticastList; 1267 cmd->command = CmdMulticastList;
1268 *((unsigned short *) (cmd + 1)) = netdev_mc_count(dev) * 6; 1268 *((unsigned short *) (cmd + 1)) = netdev_mc_count(dev) * 6;
1269 cp = ((char *)(cmd + 1))+2; 1269 cp = ((char *)(cmd + 1))+2;
1270 for (dmi = dev->mc_list; dmi != NULL; dmi = dmi->next) { 1270 netdev_for_each_mc_addr(dmi, dev) {
1271 memcpy(cp, dmi,6); 1271 memcpy(cp, dmi->dmi_addr, 6);
1272 cp += 6; 1272 cp += 6;
1273 } 1273 }
1274 if (i596_debug & LOG_SRCDST) 1274 if (i596_debug & LOG_SRCDST)
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
index 23b633e2ac42..c292a608f9a9 100644
--- a/drivers/net/mac89x0.c
+++ b/drivers/net/mac89x0.c
@@ -568,9 +568,7 @@ static void set_multicast_list(struct net_device *dev)
568 if(dev->flags&IFF_PROMISC) 568 if(dev->flags&IFF_PROMISC)
569 { 569 {
570 lp->rx_mode = RX_ALL_ACCEPT; 570 lp->rx_mode = RX_ALL_ACCEPT;
571 } 571 } else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev)) {
572 else if((dev->flags&IFF_ALLMULTI)||dev->mc_list)
573 {
574 /* The multicast-accept list is initialized to accept-all, and we 572 /* The multicast-accept list is initialized to accept-all, and we
575 rely on higher-level filtering for now. */ 573 rely on higher-level filtering for now. */
576 lp->rx_mode = RX_MULTCAST_ACCEPT; 574 lp->rx_mode = RX_MULTCAST_ACCEPT;
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 7a5f89728a81..c8a18a6203c8 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -884,15 +884,12 @@ static void macb_sethashtable(struct net_device *dev)
884{ 884{
885 struct dev_mc_list *curr; 885 struct dev_mc_list *curr;
886 unsigned long mc_filter[2]; 886 unsigned long mc_filter[2];
887 unsigned int i, bitnr; 887 unsigned int bitnr;
888 struct macb *bp = netdev_priv(dev); 888 struct macb *bp = netdev_priv(dev);
889 889
890 mc_filter[0] = mc_filter[1] = 0; 890 mc_filter[0] = mc_filter[1] = 0;
891 891
892 curr = dev->mc_list; 892 netdev_for_each_mc_addr(curr, dev) {
893 for (i = 0; i < netdev_mc_count(dev); i++, curr = curr->next) {
894 if (!curr) break; /* unexpected end of list */
895
896 bitnr = hash_get_index(curr->dmi_addr); 893 bitnr = hash_get_index(curr->dmi_addr);
897 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31); 894 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
898 } 895 }
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index fdb0bbdd6782..57534f0e906d 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -588,7 +588,7 @@ static void mace_set_multicast(struct net_device *dev)
588{ 588{
589 struct mace_data *mp = netdev_priv(dev); 589 struct mace_data *mp = netdev_priv(dev);
590 volatile struct mace __iomem *mb = mp->mace; 590 volatile struct mace __iomem *mb = mp->mace;
591 int i, j; 591 int i;
592 u32 crc; 592 u32 crc;
593 unsigned long flags; 593 unsigned long flags;
594 594
@@ -598,7 +598,7 @@ static void mace_set_multicast(struct net_device *dev)
598 mp->maccc |= PROM; 598 mp->maccc |= PROM;
599 } else { 599 } else {
600 unsigned char multicast_filter[8]; 600 unsigned char multicast_filter[8];
601 struct dev_mc_list *dmi = dev->mc_list; 601 struct dev_mc_list *dmi;
602 602
603 if (dev->flags & IFF_ALLMULTI) { 603 if (dev->flags & IFF_ALLMULTI) {
604 for (i = 0; i < 8; i++) 604 for (i = 0; i < 8; i++)
@@ -606,11 +606,10 @@ static void mace_set_multicast(struct net_device *dev)
606 } else { 606 } else {
607 for (i = 0; i < 8; i++) 607 for (i = 0; i < 8; i++)
608 multicast_filter[i] = 0; 608 multicast_filter[i] = 0;
609 for (i = 0; i < netdev_mc_count(dev); i++) { 609 netdev_for_each_mc_addr(dmi, dev) {
610 crc = ether_crc_le(6, dmi->dmi_addr); 610 crc = ether_crc_le(6, dmi->dmi_addr);
611 j = crc >> 26; /* bit number in multicast_filter */ 611 i = crc >> 26; /* bit number in multicast_filter */
612 multicast_filter[j >> 3] |= 1 << (j & 7); 612 multicast_filter[i >> 3] |= 1 << (i & 7);
613 dmi = dmi->next;
614 } 613 }
615 } 614 }
616#if 0 615#if 0
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index 740accbf0806..4e4eac0ba176 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -496,7 +496,7 @@ static void mace_set_multicast(struct net_device *dev)
496{ 496{
497 struct mace_data *mp = netdev_priv(dev); 497 struct mace_data *mp = netdev_priv(dev);
498 volatile struct mace *mb = mp->mace; 498 volatile struct mace *mb = mp->mace;
499 int i, j; 499 int i;
500 u32 crc; 500 u32 crc;
501 u8 maccc; 501 u8 maccc;
502 unsigned long flags; 502 unsigned long flags;
@@ -509,7 +509,7 @@ static void mace_set_multicast(struct net_device *dev)
509 mb->maccc |= PROM; 509 mb->maccc |= PROM;
510 } else { 510 } else {
511 unsigned char multicast_filter[8]; 511 unsigned char multicast_filter[8];
512 struct dev_mc_list *dmi = dev->mc_list; 512 struct dev_mc_list *dmi;
513 513
514 if (dev->flags & IFF_ALLMULTI) { 514 if (dev->flags & IFF_ALLMULTI) {
515 for (i = 0; i < 8; i++) { 515 for (i = 0; i < 8; i++) {
@@ -518,11 +518,11 @@ static void mace_set_multicast(struct net_device *dev)
518 } else { 518 } else {
519 for (i = 0; i < 8; i++) 519 for (i = 0; i < 8; i++)
520 multicast_filter[i] = 0; 520 multicast_filter[i] = 0;
521 for (i = 0; i < netdev_mc_count(dev); i++) { 521 netdev_for_each_mc_addr(dmi, dev) {
522 crc = ether_crc_le(6, dmi->dmi_addr); 522 crc = ether_crc_le(6, dmi->dmi_addr);
523 j = crc >> 26; /* bit number in multicast_filter */ 523 /* bit number in multicast_filter */
524 multicast_filter[j >> 3] |= 1 << (j & 7); 524 i = crc >> 26;
525 dmi = dmi->next; 525 multicast_filter[i >> 3] |= 1 << (i & 7);
526 } 526 }
527 } 527 }
528 528
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 2733b0a3b703..c97b6e4365a9 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1794,7 +1794,7 @@ oom:
1794 memset(mc_spec, 0, 0x100); 1794 memset(mc_spec, 0, 0x100);
1795 memset(mc_other, 0, 0x100); 1795 memset(mc_other, 0, 0x100);
1796 1796
1797 for (addr = dev->mc_list; addr != NULL; addr = addr->next) { 1797 netdev_for_each_mc_addr(addr, dev) {
1798 u8 *a = addr->da_addr; 1798 u8 *a = addr->da_addr;
1799 u32 *table; 1799 u32 *table;
1800 int entry; 1800 int entry;
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index 1d14a8b05fa0..aae2ddb5d827 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -3035,7 +3035,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
3035 } 3035 }
3036 3036
3037 /* Walk the multicast list, and add each address */ 3037 /* Walk the multicast list, and add each address */
3038 for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) { 3038 netdev_for_each_mc_addr(mc_list, dev) {
3039 memcpy(data, &mc_list->dmi_addr, 6); 3039 memcpy(data, &mc_list->dmi_addr, 6);
3040 cmd.data0 = ntohl(data[0]); 3040 cmd.data0 = ntohl(data[0]);
3041 cmd.data1 = ntohl(data[1]); 3041 cmd.data1 = ntohl(data[1]);
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index c64e5b0d3596..e52038783245 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -2495,9 +2495,9 @@ static void __set_rx_mode(struct net_device *dev)
2495 } else { 2495 } else {
2496 struct dev_mc_list *mclist; 2496 struct dev_mc_list *mclist;
2497 int i; 2497 int i;
2498
2498 memset(mc_filter, 0, sizeof(mc_filter)); 2499 memset(mc_filter, 0, sizeof(mc_filter));
2499 for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev); 2500 netdev_for_each_mc_addr(mclist, dev) {
2500 i++, mclist = mclist->next) {
2501 int b = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 23) & 0x1ff; 2501 int b = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 23) & 0x1ff;
2502 mc_filter[b/8] |= (1 << (b & 0x07)); 2502 mc_filter[b/8] |= (1 << (b & 0x07));
2503 } 2503 }
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 25f4414cc33e..a945591298a8 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -539,7 +539,7 @@ void netxen_p2_nic_set_multi(struct net_device *netdev)
539 struct netxen_adapter *adapter = netdev_priv(netdev); 539 struct netxen_adapter *adapter = netdev_priv(netdev);
540 struct dev_mc_list *mc_ptr; 540 struct dev_mc_list *mc_ptr;
541 u8 null_addr[6]; 541 u8 null_addr[6];
542 int index = 0; 542 int i;
543 543
544 memset(null_addr, 0, 6); 544 memset(null_addr, 0, 6);
545 545
@@ -570,16 +570,13 @@ void netxen_p2_nic_set_multi(struct net_device *netdev)
570 570
571 netxen_nic_enable_mcast_filter(adapter); 571 netxen_nic_enable_mcast_filter(adapter);
572 572
573 for (mc_ptr = netdev->mc_list; mc_ptr; mc_ptr = mc_ptr->next, index++) 573 i = 0;
574 netxen_nic_set_mcast_addr(adapter, index, mc_ptr->dmi_addr); 574 netdev_for_each_mc_addr(mc_ptr, netdev)
575 575 netxen_nic_set_mcast_addr(adapter, i++, mc_ptr->dmi_addr);
576 if (index != netdev_mc_count(netdev))
577 printk(KERN_WARNING "%s: %s multicast address count mismatch\n",
578 netxen_nic_driver_name, netdev->name);
579 576
580 /* Clear out remaining addresses */ 577 /* Clear out remaining addresses */
581 for (; index < adapter->max_mc_count; index++) 578 while (i < adapter->max_mc_count)
582 netxen_nic_set_mcast_addr(adapter, index, null_addr); 579 netxen_nic_set_mcast_addr(adapter, i++, null_addr);
583} 580}
584 581
585static int 582static int
@@ -710,10 +707,8 @@ void netxen_p3_nic_set_multi(struct net_device *netdev)
710 } 707 }
711 708
712 if (!netdev_mc_empty(netdev)) { 709 if (!netdev_mc_empty(netdev)) {
713 for (mc_ptr = netdev->mc_list; mc_ptr; 710 netdev_for_each_mc_addr(mc_ptr, netdev)
714 mc_ptr = mc_ptr->next) {
715 nx_p3_nic_add_mac(adapter, mc_ptr->dmi_addr, &del_list); 711 nx_p3_nic_add_mac(adapter, mc_ptr->dmi_addr, &del_list);
716 }
717 } 712 }
718 713
719send_fw_cmd: 714send_fw_cmd:
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c
index 6a87d810e59d..c16cbfb4061b 100644
--- a/drivers/net/ni5010.c
+++ b/drivers/net/ni5010.c
@@ -651,7 +651,8 @@ static void ni5010_set_multicast_list(struct net_device *dev)
651 651
652 PRINTK2((KERN_DEBUG "%s: entering set_multicast_list\n", dev->name)); 652 PRINTK2((KERN_DEBUG "%s: entering set_multicast_list\n", dev->name));
653 653
654 if (dev->flags&IFF_PROMISC || dev->flags&IFF_ALLMULTI || dev->mc_list) { 654 if (dev->flags & IFF_PROMISC || dev->flags & IFF_ALLMULTI ||
655 !netdev_mc_empty(dev)) {
655 outb(RMD_PROMISC, EDLC_RMODE); /* Enable promiscuous mode */ 656 outb(RMD_PROMISC, EDLC_RMODE); /* Enable promiscuous mode */
656 PRINTK((KERN_DEBUG "%s: Entering promiscuous mode\n", dev->name)); 657 PRINTK((KERN_DEBUG "%s: Entering promiscuous mode\n", dev->name));
657 } else { 658 } else {
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index 497c6d514a68..05c29c2cef2a 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -596,7 +596,7 @@ static int init586(struct net_device *dev)
596 struct iasetup_cmd_struct __iomem *ias_cmd; 596 struct iasetup_cmd_struct __iomem *ias_cmd;
597 struct tdr_cmd_struct __iomem *tdr_cmd; 597 struct tdr_cmd_struct __iomem *tdr_cmd;
598 struct mcsetup_cmd_struct __iomem *mc_cmd; 598 struct mcsetup_cmd_struct __iomem *mc_cmd;
599 struct dev_mc_list *dmi = dev->mc_list; 599 struct dev_mc_list *dmi;
600 int num_addrs = netdev_mc_count(dev); 600 int num_addrs = netdev_mc_count(dev);
601 601
602 ptr = p->scb + 1; 602 ptr = p->scb + 1;
@@ -724,9 +724,9 @@ static int init586(struct net_device *dev)
724 writew(0xffff, &mc_cmd->cmd_link); 724 writew(0xffff, &mc_cmd->cmd_link);
725 writew(num_addrs * 6, &mc_cmd->mc_cnt); 725 writew(num_addrs * 6, &mc_cmd->mc_cnt);
726 726
727 for (i = 0; i < num_addrs; i++, dmi = dmi->next) 727 i = 0;
728 memcpy_toio(mc_cmd->mc_list[i], 728 netdev_for_each_mc_addr(dmi, dev)
729 dmi->dmi_addr, 6); 729 memcpy_toio(mc_cmd->mc_list[i++], dmi->dmi_addr, 6);
730 730
731 writew(make16(mc_cmd), &p->scb->cbl_offset); 731 writew(make16(mc_cmd), &p->scb->cbl_offset);
732 writeb(CUC_START, &p->scb->cmd_cuc); 732 writeb(CUC_START, &p->scb->cmd_cuc);
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 5e604e305d95..0678f3106cbc 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -6365,7 +6365,7 @@ static void niu_set_rx_mode(struct net_device *dev)
6365 for (i = 0; i < 16; i++) 6365 for (i = 0; i < 16; i++)
6366 hash[i] = 0xffff; 6366 hash[i] = 0xffff;
6367 } else if (!netdev_mc_empty(dev)) { 6367 } else if (!netdev_mc_empty(dev)) {
6368 for (addr = dev->mc_list; addr; addr = addr->next) { 6368 netdev_for_each_mc_addr(addr, dev) {
6369 u32 crc = ether_crc_le(ETH_ALEN, addr->da_addr); 6369 u32 crc = ether_crc_le(ETH_ALEN, addr->da_addr);
6370 6370
6371 crc >>= 24; 6371 crc >>= 24;
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index 11d4398eac94..36785853a149 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -1793,7 +1793,7 @@ static void netdrv_set_rx_mode(struct net_device *dev)
1793 struct netdrv_private *tp = netdev_priv(dev); 1793 struct netdrv_private *tp = netdev_priv(dev);
1794 void *ioaddr = tp->mmio_addr; 1794 void *ioaddr = tp->mmio_addr;
1795 u32 mc_filter[2]; /* Multicast hash filter */ 1795 u32 mc_filter[2]; /* Multicast hash filter */
1796 int i, rx_mode; 1796 int rx_mode;
1797 u32 tmp; 1797 u32 tmp;
1798 1798
1799 DPRINTK("ENTER\n"); 1799 DPRINTK("ENTER\n");
@@ -1814,10 +1814,10 @@ static void netdrv_set_rx_mode(struct net_device *dev)
1814 mc_filter[1] = mc_filter[0] = 0xffffffff; 1814 mc_filter[1] = mc_filter[0] = 0xffffffff;
1815 } else { 1815 } else {
1816 struct dev_mc_list *mclist; 1816 struct dev_mc_list *mclist;
1817
1817 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 1818 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
1818 mc_filter[1] = mc_filter[0] = 0; 1819 mc_filter[1] = mc_filter[0] = 0;
1819 for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev); 1820 netdev_for_each_mc_addr(mclist, dev) {
1820 i++, mclist = mclist->next) {
1821 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 1821 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
1822 1822
1823 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 1823 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 63e03159daf7..084d78dd1637 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -2590,7 +2590,7 @@ static void pcnet32_load_multicast(struct net_device *dev)
2590 struct pcnet32_private *lp = netdev_priv(dev); 2590 struct pcnet32_private *lp = netdev_priv(dev);
2591 volatile struct pcnet32_init_block *ib = lp->init_block; 2591 volatile struct pcnet32_init_block *ib = lp->init_block;
2592 volatile __le16 *mcast_table = (__le16 *)ib->filter; 2592 volatile __le16 *mcast_table = (__le16 *)ib->filter;
2593 struct dev_mc_list *dmi = dev->mc_list; 2593 struct dev_mc_list *dmi;
2594 unsigned long ioaddr = dev->base_addr; 2594 unsigned long ioaddr = dev->base_addr;
2595 char *addrs; 2595 char *addrs;
2596 int i; 2596 int i;
@@ -2611,9 +2611,8 @@ static void pcnet32_load_multicast(struct net_device *dev)
2611 ib->filter[1] = 0; 2611 ib->filter[1] = 0;
2612 2612
2613 /* Add addresses */ 2613 /* Add addresses */
2614 for (i = 0; i < netdev_mc_count(dev); i++) { 2614 netdev_for_each_mc_addr(dmi, dev) {
2615 addrs = dmi->dmi_addr; 2615 addrs = dmi->dmi_addr;
2616 dmi = dmi->next;
2617 2616
2618 /* multicast address? */ 2617 /* multicast address? */
2619 if (!(*addrs & 1)) 2618 if (!(*addrs & 1))
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index c19dd4a6cd76..a849f6f23a17 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -580,7 +580,7 @@ void gelic_net_set_multi(struct net_device *netdev)
580 } 580 }
581 581
582 /* set multicast addresses */ 582 /* set multicast addresses */
583 for (mc = netdev->mc_list; mc; mc = mc->next) { 583 netdev_for_each_mc_addr(mc, netdev) {
584 addr = 0; 584 addr = 0;
585 p = mc->dmi_addr; 585 p = mc->dmi_addr;
586 for (i = 0; i < ETH_ALEN; i++) { 586 for (i = 0; i < ETH_ALEN; i++) {
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index 8ea7f869e293..99a4d1379d00 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -453,8 +453,7 @@ void qlcnic_set_multi(struct net_device *netdev)
453 } 453 }
454 454
455 if (!netdev_mc_empty(netdev)) { 455 if (!netdev_mc_empty(netdev)) {
456 for (mc_ptr = netdev->mc_list; mc_ptr; 456 netdev_for_each_mc_addr(mc_ptr, netdev) {
457 mc_ptr = mc_ptr->next) {
458 qlcnic_nic_add_mac(adapter, mc_ptr->dmi_addr, 457 qlcnic_nic_add_mac(adapter, mc_ptr->dmi_addr,
459 &del_list); 458 &del_list);
460 } 459 }
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index c170349717c5..c26ec5d740f6 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -4270,8 +4270,8 @@ static void qlge_set_multicast_list(struct net_device *ndev)
4270 status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK); 4270 status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK);
4271 if (status) 4271 if (status)
4272 goto exit; 4272 goto exit;
4273 for (i = 0, mc_ptr = ndev->mc_list; mc_ptr; 4273 i = 0;
4274 i++, mc_ptr = mc_ptr->next) 4274 netdev_for_each_mc_addr(mc_ptr, ndev) {
4275 if (ql_set_mac_addr_reg(qdev, (u8 *) mc_ptr->dmi_addr, 4275 if (ql_set_mac_addr_reg(qdev, (u8 *) mc_ptr->dmi_addr,
4276 MAC_ADDR_TYPE_MULTI_MAC, i)) { 4276 MAC_ADDR_TYPE_MULTI_MAC, i)) {
4277 netif_err(qdev, hw, qdev->ndev, 4277 netif_err(qdev, hw, qdev->ndev,
@@ -4279,6 +4279,8 @@ static void qlge_set_multicast_list(struct net_device *ndev)
4279 ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); 4279 ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK);
4280 goto exit; 4280 goto exit;
4281 } 4281 }
4282 i++;
4283 }
4282 ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); 4284 ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK);
4283 if (ql_set_routing_reg 4285 if (ql_set_routing_reg
4284 (qdev, RT_IDX_MCAST_MATCH_SLOT, RT_IDX_MCAST_MATCH, 1)) { 4286 (qdev, RT_IDX_MCAST_MATCH_SLOT, RT_IDX_MCAST_MATCH, 1)) {
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index b8103425facb..15d5373dc8f3 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -938,7 +938,7 @@ static void r6040_multicast_list(struct net_device *dev)
938 u16 *adrp; 938 u16 *adrp;
939 u16 reg; 939 u16 reg;
940 unsigned long flags; 940 unsigned long flags;
941 struct dev_mc_list *dmi = dev->mc_list; 941 struct dev_mc_list *dmi;
942 int i; 942 int i;
943 943
944 /* MAC Address */ 944 /* MAC Address */
@@ -973,11 +973,9 @@ static void r6040_multicast_list(struct net_device *dev)
973 for (i = 0; i < 4; i++) 973 for (i = 0; i < 4; i++)
974 hash_table[i] = 0; 974 hash_table[i] = 0;
975 975
976 for (i = 0; i < netdev_mc_count(dev); i++) { 976 netdev_for_each_mc_addr(dmi, dev) {
977 char *addrs = dmi->dmi_addr; 977 char *addrs = dmi->dmi_addr;
978 978
979 dmi = dmi->next;
980
981 if (!(*addrs & 1)) 979 if (!(*addrs & 1))
982 continue; 980 continue;
983 981
@@ -995,17 +993,19 @@ static void r6040_multicast_list(struct net_device *dev)
995 iowrite16(hash_table[3], ioaddr + MAR3); 993 iowrite16(hash_table[3], ioaddr + MAR3);
996 } 994 }
997 /* Multicast Address 1~4 case */ 995 /* Multicast Address 1~4 case */
998 for (i = 0, dmi; (i < netdev_mc_count(dev)) && (i < MCAST_MAX); i++) { 996 i = 0;
999 adrp = (u16 *)dmi->dmi_addr; 997 netdev_for_each_mc_addr(dmi, dev) {
1000 iowrite16(adrp[0], ioaddr + MID_1L + 8*i); 998 if (i < MCAST_MAX) {
1001 iowrite16(adrp[1], ioaddr + MID_1M + 8*i); 999 adrp = (u16 *) dmi->dmi_addr;
1002 iowrite16(adrp[2], ioaddr + MID_1H + 8*i); 1000 iowrite16(adrp[0], ioaddr + MID_1L + 8 * i);
1003 dmi = dmi->next; 1001 iowrite16(adrp[1], ioaddr + MID_1M + 8 * i);
1004 } 1002 iowrite16(adrp[2], ioaddr + MID_1H + 8 * i);
1005 for (i = netdev_mc_count(dev); i < MCAST_MAX; i++) { 1003 } else {
1006 iowrite16(0xffff, ioaddr + MID_0L + 8*i); 1004 iowrite16(0xffff, ioaddr + MID_0L + 8 * i);
1007 iowrite16(0xffff, ioaddr + MID_0M + 8*i); 1005 iowrite16(0xffff, ioaddr + MID_0M + 8 * i);
1008 iowrite16(0xffff, ioaddr + MID_0H + 8*i); 1006 iowrite16(0xffff, ioaddr + MID_0H + 8 * i);
1007 }
1008 i++;
1009 } 1009 }
1010} 1010}
1011 1011
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 83965eeba456..dfc3573c91bb 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -4732,12 +4732,10 @@ static void rtl_set_rx_mode(struct net_device *dev)
4732 mc_filter[1] = mc_filter[0] = 0xffffffff; 4732 mc_filter[1] = mc_filter[0] = 0xffffffff;
4733 } else { 4733 } else {
4734 struct dev_mc_list *mclist; 4734 struct dev_mc_list *mclist;
4735 unsigned int i;
4736 4735
4737 rx_mode = AcceptBroadcast | AcceptMyPhys; 4736 rx_mode = AcceptBroadcast | AcceptMyPhys;
4738 mc_filter[1] = mc_filter[0] = 0; 4737 mc_filter[1] = mc_filter[0] = 0;
4739 for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev); 4738 netdev_for_each_mc_addr(mclist, dev) {
4740 i++, mclist = mclist->next) {
4741 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 4739 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
4742 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 4740 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
4743 rx_mode |= AcceptMulticast; 4741 rx_mode |= AcceptMulticast;