sky2: Avoid race in sky2_change_mtu
[safe/jmp/linux-2.6] / drivers / net / bcm63xx_enet.c
index 1f6c548..faf5add 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/clk.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
@@ -340,11 +341,9 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
                }
 
                skb_put(skb, len);
-               skb->dev = dev;
                skb->protocol = eth_type_trans(skb, dev);
                priv->stats.rx_packets++;
                priv->stats.rx_bytes += len;
-               dev->last_rx = jiffies;
                netif_receive_skb(skb);
 
        } while (--budget > 0);
@@ -566,7 +565,6 @@ static int bcm_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        priv->stats.tx_bytes += skb->len;
        priv->stats.tx_packets++;
-       dev->trans_start = jiffies;
        ret = NETDEV_TX_OK;
 
 out_unlock:
@@ -604,7 +602,7 @@ static int bcm_enet_set_mac_address(struct net_device *dev, void *p)
 static void bcm_enet_set_multicast_list(struct net_device *dev)
 {
        struct bcm_enet_priv *priv;
-       struct dev_mc_list *mc_list;
+       struct netdev_hw_addr *ha;
        u32 val;
        int i;
 
@@ -619,7 +617,7 @@ static void bcm_enet_set_multicast_list(struct net_device *dev)
 
        /* only 3 perfect match registers left, first one is used for
         * own mac address */
-       if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > 3)
+       if ((dev->flags & IFF_ALLMULTI) || netdev_mc_count(dev) > 3)
                val |= ENET_RXCFG_ALLMCAST_MASK;
        else
                val &= ~ENET_RXCFG_ALLMCAST_MASK;
@@ -631,25 +629,22 @@ static void bcm_enet_set_multicast_list(struct net_device *dev)
                return;
        }
 
-       for (i = 0, mc_list = dev->mc_list;
-            (mc_list != NULL) && (i < dev->mc_count) && (i < 3);
-            i++, mc_list = mc_list->next) {
+       i = 0;
+       netdev_for_each_mc_addr(ha, dev) {
                u8 *dmi_addr;
                u32 tmp;
 
-               /* filter non ethernet address */
-               if (mc_list->dmi_addrlen != 6)
-                       continue;
-
+               if (i == 3)
+                       break;
                /* update perfect match registers */
-               dmi_addr = mc_list->dmi_addr;
+               dmi_addr = ha->addr;
                tmp = (dmi_addr[2] << 24) | (dmi_addr[3] << 16) |
                        (dmi_addr[4] << 8) | dmi_addr[5];
                enet_writel(priv, tmp, ENET_PML_REG(i + 1));
 
                tmp = (dmi_addr[0] << 8 | dmi_addr[1]);
                tmp |= ENET_PMH_DATAVALID_MASK;
-               enet_writel(priv, tmp, ENET_PMH_REG(i + 1));
+               enet_writel(priv, tmp, ENET_PMH_REG(i++ + 1));
        }
 
        for (; i < 3; i++) {
@@ -962,7 +957,9 @@ static int bcm_enet_open(struct net_device *dev)
        /* all set, enable mac and interrupts, start dma engine and
         * kick rx dma channel */
        wmb();
-       enet_writel(priv, ENET_CTL_ENABLE_MASK, ENET_CTL_REG);
+       val = enet_readl(priv, ENET_CTL_REG);
+       val |= ENET_CTL_ENABLE_MASK;
+       enet_writel(priv, val, ENET_CTL_REG);
        enet_dma_writel(priv, ENETDMA_CFG_EN_MASK, ENETDMA_CFG_REG);
        enet_dma_writel(priv, ENETDMA_CHANCFG_EN_MASK,
                        ENETDMA_CHANCFG_REG(priv->rx_chan));
@@ -1245,9 +1242,15 @@ static void bcm_enet_get_drvinfo(struct net_device *netdev,
        drvinfo->n_stats = BCM_ENET_STATS_LEN;
 }
 
-static int bcm_enet_get_stats_count(struct net_device *netdev)
+static int bcm_enet_get_sset_count(struct net_device *netdev,
+                                       int string_set)
 {
-       return BCM_ENET_STATS_LEN;
+       switch (string_set) {
+       case ETH_SS_STATS:
+               return BCM_ENET_STATS_LEN;
+       default:
+               return -EINVAL;
+       }
 }
 
 static void bcm_enet_get_strings(struct net_device *netdev,
@@ -1473,7 +1476,7 @@ static int bcm_enet_set_pauseparam(struct net_device *dev,
 
 static struct ethtool_ops bcm_enet_ethtool_ops = {
        .get_strings            = bcm_enet_get_strings,
-       .get_stats_count        = bcm_enet_get_stats_count,
+       .get_sset_count         = bcm_enet_get_sset_count,
        .get_ethtool_stats      = bcm_enet_get_ethtool_stats,
        .get_settings           = bcm_enet_get_settings,
        .set_settings           = bcm_enet_set_settings,
@@ -1643,7 +1646,6 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
        if (!dev)
                return -ENOMEM;
        priv = netdev_priv(dev);
-       memset(priv, 0, sizeof(*priv));
 
        ret = compute_hw_mtu(priv, dev->mtu);
        if (ret)