Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/linville...
[safe/jmp/linux-2.6] / drivers / net / mace.c
index b52f050..b6855a6 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/crc32.h>
 #include <linux/spinlock.h>
 #include <linux/bitrev.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 #include <asm/dbdma.h>
 #include <asm/io.h>
@@ -94,6 +95,16 @@ static void __mace_set_address(struct net_device *dev, void *addr);
  */
 static unsigned char *dummy_buf;
 
+static const struct net_device_ops mace_netdev_ops = {
+       .ndo_open               = mace_open,
+       .ndo_stop               = mace_close,
+       .ndo_start_xmit         = mace_xmit_start,
+       .ndo_set_multicast_list = mace_set_multicast,
+       .ndo_set_mac_address    = mace_set_address,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_id *match)
 {
        struct device_node *mace = macio_get_of_node(mdev);
@@ -143,7 +154,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
        }
        SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
 
-       mp = dev->priv;
+       mp = netdev_priv(dev);
        mp->mdev = mdev;
        macio_set_drvdata(mdev, dev);
 
@@ -164,7 +175,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
                        in_8(&mp->mace->chipid_lo);
 
 
-       mp = (struct mace_data *) dev->priv;
+       mp = netdev_priv(dev);
        mp->maccc = ENXMT | ENRCV;
 
        mp->tx_dma = ioremap(macio_resource_start(mdev, 1), 0x1000);
@@ -196,7 +207,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
                mp->port_aaui = port_aaui;
        else {
                /* Apple Network Server uses the AAUI port */
-               if (machine_is_compatible("AAPL,ShinerESB"))
+               if (of_machine_is_compatible("AAPL,ShinerESB"))
                        mp->port_aaui = 1;
                else {
 #ifdef CONFIG_MACE_AAUI_PORT
@@ -207,11 +218,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
                }
        }
 
-       dev->open = mace_open;
-       dev->stop = mace_close;
-       dev->hard_start_xmit = mace_xmit_start;
-       dev->set_multicast_list = mace_set_multicast;
-       dev->set_mac_address = mace_set_address;
+       dev->netdev_ops = &mace_netdev_ops;
 
        /*
         * Most of what is below could be moved to mace_open()
@@ -275,7 +282,7 @@ static int __devexit mace_remove(struct macio_dev *mdev)
 
        macio_set_drvdata(mdev, NULL);
 
-       mp = dev->priv;
+       mp = netdev_priv(dev);
 
        unregister_netdev(dev);
 
@@ -311,7 +318,7 @@ static void dbdma_reset(volatile struct dbdma_regs __iomem *dma)
 
 static void mace_reset(struct net_device *dev)
 {
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct mace __iomem *mb = mp->mace;
     int i;
 
@@ -366,7 +373,7 @@ static void mace_reset(struct net_device *dev)
 
 static void __mace_set_address(struct net_device *dev, void *addr)
 {
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct mace __iomem *mb = mp->mace;
     unsigned char *p = addr;
     int i;
@@ -387,7 +394,7 @@ static void __mace_set_address(struct net_device *dev, void *addr)
 
 static int mace_set_address(struct net_device *dev, void *addr)
 {
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct mace __iomem *mb = mp->mace;
     unsigned long flags;
 
@@ -422,7 +429,7 @@ static inline void mace_clean_rings(struct mace_data *mp)
 
 static int mace_open(struct net_device *dev)
 {
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct mace __iomem *mb = mp->mace;
     volatile struct dbdma_regs __iomem *rd = mp->rx_dma;
     volatile struct dbdma_regs __iomem *td = mp->tx_dma;
@@ -492,7 +499,7 @@ static int mace_open(struct net_device *dev)
 
 static int mace_close(struct net_device *dev)
 {
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct mace __iomem *mb = mp->mace;
     volatile struct dbdma_regs __iomem *rd = mp->rx_dma;
     volatile struct dbdma_regs __iomem *td = mp->tx_dma;
@@ -512,7 +519,7 @@ static int mace_close(struct net_device *dev)
 
 static inline void mace_set_timeout(struct net_device *dev)
 {
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
 
     if (mp->timeout_active)
        del_timer(&mp->tx_timeout);
@@ -525,7 +532,7 @@ static inline void mace_set_timeout(struct net_device *dev)
 
 static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev)
 {
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct dbdma_regs __iomem *td = mp->tx_dma;
     volatile struct dbdma_cmd *cp, *np;
     unsigned long flags;
@@ -541,7 +548,7 @@ static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev)
        netif_stop_queue(dev);
        mp->tx_fullup = 1;
        spin_unlock_irqrestore(&mp->lock, flags);
-       return 1;               /* can't take it at the moment */
+       return NETDEV_TX_BUSY;          /* can't take it at the moment */
     }
     spin_unlock_irqrestore(&mp->lock, flags);
 
@@ -575,14 +582,14 @@ static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev)
        netif_stop_queue(dev);
     spin_unlock_irqrestore(&mp->lock, flags);
 
-    return 0;
+    return NETDEV_TX_OK;
 }
 
 static void mace_set_multicast(struct net_device *dev)
 {
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct mace __iomem *mb = mp->mace;
-    int i, j;
+    int i;
     u32 crc;
     unsigned long flags;
 
@@ -592,7 +599,7 @@ static void mace_set_multicast(struct net_device *dev)
        mp->maccc |= PROM;
     } else {
        unsigned char multicast_filter[8];
-       struct dev_mc_list *dmi = dev->mc_list;
+       struct netdev_hw_addr *ha;
 
        if (dev->flags & IFF_ALLMULTI) {
            for (i = 0; i < 8; i++)
@@ -600,11 +607,10 @@ static void mace_set_multicast(struct net_device *dev)
        } else {
            for (i = 0; i < 8; i++)
                multicast_filter[i] = 0;
-           for (i = 0; i < dev->mc_count; i++) {
-               crc = ether_crc_le(6, dmi->dmi_addr);
-               j = crc >> 26;  /* bit number in multicast_filter */
-               multicast_filter[j >> 3] |= 1 << (j & 7);
-               dmi = dmi->next;
+           netdev_for_each_mc_addr(ha, dev) {
+               crc = ether_crc_le(6, ha->addr);
+               i = crc >> 26;  /* bit number in multicast_filter */
+               multicast_filter[i >> 3] |= 1 << (i & 7);
            }
        }
 #if 0
@@ -655,7 +661,7 @@ static void mace_handle_misc_intrs(struct mace_data *mp, int intr, struct net_de
 static irqreturn_t mace_interrupt(int irq, void *dev_id)
 {
     struct net_device *dev = (struct net_device *) dev_id;
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct mace __iomem *mb = mp->mace;
     volatile struct dbdma_regs __iomem *td = mp->tx_dma;
     volatile struct dbdma_cmd *cp;
@@ -801,7 +807,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
 static void mace_tx_timeout(unsigned long data)
 {
     struct net_device *dev = (struct net_device *) data;
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct mace __iomem *mb = mp->mace;
     volatile struct dbdma_regs __iomem *td = mp->tx_dma;
     volatile struct dbdma_regs __iomem *rd = mp->rx_dma;
@@ -872,7 +878,7 @@ static irqreturn_t mace_txdma_intr(int irq, void *dev_id)
 static irqreturn_t mace_rxdma_intr(int irq, void *dev_id)
 {
     struct net_device *dev = (struct net_device *) dev_id;
-    struct mace_data *mp = (struct mace_data *) dev->priv;
+    struct mace_data *mp = netdev_priv(dev);
     volatile struct dbdma_regs __iomem *rd = mp->rx_dma;
     volatile struct dbdma_cmd *cp, *np;
     int i, nb, stat, next;
@@ -891,8 +897,8 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id)
            if (next >= N_RX_RING)
                next = 0;
            np = mp->rx_cmds + next;
-           if (next != mp->rx_fill
-               && (ld_le16(&np->xfer_status) & ACTIVE) != 0) {
+           if (next != mp->rx_fill &&
+               (ld_le16(&np->xfer_status) & ACTIVE) != 0) {
                printk(KERN_DEBUG "mace: lost a status word\n");
                ++mace_lost_status;
            } else