staging: convert to use netdev_for_each_mc_addr
authorJiri Pirko <jpirko@redhat.com>
Thu, 18 Feb 2010 05:10:14 +0000 (05:10 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Feb 2010 22:47:51 +0000 (14:47 -0800)
removed needless checks in arlan-main.c and slicoss.c
fixed bug in et131x_netdev.c to actually fill addresses in.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/staging/arlan/arlan-main.c
drivers/staging/et131x/et131x_netdev.c
drivers/staging/octeon/ethernet.c
drivers/staging/slicoss/slicoss.c
drivers/staging/vt6655/device_main.c
drivers/staging/vt6656/main_usb.c
drivers/staging/wavelan/wavelan.c
drivers/staging/wavelan/wavelan_cs.c
drivers/staging/wlags49_h2/wl_netdev.c

index 921a082487a14686c3e23dfdc8d5bcaad9a68825..88fdd53cf5d3668fbbf2dd4b59f0a89ed9678ac2 100644 (file)
@@ -1455,10 +1455,10 @@ static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short
 #ifdef ARLAN_MULTICAST
                        if (!(dev->flags & IFF_ALLMULTI) &&
                                !(dev->flags & IFF_PROMISC) &&
-                               dev->mc_list)
+                               !netdev_mc_empty(dev))
                        {
                                char hw_dst_addr[6];
-                               struct dev_mc_list *dmi = dev->mc_list;
+                               struct dev_mc_list *dmi;
                                int i;
 
                                memcpy_fromio(hw_dst_addr, arlan->ultimateDestAddress, 6);
@@ -1469,20 +1469,15 @@ static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short
                                                        printk(KERN_ERR "%s mcast 0x0100 \n", dev->name);
                                                else if (hw_dst_addr[1] == 0x40)
                                                        printk(KERN_ERR "%s m/bcast 0x0140 \n", dev->name);
-                                       while (dmi)
-                                       {
-                                               if (dmi->dmi_addrlen == 6) {
-                                                       if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP)
-                                                               printk(KERN_ERR "%s mcl %pM\n",
-                                                                      dev->name, dmi->dmi_addr);
-                                                       for (i = 0; i < 6; i++)
-                                                               if (dmi->dmi_addr[i] != hw_dst_addr[i])
-                                                                       break;
-                                                       if (i == 6)
+                                       netdev_for_each_mc_entry(dmi, dev) {
+                                               if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP)
+                                                       printk(KERN_ERR "%s mcl %pM\n",
+                                                              dev->name, dmi->dmi_addr);
+                                               for (i = 0; i < 6; i++)
+                                                       if (dmi->dmi_addr[i] != hw_dst_addr[i])
                                                                break;
-                                               } else
-                                                       printk(KERN_ERR "%s: invalid multicast address length given.\n", dev->name);
-                                               dmi = dmi->next;
+                                               if (i == 6)
+                                                       break;
                                        }
                                        /* we reach here if multicast filtering is on and packet 
                                         * is multicast and not for receive */
index bc1fad248952522ff2e1148ec181af32de70a2d0..edb78ae9e593738b50bd75a1a04f2394a6243ad2 100644 (file)
@@ -411,9 +411,9 @@ void et131x_multicast(struct net_device *netdev)
 {
        struct et131x_adapter *adapter = netdev_priv(netdev);
        uint32_t PacketFilter = 0;
-       uint32_t count;
        unsigned long flags;
-       struct dev_mc_list *mclist = netdev->mc_list;
+       struct dev_mc_list *mclist;
+       int i;
 
        spin_lock_irqsave(&adapter->Lock, flags);
 
@@ -456,12 +456,13 @@ void et131x_multicast(struct net_device *netdev)
        }
 
        /* Set values in the private adapter struct */
-       adapter->MCAddressCount = netdev_mc_count(netdev);
-
-       if (!netdev_mc_empty(netdev)) {
-               count = netdev_mc_count(netdev) - 1;
-               memcpy(adapter->MCList[count], mclist->dmi_addr, ETH_ALEN);
+       i = 0;
+       netdev_for_each_mc_addr(mclist, netdev) {
+               if (i == NIC_MAX_MCAST_LIST)
+                       break;
+               memcpy(adapter->MCList[i++], mclist->dmi_addr, ETH_ALEN);
        }
+       adapter->MCAddressCount = i;
 
        /* Are the new flags different from the previous ones? If not, then no
         * action is required
index 4cfd4b136b328697f36ba3294f3273bf76bd1142..220de133a6a5e093449b5d4dc385f2ea8d4c5d25 100644 (file)
@@ -382,7 +382,7 @@ static void cvm_oct_common_set_multicast_list(struct net_device *dev)
                control.u64 = 0;
                control.s.bcst = 1;     /* Allow broadcast MAC addresses */
 
-               if (dev->mc_list || (dev->flags & IFF_ALLMULTI) ||
+               if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI) ||
                    (dev->flags & IFF_PROMISC))
                        /* Force accept multicast packets */
                        control.s.mcst = 2;
index 8c9d5e5c7702cc8eb632fc36d9e65674d2841db1..f5cc01ba4145e72e4c21e9256ec50a0d56c57f09 100644 (file)
@@ -1362,25 +1362,17 @@ static void slic_mcast_set_list(struct net_device *dev)
 {
        struct adapter *adapter = (struct adapter *)netdev_priv(dev);
        int status = STATUS_SUCCESS;
-       int i;
        char *addresses;
-       struct dev_mc_list *mc_list = dev->mc_list;
-       int mc_count = netdev_mc_count(dev);
+       struct dev_mc_list *mc_list;
 
        ASSERT(adapter);
 
-       for (i = 1; i <= mc_count; i++) {
+       netdev_for_each_mc_addr(mc_list, dev) {
                addresses = (char *) &mc_list->dmi_addr;
-               if (mc_list->dmi_addrlen == 6) {
-                       status = slic_mcast_add_list(adapter, addresses);
-                       if (status != STATUS_SUCCESS)
-                               break;
-               } else {
-                       status = -EINVAL;
+               status = slic_mcast_add_list(adapter, addresses);
+               if (status != STATUS_SUCCESS)
                        break;
-               }
                slic_mcast_set_bit(adapter, addresses);
-               mc_list = mc_list->next;
        }
 
        if (adapter->devflags_prev != dev->flags) {
index 82b3a6e0b15ab8c02ac0e217a5a5d63faad50a68..0dadb765fece2e000a3d03f573e051dbe9c3b93f 100644 (file)
@@ -3082,8 +3082,7 @@ static void device_set_multi(struct net_device *dev) {
 
     PSMgmtObject     pMgmt = pDevice->pMgmt;
     u32              mc_filter[2];
-    int              i;
-    struct dev_mc_list  *mclist;
+    struct dev_mc_list *mclist;
 
 
     VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode));
@@ -3103,8 +3102,7 @@ static void device_set_multi(struct net_device *dev) {
     }
     else {
         memset(mc_filter, 0, sizeof(mc_filter));
-        for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
-             i++, mclist = mclist->next) {
+       netdev_for_each_mc_addr(mclist, dev) {
             int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
             mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
         }
index 2c6a5350547ce4eede792644570a768388bd84d5..a8e1adbc9592daea1e114c147f6c2116477680db 100644 (file)
@@ -1596,7 +1596,7 @@ static void device_set_multi(struct net_device *dev) {
     PSMgmtObject     pMgmt = &(pDevice->sMgmtObj);
     u32              mc_filter[2];
     int              ii;
-    struct dev_mc_list  *mclist;
+    struct dev_mc_list *mclist;
     BYTE             pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
     BYTE             byTmpMode = 0;
     int              rc;
@@ -1632,8 +1632,7 @@ static void device_set_multi(struct net_device *dev) {
     }
     else {
         memset(mc_filter, 0, sizeof(mc_filter));
-        for (ii = 0, mclist = dev->mc_list; mclist && ii < netdev_mc_count(dev);
-             ii++, mclist = mclist->next) {
+       netdev_for_each_mc_addr(mclist, dev) {
             int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
             mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
         }
index 961f1417fb58f45104555af4c263230e56189e59..54ca63196fdd7e2e599b483397c50ce3d5296660 100644 (file)
@@ -1387,7 +1387,7 @@ static void wavelan_set_multicast_list(struct net_device * dev)
                }
        } else
                /* Are there multicast addresses to send? */
-       if (dev->mc_list != (struct dev_mc_list *) NULL) {
+       if (!netdev_mc_empty(dev)) {
                /*
                 * Disable promiscuous mode, but receive all packets
                 * in multicast list
@@ -3531,7 +3531,7 @@ static void wv_82586_config(struct net_device * dev)
 
        /* Any address to set? */
        if (lp->mc_count) {
-               for (dmi = dev->mc_list; dmi; dmi = dmi->next)
+               netdev_for_each_mc_addr(dmi, dev)
                        outsw(PIOP1(ioaddr), (u16 *) dmi->dmi_addr,
                              WAVELAN_ADDR_SIZE >> 1);
 
@@ -3539,7 +3539,7 @@ static void wv_82586_config(struct net_device * dev)
                printk(KERN_DEBUG
                       "%s: wv_82586_config(): set %d multicast addresses:\n",
                       dev->name, lp->mc_count);
-               for (dmi = dev->mc_list; dmi; dmi = dmi->next)
+               netdev_for_each_mc_addr(dmi, dev)
                        printk(KERN_DEBUG " %pM\n", dmi->dmi_addr);
 #endif
        }
index 08fcb226d7d66a77db763e37278a1c27a8b7c158..04f691d127b4bb9547da3c0865746e2fb4777fcb 100644 (file)
@@ -1410,8 +1410,7 @@ wavelan_set_multicast_list(struct net_device *    dev)
       }
     else
       /* If there is some multicast addresses to send */
-      if(dev->mc_list != (struct dev_mc_list *) NULL)
-       {
+      if (!netdev_mc_empty(dev)) {
          /*
           * Disable promiscuous mode, but receive all packets
           * in multicast list
@@ -3598,13 +3597,13 @@ wv_82593_config(struct net_device *     dev)
   /* If any multicast address to set */
   if(lp->mc_count)
     {
-      struct dev_mc_list *     dmi;
+      struct dev_mc_list *dmi;
       int                      addrs_len = WAVELAN_ADDR_SIZE * lp->mc_count;
 
 #ifdef DEBUG_CONFIG_INFO
       printk(KERN_DEBUG "%s: wv_hw_config(): set %d multicast addresses:\n",
             dev->name, lp->mc_count);
-      for(dmi=dev->mc_list; dmi; dmi=dmi->next)
+      netdev_for_each_mc_addr(dmi, dev)
        printk(KERN_DEBUG " %pM\n", dmi->dmi_addr);
 #endif
 
@@ -3613,7 +3612,7 @@ wv_82593_config(struct net_device *       dev)
       outb(((TX_BASE >> 8) & PIORH_MASK) | PIORH_SEL_TX, PIORH(base));
       outb(addrs_len & 0xff, PIOP(base));      /* byte count lsb */
       outb((addrs_len >> 8), PIOP(base));      /* byte count msb */
-      for(dmi=dev->mc_list; dmi; dmi=dmi->next)
+      netdev_for_each_mc_addr(dmi, dev)
        outsb(PIOP(base), dmi->dmi_addr, dmi->dmi_addrlen);
 
       /* reset transmit DMA pointer */
index a95ebf881fcde8701a2c8fb6482684269b7269b8..c33e225bc0e6561d2b612d08e5a2b7f8ce90f7e3 100644 (file)
@@ -1049,7 +1049,7 @@ void wl_multicast( struct net_device *dev )
 //;?seems reasonable that even an AP-only driver could afford this small additional footprint
 
     int                 x;
-    struct dev_mc_list  *mclist;
+    struct dev_mc_list *mclist;
     struct wl_private   *lp = wl_priv(dev);
     unsigned long       flags;
     /*------------------------------------------------------------------------*/
@@ -1072,11 +1072,9 @@ void wl_multicast( struct net_device *dev )
 
         DBG_PRINT( "  mc_count: %d\n", netdev_mc_count(dev));
 
-        for( x = 0, mclist = dev->mc_list; mclist && x < netdev_mc_count(dev);
-             x++, mclist = mclist->next ) {
+       netdev_for_each_mc_addr(mclist, dev)
             DBG_PRINT( "    %s (%d)\n", DbgHwAddr(mclist->dmi_addr),
                        mclist->dmi_addrlen );
-        }
     }
 #endif /* DBG */
 
@@ -1120,12 +1118,10 @@ void wl_multicast( struct net_device *dev )
                 lp->ltvRecord.len = ( netdev_mc_count(dev) * 3 ) + 1;
                 lp->ltvRecord.typ = CFG_GROUP_ADDR;
 
-                for( x = 0, mclist = dev->mc_list;
-                ( x < netdev_mc_count(dev)) && ( mclist != NULL );
-                    x++, mclist = mclist->next ) {
-                    memcpy( &( lp->ltvRecord.u.u8[x * ETH_ALEN] ),
-                            mclist->dmi_addr, ETH_ALEN );
-                }
+               x = 0;
+               netdev_for_each_mc_addr(mclist, dev)
+                    memcpy(&(lp->ltvRecord.u.u8[x++ * ETH_ALEN]),
+                           mclist->dmi_addr, ETH_ALEN);
                 DBG_PRINT( "Setting multicast list\n" );
                 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
             } else {