wireless: convert to use netdev_for_each_mc_addr
authorJiri Pirko <jpirko@redhat.com>
Sat, 27 Feb 2010 07:35:45 +0000 (07:35 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 28 Feb 2010 09:44:01 +0000 (01:44 -0800)
also added missed locking in rndis_wlan.c

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wireless/libertas/main.c
drivers/net/wireless/orinoco/hw.c
drivers/net/wireless/orinoco/hw.h
drivers/net/wireless/orinoco/main.c
drivers/net/wireless/ray_cs.c
drivers/net/wireless/rndis_wlan.c
drivers/net/wireless/zd1201.c

index cd8ed7fdafad92d62a2cf112c4bbeef37a946b1c..28a1c9d1627a7cb0a73c36d07b25d594d17d00d3 100644 (file)
@@ -319,15 +319,18 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
 {
        int i = nr_addrs;
        struct dev_mc_list *mc_list;
+       int cnt;
 
        if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST))
                return nr_addrs;
 
        netif_addr_lock_bh(dev);
-       for (mc_list = dev->mc_list; mc_list; mc_list = mc_list->next) {
+       cnt = netdev_mc_count(dev);
+       netdev_for_each_mc_addr(mc_list, dev) {
                if (mac_in_list(cmd->maclist, nr_addrs, mc_list->dmi_addr)) {
                        lbs_deb_net("mcast address %s:%pM skipped\n", dev->name,
                                    mc_list->dmi_addr);
+                       cnt--;
                        continue;
                }
 
@@ -337,9 +340,10 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
                lbs_deb_net("mcast address %s:%pM added to filter\n", dev->name,
                            mc_list->dmi_addr);
                i++;
+               cnt--;
        }
        netif_addr_unlock_bh(dev);
-       if (mc_list)
+       if (cnt)
                return -EOVERFLOW;
 
        return i;
index 404830f47ab24c69d2384f0514f9160bd44a7753..e6369242e49c85479f222c51a7ba5afc81706301 100644 (file)
@@ -1028,7 +1028,7 @@ int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx)
 }
 
 int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
-                                   struct dev_addr_list *mc_list,
+                                   struct net_device *dev,
                                    int mc_count, int promisc)
 {
        hermes_t *hw = &priv->hw;
@@ -1049,24 +1049,16 @@ int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
         * group address if either we want to multicast, or if we were
         * multicasting and want to stop */
        if (!promisc && (mc_count || priv->mc_count)) {
-               struct dev_mc_list *p = mc_list;
+               struct dev_mc_list *p;
                struct hermes_multicast mclist;
-               int i;
+               int i = 0;
 
-               for (i = 0; i < mc_count; i++) {
-                       /* paranoia: is list shorter than mc_count? */
-                       BUG_ON(!p);
-                       /* paranoia: bad address size in list? */
-                       BUG_ON(p->dmi_addrlen != ETH_ALEN);
-
-                       memcpy(mclist.addr[i], p->dmi_addr, ETH_ALEN);
-                       p = p->next;
+               netdev_for_each_mc_addr(p, dev) {
+                       if (i == mc_count)
+                               break;
+                       memcpy(mclist.addr[i++], p->dmi_addr, ETH_ALEN);
                }
 
-               if (p)
-                       printk(KERN_WARNING "%s: Multicast list is "
-                              "longer than mc_count\n", priv->ndev->name);
-
                err = hermes_write_ltv(hw, USER_BAP,
                                   HERMES_RID_CNFGROUPADDRESSES,
                                   HERMES_BYTES_TO_RECLEN(mc_count * ETH_ALEN),
index e2f7fdc4d45aacdbeb01fbb2ec314f9f392bbb82..9799a1d14a638e37ebb12d698c9a16408cbe4049 100644 (file)
@@ -43,7 +43,7 @@ int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
                              u8 *tsc, size_t tsc_len);
 int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx);
 int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
-                                   struct dev_addr_list *mc_list,
+                                   struct net_device *dev,
                                    int mc_count, int promisc);
 int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
                         char buf[IW_ESSID_MAX_SIZE+1]);
index a9e9cea2d767ab79f6c6a300bc0f47b98444ae46..b42634c614b5814a9822ef3011efd11b6ab30345 100644 (file)
@@ -1676,8 +1676,7 @@ __orinoco_set_multicast_list(struct net_device *dev)
                mc_count = netdev_mc_count(dev);
        }
 
-       err = __orinoco_hw_set_multicast_list(priv, dev->mc_list, mc_count,
-                                             promisc);
+       err = __orinoco_hw_set_multicast_list(priv, dev, mc_count, promisc);
 
        return err;
 }
index 85905cab4f16ad1c7ed5bd64272f003d184adf95..84c530aa52f9d42f11f3f62f816c8fdd95767b43 100644 (file)
@@ -1871,10 +1871,8 @@ static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value,
 /*===========================================================================*/
 static void ray_update_multi_list(struct net_device *dev, int all)
 {
-       struct dev_mc_list *dmi, **dmip;
        int ccsindex;
        struct ccs __iomem *pccs;
-       int i = 0;
        ray_dev_t *local = netdev_priv(dev);
        struct pcmcia_device *link = local->finder;
        void __iomem *p = local->sram + HOST_TO_ECF_BASE;
@@ -1895,9 +1893,11 @@ static void ray_update_multi_list(struct net_device *dev, int all)
                writeb(0xff, &pccs->var);
                local->num_multi = 0xff;
        } else {
+               struct dev_mc_list *dmi;
+               int i = 0;
+
                /* Copy the kernel's list of MC addresses to card */
-               for (dmip = &dev->mc_list; (dmi = *dmip) != NULL;
-                    dmip = &dmi->next) {
+               netdev_for_each_mc_addr(dmi, dev) {
                        memcpy_toio(p, dmi->dmi_addr, ETH_ALEN);
                        dev_dbg(&link->dev,
                              "ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n",
index 65cbd060cc3085c23f094c7fc85e470ef21488f0..9f6d6bf06b8e595eda66c13470846ade5a976e89 100644 (file)
@@ -1502,6 +1502,7 @@ static void set_multicast_list(struct usbnet *usbdev)
 
        filter = RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_BROADCAST;
 
+       netif_addr_lock_bh(usbdev->net);
        if (usbdev->net->flags & IFF_PROMISC) {
                filter |= RNDIS_PACKET_TYPE_PROMISCUOUS |
                        RNDIS_PACKET_TYPE_ALL_LOCAL;
@@ -1515,16 +1516,15 @@ static void set_multicast_list(struct usbnet *usbdev)
                        netdev_warn(usbdev->net,
                                    "couldn't alloc %d bytes of memory\n",
                                    size * ETH_ALEN);
+                       netif_addr_unlock_bh(usbdev->net);
                        return;
                }
 
-               mclist = usbdev->net->mc_list;
-               for (i = 0; i < size && mclist; mclist = mclist->next) {
-                       if (mclist->dmi_addrlen != ETH_ALEN)
-                               continue;
-
-                       memcpy(buf + i * ETH_ALEN, mclist->dmi_addr, ETH_ALEN);
-                       i++;
+               i = 0;
+               netdev_for_each_mc_addr(mclist, usbdev->net) {
+                       if (i == size)
+                               break;
+                       memcpy(buf + i++ * ETH_ALEN, mclist->dmi_addr, ETH_ALEN);
                }
 
                ret = rndis_set_oid(usbdev, OID_802_3_MULTICAST_LIST, buf,
@@ -1539,6 +1539,7 @@ static void set_multicast_list(struct usbnet *usbdev)
 
                kfree(buf);
        }
+       netif_addr_unlock_bh(usbdev->net);
 
        ret = rndis_set_oid(usbdev, OID_GEN_CURRENT_PACKET_FILTER, &filter,
                                                        sizeof(filter));
index 5d2b52f4717fc0cb0ad76e8d954a7ad5aabbda10..6917286edcae555df02297b793ac6f42b6d91692 100644 (file)
@@ -875,17 +875,16 @@ static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
 static void zd1201_set_multicast(struct net_device *dev)
 {
        struct zd1201 *zd = netdev_priv(dev);
-       struct dev_mc_list *mc = dev->mc_list;
+       struct dev_mc_list *mc;
        unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI];
        int i;
 
        if (netdev_mc_count(dev) > ZD1201_MAXMULTI)
                return;
 
-       for (i=0; i<netdev_mc_count(dev); i++) {
-               memcpy(reqbuf+i*ETH_ALEN, mc->dmi_addr, ETH_ALEN);
-               mc = mc->next;
-       }
+       i = 0;
+       netdev_for_each_mc_addr(mc, dev)
+               memcpy(reqbuf + i++ * ETH_ALEN, mc->dmi_addr, ETH_ALEN);
        zd1201_setconfig(zd, ZD1201_RID_CNFGROUPADDRESS, reqbuf,
                         netdev_mc_count(dev) * ETH_ALEN, 0);
 }