drivers/net: Omit check for multicast bit in netdev_for_each_mc_addr
[linux-2.6.git] / drivers / net / sunbmac.c
index 5017d7f..297a424 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/init.h>
@@ -25,6 +24,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/gfp.h>
 
 #include <asm/auxio.h>
 #include <asm/byteorder.h>
@@ -97,7 +97,7 @@ static int qec_global_reset(void __iomem *gregs)
 
 static void qec_init(struct bigmac *bp)
 {
-       struct of_device *qec_op = bp->qec_op;
+       struct platform_device *qec_op = bp->qec_op;
        void __iomem *gregs = bp->gregs;
        u8 bsizes = bp->bigmac_bursts;
        u32 regval;
@@ -362,7 +362,7 @@ static void bigmac_tcvr_write(struct bigmac *bp, void __iomem *tregs,
        default:
                printk(KERN_ERR "bigmac_tcvr_read: Whoops, no known transceiver type.\n");
                return;
-       };
+       }
 
        idle_transceiver(tregs);
        write_tcvr_bit(bp, tregs, 0);
@@ -401,7 +401,7 @@ static unsigned short bigmac_tcvr_read(struct bigmac *bp,
        default:
                printk(KERN_ERR "bigmac_tcvr_read: Whoops, no known transceiver type.\n");
                return 0xffff;
-       };
+       }
 
        idle_transceiver(tregs);
        write_tcvr_bit(bp, tregs, 0);
@@ -617,7 +617,7 @@ static void bigmac_begin_auto_negotiation(struct bigmac *bp)
        bp->timer_ticks = 0;
        bp->bigmac_timer.expires = jiffies + (12 * HZ) / 10;
        bp->bigmac_timer.data = (unsigned long) bp;
-       bp->bigmac_timer.function = &bigmac_timer;
+       bp->bigmac_timer.function = bigmac_timer;
        add_timer(&bp->bigmac_timer);
 }
 
@@ -919,7 +919,7 @@ static int bigmac_open(struct net_device *dev)
        struct bigmac *bp = netdev_priv(dev);
        int ret;
 
-       ret = request_irq(dev->irq, &bigmac_interrupt, IRQF_SHARED, dev->name, bp);
+       ret = request_irq(dev->irq, bigmac_interrupt, IRQF_SHARED, dev->name, bp);
        if (ret) {
                printk(KERN_ERR "BIGMAC: Can't order irq %d to go.\n", dev->irq);
                return ret;
@@ -982,9 +982,7 @@ static int bigmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
        sbus_writel(CREG_CTRL_TWAKEUP, bp->creg + CREG_CTRL);
 
 
-       dev->trans_start = jiffies;
-
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static struct net_device_stats *bigmac_get_stats(struct net_device *dev)
@@ -999,8 +997,7 @@ static void bigmac_set_multicast(struct net_device *dev)
 {
        struct bigmac *bp = netdev_priv(dev);
        void __iomem *bregs = bp->bregs;
-       struct dev_mc_list *dmi = dev->mc_list;
-       char *addrs;
+       struct netdev_hw_addr *ha;
        int i;
        u32 tmp, crc;
 
@@ -1013,7 +1010,7 @@ static void bigmac_set_multicast(struct net_device *dev)
        while ((sbus_readl(bregs + BMAC_RXCFG) & BIGMAC_RXCFG_ENABLE) != 0)
                udelay(20);
 
-       if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 64)) {
+       if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 64)) {
                sbus_writel(0xffff, bregs + BMAC_HTABLE0);
                sbus_writel(0xffff, bregs + BMAC_HTABLE1);
                sbus_writel(0xffff, bregs + BMAC_HTABLE2);
@@ -1028,14 +1025,8 @@ static void bigmac_set_multicast(struct net_device *dev)
                for (i = 0; i < 4; i++)
                        hash_table[i] = 0;
 
-               for (i = 0; i < dev->mc_count; i++) {
-                       addrs = dmi->dmi_addr;
-                       dmi = dmi->next;
-
-                       if (!(*addrs & 1))
-                               continue;
-
-                       crc = ether_crc_le(6, addrs);
+               netdev_for_each_mc_addr(ha, dev) {
+                       crc = ether_crc_le(6, ha->addr);
                        crc >>= 26;
                        hash_table[crc >> 4] |= 1 << (crc & 0xf);
                }
@@ -1086,8 +1077,8 @@ static const struct net_device_ops bigmac_ops = {
        .ndo_validate_addr      = eth_validate_addr,
 };
 
-static int __devinit bigmac_ether_init(struct of_device *op,
-                                      struct of_device *qec_op)
+static int __devinit bigmac_ether_init(struct platform_device *op,
+                                      struct platform_device *qec_op)
 {
        static int version_printed;
        struct net_device *dev;
@@ -1134,8 +1125,8 @@ static int __devinit bigmac_ether_init(struct of_device *op,
                goto fail_and_cleanup;
 
        /* Get supported SBUS burst sizes. */
-       bsizes = of_getintprop_default(qec_op->node, "burst-sizes", 0xff);
-       bsizes_more = of_getintprop_default(qec_op->node, "burst-sizes", 0xff);
+       bsizes = of_getintprop_default(qec_op->dev.of_node, "burst-sizes", 0xff);
+       bsizes_more = of_getintprop_default(qec_op->dev.of_node, "burst-sizes", 0xff);
 
        bsizes &= 0xff;
        if (bsizes_more != 0xff)
@@ -1187,7 +1178,7 @@ static int __devinit bigmac_ether_init(struct of_device *op,
        }
 
        /* Get the board revision of this BigMAC. */
-       bp->board_rev = of_getintprop_default(bp->bigmac_op->node,
+       bp->board_rev = of_getintprop_default(bp->bigmac_op->dev.of_node,
                                              "board-version", 1);
 
        /* Init auto-negotiation timer state. */
@@ -1204,7 +1195,7 @@ static int __devinit bigmac_ether_init(struct of_device *op,
        dev->watchdog_timeo = 5*HZ;
 
        /* Finish net device registration. */
-       dev->irq = bp->bigmac_op->irqs[0];
+       dev->irq = bp->bigmac_op->archdata.irqs[0];
        dev->dma = 0;
 
        if (register_netdev(dev)) {
@@ -1245,25 +1236,24 @@ fail_and_cleanup:
 /* QEC can be the parent of either QuadEthernet or a BigMAC.  We want
  * the latter.
  */
-static int __devinit bigmac_sbus_probe(struct of_device *op,
-                                      const struct of_device_id *match)
+static int __devinit bigmac_sbus_probe(struct platform_device *op)
 {
        struct device *parent = op->dev.parent;
-       struct of_device *qec_op;
+       struct platform_device *qec_op;
 
-       qec_op = to_of_device(parent);
+       qec_op = to_platform_device(parent);
 
        return bigmac_ether_init(op, qec_op);
 }
 
-static int __devexit bigmac_sbus_remove(struct of_device *op)
+static int __devexit bigmac_sbus_remove(struct platform_device *op)
 {
        struct bigmac *bp = dev_get_drvdata(&op->dev);
        struct device *parent = op->dev.parent;
        struct net_device *net_dev = bp->dev;
-       struct of_device *qec_op;
+       struct platform_device *qec_op;
 
-       qec_op = to_of_device(parent);
+       qec_op = to_platform_device(parent);
 
        unregister_netdev(net_dev);
 
@@ -1292,21 +1282,24 @@ static const struct of_device_id bigmac_sbus_match[] = {
 
 MODULE_DEVICE_TABLE(of, bigmac_sbus_match);
 
-static struct of_platform_driver bigmac_sbus_driver = {
-       .name           = "sunbmac",
-       .match_table    = bigmac_sbus_match,
+static struct platform_driver bigmac_sbus_driver = {
+       .driver = {
+               .name = "sunbmac",
+               .owner = THIS_MODULE,
+               .of_match_table = bigmac_sbus_match,
+       },
        .probe          = bigmac_sbus_probe,
        .remove         = __devexit_p(bigmac_sbus_remove),
 };
 
 static int __init bigmac_init(void)
 {
-       return of_register_driver(&bigmac_sbus_driver, &of_bus_type);
+       return platform_driver_register(&bigmac_sbus_driver);
 }
 
 static void __exit bigmac_exit(void)
 {
-       of_unregister_driver(&bigmac_sbus_driver);
+       platform_driver_unregister(&bigmac_sbus_driver);
 }
 
 module_init(bigmac_init);