Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes...
[safe/jmp/linux-2.6] / drivers / net / r6040.c
index 7238a6f..0298d8c 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
@@ -49,8 +48,8 @@
 #include <asm/processor.h>
 
 #define DRV_NAME       "r6040"
-#define DRV_VERSION    "0.24"
-#define DRV_RELDATE    "08Jul2009"
+#define DRV_VERSION    "0.25"
+#define DRV_RELDATE    "20Aug2009"
 
 /* PHY CHIP Address */
 #define PHY1_ADDR      1       /* For MAC1 */
 #define RX_DESC_SIZE   (RX_DCNT * sizeof(struct r6040_descriptor))
 #define TX_DESC_SIZE   (TX_DCNT * sizeof(struct r6040_descriptor))
 #define MBCR_DEFAULT   0x012A  /* MAC Bus Control Register */
-#define MCAST_MAX      4       /* Max number multicast addresses to filter */
+#define MCAST_MAX      3       /* Max number multicast addresses to filter */
 
 /* Descriptor status */
 #define DSC_OWNER_MAC  0x8000  /* MAC is the owner of this descriptor */
@@ -842,7 +841,7 @@ static int r6040_open(struct net_device *dev)
        int ret;
 
        /* Request IRQ and Register interrupt handler */
-       ret = request_irq(dev->irq, &r6040_interrupt,
+       ret = request_irq(dev->irq, r6040_interrupt,
                IRQF_SHARED, dev->name, dev);
        if (ret)
                return ret;
@@ -883,13 +882,13 @@ static int r6040_open(struct net_device *dev)
        return 0;
 }
 
-static int r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t r6040_start_xmit(struct sk_buff *skb,
+                                   struct net_device *dev)
 {
        struct r6040_private *lp = netdev_priv(dev);
        struct r6040_descriptor *descptr;
        void __iomem *ioaddr = lp->base;
        unsigned long flags;
-       int ret = NETDEV_TX_OK;
 
        /* Critical Section */
        spin_lock_irqsave(&lp->lock, flags);
@@ -899,8 +898,7 @@ static int r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
                spin_unlock_irqrestore(&lp->lock, flags);
                netif_stop_queue(dev);
                printk(KERN_ERR DRV_NAME ": no tx descriptor\n");
-               ret = NETDEV_TX_BUSY;
-               return ret;
+               return NETDEV_TX_BUSY;
        }
 
        /* Statistic Counter */
@@ -928,7 +926,8 @@ static int r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        dev->trans_start = jiffies;
        spin_unlock_irqrestore(&lp->lock, flags);
-       return ret;
+
+       return NETDEV_TX_OK;
 }
 
 static void r6040_multicast_list(struct net_device *dev)
@@ -938,7 +937,7 @@ static void r6040_multicast_list(struct net_device *dev)
        u16 *adrp;
        u16 reg;
        unsigned long flags;
-       struct dev_mc_list *dmi = dev->mc_list;
+       struct dev_mc_list *dmi;
        int i;
 
        /* MAC Address */
@@ -958,26 +957,24 @@ static void r6040_multicast_list(struct net_device *dev)
        }
        /* Too many multicast addresses
         * accept all traffic */
-       else if ((dev->mc_count > MCAST_MAX)
-               || (dev->flags & IFF_ALLMULTI))
+       else if ((netdev_mc_count(dev) > MCAST_MAX) ||
+                (dev->flags & IFF_ALLMULTI))
                reg |= 0x0020;
 
        iowrite16(reg, ioaddr);
        spin_unlock_irqrestore(&lp->lock, flags);
 
        /* Build the hash table */
-       if (dev->mc_count > MCAST_MAX) {
+       if (netdev_mc_count(dev) > MCAST_MAX) {
                u16 hash_table[4];
                u32 crc;
 
                for (i = 0; i < 4; i++)
                        hash_table[i] = 0;
 
-               for (i = 0; i < dev->mc_count; i++) {
+               netdev_for_each_mc_addr(dmi, dev) {
                        char *addrs = dmi->dmi_addr;
 
-                       dmi = dmi->next;
-
                        if (!(*addrs & 1))
                                continue;
 
@@ -985,9 +982,6 @@ static void r6040_multicast_list(struct net_device *dev)
                        crc >>= 26;
                        hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf));
                }
-               /* Write the index of the hash table */
-               for (i = 0; i < 4; i++)
-                       iowrite16(hash_table[i] << 14, ioaddr + MCR1);
                /* Fill the MAC hash tables with their values */
                iowrite16(hash_table[0], ioaddr + MAR0);
                iowrite16(hash_table[1], ioaddr + MAR1);
@@ -995,17 +989,19 @@ static void r6040_multicast_list(struct net_device *dev)
                iowrite16(hash_table[3], ioaddr + MAR3);
        }
        /* Multicast Address 1~4 case */
-       for (i = 0, dmi; (i < dev->mc_count) && (i < MCAST_MAX); i++) {
-               adrp = (u16 *)dmi->dmi_addr;
-               iowrite16(adrp[0], ioaddr + MID_1L + 8*i);
-               iowrite16(adrp[1], ioaddr + MID_1M + 8*i);
-               iowrite16(adrp[2], ioaddr + MID_1H + 8*i);
-               dmi = dmi->next;
-       }
-       for (i = dev->mc_count; i < MCAST_MAX; i++) {
-               iowrite16(0xffff, ioaddr + MID_0L + 8*i);
-               iowrite16(0xffff, ioaddr + MID_0M + 8*i);
-               iowrite16(0xffff, ioaddr + MID_0H + 8*i);
+       i = 0;
+       netdev_for_each_mc_addr(dmi, dev) {
+               if (i < MCAST_MAX) {
+                       adrp = (u16 *) dmi->dmi_addr;
+                       iowrite16(adrp[0], ioaddr + MID_1L + 8 * i);
+                       iowrite16(adrp[1], ioaddr + MID_1M + 8 * i);
+                       iowrite16(adrp[2], ioaddr + MID_1H + 8 * i);
+               } else {
+                       iowrite16(0xffff, ioaddr + MID_1L + 8 * i);
+                       iowrite16(0xffff, ioaddr + MID_1M + 8 * i);
+                       iowrite16(0xffff, ioaddr + MID_1H + 8 * i);
+               }
+               i++;
        }
 }
 
@@ -1085,7 +1081,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
        int bar = 0;
        u16 *adrp;
 
-       printk(KERN_INFO "%s\n", version);
+       printk("%s\n", version);
 
        err = pci_enable_device(pdev);
        if (err)
@@ -1223,7 +1219,7 @@ static void __devexit r6040_remove_one(struct pci_dev *pdev)
 }
 
 
-static struct pci_device_id r6040_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(r6040_pci_tbl) = {
        { PCI_DEVICE(PCI_VENDOR_ID_RDC, 0x6040) },
        { 0 }
 };