Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[safe/jmp/linux-2.6] / drivers / net / bmac.c
index a42bd19..959add2 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/crc32.h>
 #include <linux/bitrev.h>
 #include <linux/ethtool.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 #include <asm/dbdma.h>
 #include <asm/io.h>
@@ -166,7 +167,6 @@ static inline void
 dbdma_st32(volatile __u32 __iomem *a, unsigned long x)
 {
        __asm__ volatile( "stwbrx %0,0,%1" : : "r" (x), "r" (a) : "memory");
-       return;
 }
 
 static inline unsigned long
@@ -381,8 +381,6 @@ bmac_init_registers(struct net_device *dev)
        bmwrite(dev, RXCFG, RxCRCNoStrip | RxHashFilterEnable | RxRejectOwnPackets);
 
        bmwrite(dev, INTDISABLE, EnableNormal);
-
-       return;
 }
 
 #if 0
@@ -428,17 +426,18 @@ bmac_init_phy(struct net_device *dev)
        printk(KERN_DEBUG "phy registers:");
        for (addr = 0; addr < 32; ++addr) {
                if ((addr & 7) == 0)
-                       printk("\n" KERN_DEBUG);
-               printk(" %.4x", bmac_mif_read(dev, addr));
+                       printk(KERN_DEBUG);
+               printk(KERN_CONT " %.4x", bmac_mif_read(dev, addr));
        }
-       printk("\n");
+       printk(KERN_CONT "\n");
+
        if (bp->is_bmac_plus) {
                unsigned int capable, ctrl;
 
                ctrl = bmac_mif_read(dev, 0);
                capable = ((bmac_mif_read(dev, 1) & 0xf800) >> 6) | 1;
-               if (bmac_mif_read(dev, 4) != capable
-                   || (ctrl & 0x1000) == 0) {
+               if (bmac_mif_read(dev, 4) != capable ||
+                   (ctrl & 0x1000) == 0) {
                        bmac_mif_write(dev, 4, capable);
                        bmac_mif_write(dev, 0, 0x1200);
                } else
@@ -716,13 +715,11 @@ static irqreturn_t bmac_rxdma_intr(int irq, void *dev_id)
                        skb_put(skb, nb);
                        skb->protocol = eth_type_trans(skb, dev);
                        netif_rx(skb);
-                       dev->last_rx = jiffies;
                        ++dev->stats.rx_packets;
                        dev->stats.rx_bytes += nb;
                } else {
                        ++dev->stats.rx_dropped;
                }
-               dev->last_rx = jiffies;
                if ((skb = bp->rx_bufs[i]) == NULL) {
                        bp->rx_bufs[i] = skb = dev_alloc_skb(RX_BUFLEN+2);
                        if (skb != NULL)
@@ -972,9 +969,9 @@ bmac_remove_multi(struct net_device *dev,
  */
 static void bmac_set_multicast(struct net_device *dev)
 {
-       struct dev_mc_list *dmi;
+       struct netdev_hw_addr *ha;
        struct bmac_data *bp = netdev_priv(dev);
-       int num_addrs = dev->mc_count;
+       int num_addrs = netdev_mc_count(dev);
        unsigned short rx_cfg;
        int i;
 
@@ -983,7 +980,7 @@ static void bmac_set_multicast(struct net_device *dev)
 
        XXDEBUG(("bmac: enter bmac_set_multicast, n_addrs=%d\n", num_addrs));
 
-       if((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 64)) {
+       if((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 64)) {
                for (i=0; i<4; i++) bp->hash_table_mask[i] = 0xffff;
                bmac_update_hash_table_mask(dev, bp);
                rx_cfg = bmac_rx_on(dev, 1, 0);
@@ -1001,8 +998,8 @@ static void bmac_set_multicast(struct net_device *dev)
                        rx_cfg = bmac_rx_on(dev, 0, 0);
                        XXDEBUG(("bmac: multi disabled, rx_cfg=%#08x\n", rx_cfg));
                } else {
-                       for (dmi=dev->mc_list; dmi!=NULL; dmi=dmi->next)
-                               bmac_addhash(bp, dmi->dmi_addr);
+                       netdev_for_each_mc_addr(ha, dev)
+                               bmac_addhash(bp, ha->addr);
                        bmac_update_hash_table_mask(dev, bp);
                        rx_cfg = bmac_rx_on(dev, 1, 0);
                        XXDEBUG(("bmac: multi enabled, rx_cfg=%#08x\n", rx_cfg));
@@ -1016,13 +1013,13 @@ static void bmac_set_multicast(struct net_device *dev)
 
 static void bmac_set_multicast(struct net_device *dev)
 {
-       struct dev_mc_list *dmi = dev->mc_list;
+       struct netdev_hw_addr *ha;
        char *addrs;
        int i;
        unsigned short rx_cfg;
        u32 crc;
 
-       if((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 64)) {
+       if((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 64)) {
                bmwrite(dev, BHASH0, 0xffff);
                bmwrite(dev, BHASH1, 0xffff);
                bmwrite(dev, BHASH2, 0xffff);
@@ -1040,9 +1037,8 @@ static void bmac_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;
+               netdev_for_each_mc_addr(ha, dev) {
+                       addrs = ha->addr;
 
                        if(!(*addrs & 1))
                                continue;
@@ -1064,7 +1060,6 @@ static int miscintcount;
 static irqreturn_t bmac_misc_intr(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
-       struct bmac_data *bp = netdev_priv(dev);
        unsigned int status = bmread(dev, STATUS);
        if (miscintcount++ < 10) {
                XXDEBUG(("bmac_misc_intr\n"));
@@ -1242,7 +1237,7 @@ static void bmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *inf
 {
        struct bmac_data *bp = netdev_priv(dev);
        strcpy(info->driver, "bmac");
-       strcpy(info->bus_info, bp->mdev->ofdev.dev.bus_id);
+       strcpy(info->bus_info, dev_name(&bp->mdev->ofdev.dev));
 }
 
 static const struct ethtool_ops bmac_ethtool_ops = {
@@ -1250,6 +1245,16 @@ static const struct ethtool_ops bmac_ethtool_ops = {
        .get_link               = ethtool_op_get_link,
 };
 
+static const struct net_device_ops bmac_netdev_ops = {
+       .ndo_open               = bmac_open,
+       .ndo_stop               = bmac_close,
+       .ndo_start_xmit         = bmac_output,
+       .ndo_set_multicast_list = bmac_set_multicast,
+       .ndo_set_mac_address    = bmac_set_address,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)
 {
        int j, rev, ret;
@@ -1258,7 +1263,6 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
        unsigned char addr[6];
        struct net_device *dev;
        int is_bmac_plus = ((int)match->data) != 0;
-       DECLARE_MAC_BUF(mac);
 
        if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) {
                printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n");
@@ -1312,12 +1316,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
        bmac_enable_and_reset_chip(dev);
        bmwrite(dev, INTDISABLE, DisableAll);
 
-       dev->open = bmac_open;
-       dev->stop = bmac_close;
+       dev->netdev_ops = &bmac_netdev_ops;
        dev->ethtool_ops = &bmac_ethtool_ops;
-       dev->hard_start_xmit = bmac_output;
-       dev->set_multicast_list = bmac_set_multicast;
-       dev->set_mac_address = bmac_set_address;
 
        bmac_get_station_address(dev, addr);
        if (bmac_verify_checksum(dev) != 0)
@@ -1368,8 +1368,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
                goto err_out_irq2;
        }
 
-       printk(KERN_INFO "%s: BMAC%s at %s",
-              dev->name, (is_bmac_plus ? "+" : ""), print_mac(mac, dev->dev_addr));
+       printk(KERN_INFO "%s: BMAC%s at %pM",
+              dev->name, (is_bmac_plus ? "+" : ""), dev->dev_addr);
        XXDEBUG((", base_addr=%#0lx", dev->base_addr));
        printk("\n");
 
@@ -1486,7 +1486,7 @@ bmac_output(struct sk_buff *skb, struct net_device *dev)
        struct bmac_data *bp = netdev_priv(dev);
        skb_queue_tail(bp->queue, skb);
        bmac_start(dev);
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void bmac_tx_timeout(unsigned long data)
@@ -1654,8 +1654,11 @@ MODULE_DEVICE_TABLE (of, bmac_match);
 
 static struct macio_driver bmac_driver =
 {
-       .name           = "bmac",
-       .match_table    = bmac_match,
+       .driver = {
+               .name           = "bmac",
+               .owner          = THIS_MODULE,
+               .of_match_table = bmac_match,
+       },
        .probe          = bmac_probe,
        .remove         = bmac_remove,
 #ifdef CONFIG_PM