Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[safe/jmp/linux-2.6] / drivers / net / 3c509.c
index 54dac06..91abb96 100644 (file)
@@ -40,7 +40,7 @@
                v1.14 10/15/97 Avoided waiting..discard message for fast machines -djb
                v1.15 1/31/98 Faster recovery for Tx errors. -djb
                v1.16 2/3/98 Different ID port handling to avoid sound cards. -djb
-               v1.18 12Mar2001 Andrew Morton <andrewm@uow.edu.au>
+               v1.18 12Mar2001 Andrew Morton
                        - Avoid bogus detect of 3c590's (Andrzej Krzysztofowicz)
                        - Reviewed against 1.18 from scyld.com
                v1.18a 17Nov2001 Jeff Garzik <jgarzik@pobox.com>
@@ -76,7 +76,6 @@
 #include <linux/interrupt.h>
 #include <linux/errno.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/netdevice.h>
@@ -94,7 +93,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-static char version[] __initdata = DRV_NAME ".c:" DRV_VERSION " " DRV_RELDATE " becker@scyld.com\n";
+static char version[] __devinitdata = DRV_NAME ".c:" DRV_VERSION " " DRV_RELDATE " becker@scyld.com\n";
 
 #ifdef EL3_DEBUG
 static int el3_debug = EL3_DEBUG;
@@ -167,7 +166,6 @@ enum RxFilter {
 enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA };
 
 struct el3_private {
-       struct net_device_stats stats;
        spinlock_t lock;
        /* skb send-queue */
        int head, size;
@@ -187,12 +185,12 @@ static int max_interrupt_work = 10;
 static int nopnp;
 #endif
 
-static int __init el3_common_init(struct net_device *dev);
+static int __devinit el3_common_init(struct net_device *dev);
 static void el3_common_remove(struct net_device *dev);
 static ushort id_read_eeprom(int index);
 static ushort read_eeprom(int ioaddr, int index);
 static int el3_open(struct net_device *dev);
-static int el3_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t el3_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static irqreturn_t el3_interrupt(int irq, void *dev_id);
 static void update_stats(struct net_device *dev);
 static struct net_device_stats *el3_get_stats(struct net_device *dev);
@@ -254,11 +252,11 @@ static int el3_isa_id_sequence(__be16 *phys_addr)
                   This check is needed in order not to register them twice. */
                for (i = 0; i < el3_cards; i++) {
                        struct el3_private *lp = netdev_priv(el3_devs[i]);
-                       if (lp->type == EL3_PNP
-                           && !memcmp(phys_addr, el3_devs[i]->dev_addr,
-                                      ETH_ALEN)) {
+                       if (lp->type == EL3_PNP &&
+                           !memcmp(phys_addr, el3_devs[i]->dev_addr,
+                                   ETH_ALEN)) {
                                if (el3_debug > 3)
-                                       printk(KERN_DEBUG "3c509 with address %02x %02x %02x %02x %02x %02x was found by ISAPnP\n",
+                                       pr_debug("3c509 with address %02x %02x %02x %02x %02x %02x was found by ISAPnP\n",
                                                phys_addr[0] & 0xff, phys_addr[0] >> 8,
                                                phys_addr[1] & 0xff, phys_addr[1] >> 8,
                                                phys_addr[2] & 0xff, phys_addr[2] >> 8);
@@ -414,7 +412,7 @@ static int __devinit el3_pnp_probe(struct pnp_dev *pdev,
 {
        short i;
        int ioaddr, irq, if_port;
-       u16 phys_addr[3];
+       __be16 phys_addr[3];
        struct net_device *dev = NULL;
        int err;
 
@@ -481,9 +479,13 @@ static int pnp_registered;
 
 #ifdef CONFIG_EISA
 static struct eisa_device_id el3_eisa_ids[] = {
+               { "TCM5090" },
+               { "TCM5091" },
                { "TCM5092" },
                { "TCM5093" },
+               { "TCM5094" },
                { "TCM5095" },
+               { "TCM5098" },
                { "" }
 };
 MODULE_DEVICE_TABLE(eisa, el3_eisa_ids);
@@ -538,11 +540,25 @@ static struct mca_driver el3_mca_driver = {
 static int mca_registered;
 #endif /* CONFIG_MCA */
 
-static int __init el3_common_init(struct net_device *dev)
+static const struct net_device_ops netdev_ops = {
+       .ndo_open               = el3_open,
+       .ndo_stop               = el3_close,
+       .ndo_start_xmit         = el3_start_xmit,
+       .ndo_get_stats          = el3_get_stats,
+       .ndo_set_multicast_list = set_multicast_list,
+       .ndo_tx_timeout         = el3_tx_timeout,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = el3_poll_controller,
+#endif
+};
+
+static int __devinit el3_common_init(struct net_device *dev)
 {
        struct el3_private *lp = netdev_priv(dev);
        int err;
-       DECLARE_MAC_BUF(mac);
        const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
 
        spin_lock_init(&lp->lock);
@@ -555,33 +571,24 @@ static int __init el3_common_init(struct net_device *dev)
        }
 
        /* The EL3-specific entries in the device structure. */
-       dev->open = &el3_open;
-       dev->hard_start_xmit = &el3_start_xmit;
-       dev->stop = &el3_close;
-       dev->get_stats = &el3_get_stats;
-       dev->set_multicast_list = &set_multicast_list;
-       dev->tx_timeout = el3_tx_timeout;
+       dev->netdev_ops = &netdev_ops;
        dev->watchdog_timeo = TX_TIMEOUT;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       dev->poll_controller = el3_poll_controller;
-#endif
        SET_ETHTOOL_OPS(dev, &ethtool_ops);
 
        err = register_netdev(dev);
        if (err) {
-               printk(KERN_ERR "Failed to register 3c5x9 at %#3.3lx, IRQ %d.\n",
+               pr_err("Failed to register 3c5x9 at %#3.3lx, IRQ %d.\n",
                        dev->base_addr, dev->irq);
                release_region(dev->base_addr, EL3_IO_EXTENT);
                return err;
        }
 
-       printk(KERN_INFO "%s: 3c5x9 found at %#3.3lx, %s port, "
-              "address %s, IRQ %d.\n",
+       pr_info("%s: 3c5x9 found at %#3.3lx, %s port, address %pM, IRQ %d.\n",
               dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)],
-              print_mac(mac, dev->dev_addr), dev->irq);
+              dev->dev_addr, dev->irq);
 
        if (el3_debug > 0)
-               printk(KERN_INFO "%s", version);
+               pr_info("%s", version);
        return 0;
 
 }
@@ -606,7 +613,7 @@ static int __init el3_mca_probe(struct device *device)
 
        short i;
        int ioaddr, irq, if_port;
-       u16 phys_addr[3];
+       __be16 phys_addr[3];
        struct net_device *dev = NULL;
        u_char pos4, pos5;
        struct mca_device *mdev = to_mca_device(device);
@@ -620,8 +627,8 @@ static int __init el3_mca_probe(struct device *device)
        irq = pos5 & 0x0f;
 
 
-       printk(KERN_INFO "3c529: found %s at slot %d\n",
-                  el3_mca_adapter_names[mdev->index], slot + 1);
+       pr_info("3c529: found %s at slot %d\n",
+               el3_mca_adapter_names[mdev->index], slot + 1);
 
        /* claim the slot */
        strncpy(mdev->name, el3_mca_adapter_names[mdev->index],
@@ -633,27 +640,26 @@ static int __init el3_mca_probe(struct device *device)
        irq = mca_device_transform_irq(mdev, irq);
        ioaddr = mca_device_transform_ioport(mdev, ioaddr);
        if (el3_debug > 2) {
-                       printk(KERN_DEBUG "3c529: irq %d  ioaddr 0x%x  ifport %d\n", irq, ioaddr, if_port);
+               pr_debug("3c529: irq %d  ioaddr 0x%x  ifport %d\n", irq, ioaddr, if_port);
        }
        EL3WINDOW(0);
-       for (i = 0; i < 3; i++) {
-                       phys_addr[i] = htons(read_eeprom(ioaddr, i));
-       }
+       for (i = 0; i < 3; i++)
+               phys_addr[i] = htons(read_eeprom(ioaddr, i));
 
        dev = alloc_etherdev(sizeof (struct el3_private));
        if (dev == NULL) {
-                       release_region(ioaddr, EL3_IO_EXTENT);
-                       return -ENOMEM;
+               release_region(ioaddr, EL3_IO_EXTENT);
+               return -ENOMEM;
        }
 
        netdev_boot_setup_check(dev);
 
        el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_MCA);
-       device->driver_data = dev;
+       dev_set_drvdata(device, dev);
        err = el3_common_init(dev);
 
        if (err) {
-               device->driver_data = NULL;
+               dev_set_drvdata(device, NULL);
                free_netdev(dev);
                return -ENOMEM;
        }
@@ -669,7 +675,7 @@ static int __init el3_eisa_probe (struct device *device)
 {
        short i;
        int ioaddr, irq, if_port;
-       u16 phys_addr[3];
+       __be16 phys_addr[3];
        struct net_device *dev = NULL;
        struct eisa_device *edev;
        int err;
@@ -717,12 +723,12 @@ static int __init el3_eisa_probe (struct device *device)
 
 /* This remove works for all device types.
  *
- * The net dev must be stored in the driver_data field */
+ * The net dev must be stored in the driver data field */
 static int __devexit el3_device_remove (struct device *device)
 {
        struct net_device *dev;
 
-       dev  = device->driver_data;
+       dev = dev_get_drvdata(device);
 
        el3_common_remove (dev);
        return 0;
@@ -757,7 +763,7 @@ static ushort id_read_eeprom(int index)
                word = (word << 1) + (inb(id_port) & 0x01);
 
        if (el3_debug > 3)
-               printk(KERN_DEBUG "  3c509 EEPROM word %d %#4.4x.\n", index, word);
+               pr_debug("  3c509 EEPROM word %d %#4.4x.\n", index, word);
 
        return word;
 }
@@ -773,19 +779,19 @@ el3_open(struct net_device *dev)
        outw(RxReset, ioaddr + EL3_CMD);
        outw(SetStatusEnb | 0x00, ioaddr + EL3_CMD);
 
-       i = request_irq(dev->irq, &el3_interrupt, 0, dev->name, dev);
+       i = request_irq(dev->irq, el3_interrupt, 0, dev->name, dev);
        if (i)
                return i;
 
        EL3WINDOW(0);
        if (el3_debug > 3)
-               printk(KERN_DEBUG "%s: Opening, IRQ %d   status@%x %4.4x.\n", dev->name,
+               pr_debug("%s: Opening, IRQ %d    status@%x %4.4x.\n", dev->name,
                           dev->irq, ioaddr + EL3_STATUS, inw(ioaddr + EL3_STATUS));
 
        el3_up(dev);
 
        if (el3_debug > 3)
-               printk(KERN_DEBUG "%s: Opened 3c509  IRQ %d  status %4.4x.\n",
+               pr_debug("%s: Opened 3c509  IRQ %d  status %4.4x.\n",
                           dev->name, dev->irq, inw(ioaddr + EL3_STATUS));
 
        return 0;
@@ -794,16 +800,14 @@ el3_open(struct net_device *dev)
 static void
 el3_tx_timeout (struct net_device *dev)
 {
-       struct el3_private *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
 
        /* Transmitter timeout, serious problems. */
-       printk(KERN_WARNING "%s: transmit timed out, Tx_status %2.2x status %4.4x "
-                  "Tx FIFO room %d.\n",
+       pr_warning("%s: transmit timed out, Tx_status %2.2x status %4.4x Tx FIFO room %d.\n",
                   dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS),
                   inw(ioaddr + TX_FREE));
-       lp->stats.tx_errors++;
-       dev->trans_start = jiffies;
+       dev->stats.tx_errors++;
+       dev->trans_start = jiffies; /* prevent tx timeout */
        /* Issue TX_RESET and TX_START commands. */
        outw(TxReset, ioaddr + EL3_CMD);
        outw(TxEnable, ioaddr + EL3_CMD);
@@ -811,7 +815,7 @@ el3_tx_timeout (struct net_device *dev)
 }
 
 
-static int
+static netdev_tx_t
 el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct el3_private *lp = netdev_priv(dev);
@@ -820,19 +824,19 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        netif_stop_queue (dev);
 
-       lp->stats.tx_bytes += skb->len;
+       dev->stats.tx_bytes += skb->len;
 
        if (el3_debug > 4) {
-               printk(KERN_DEBUG "%s: el3_start_xmit(length = %u) called, status %4.4x.\n",
+               pr_debug("%s: el3_start_xmit(length = %u) called, status %4.4x.\n",
                           dev->name, skb->len, inw(ioaddr + EL3_STATUS));
        }
 #if 0
 #ifndef final_version
        {       /* Error-checking code, delete someday. */
                ushort status = inw(ioaddr + EL3_STATUS);
-               if (status & 0x0001             /* IRQ line active, missed one. */
-                       && inw(ioaddr + EL3_STATUS) & 1) {                      /* Make sure. */
-                       printk(KERN_DEBUG "%s: Missed interrupt, status then %04x now %04x"
+               if (status & 0x0001 &&          /* IRQ line active, missed one. */
+                   inw(ioaddr + EL3_STATUS) & 1) {                     /* Make sure. */
+                       pr_debug("%s: Missed interrupt, status then %04x now %04x"
                                   "  Tx %2.2x Rx %4.4x.\n", dev->name, status,
                                   inw(ioaddr + EL3_STATUS), inb(ioaddr + TX_STATUS),
                                   inw(ioaddr + RX_STATUS));
@@ -864,7 +868,6 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
        /* ... and the packet rounded to a doubleword. */
        outsl(ioaddr + TX_FIFO, skb->data, (skb->len + 3) >> 2);
 
-       dev->trans_start = jiffies;
        if (inw(ioaddr + TX_FREE) > 1536)
                netif_start_queue(dev);
        else
@@ -881,13 +884,13 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
                int i = 4;
 
                while (--i > 0  &&      (tx_status = inb(ioaddr + TX_STATUS)) > 0) {
-                       if (tx_status & 0x38) lp->stats.tx_aborted_errors++;
+                       if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
                        if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD);
                        if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD);
                        outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */
                }
        }
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /* The EL3 interrupt handler. */
@@ -906,7 +909,7 @@ el3_interrupt(int irq, void *dev_id)
 
        if (el3_debug > 4) {
                status = inw(ioaddr + EL3_STATUS);
-               printk(KERN_DEBUG "%s: interrupt, status %4.4x.\n", dev->name, status);
+               pr_debug("%s: interrupt, status %4.4x.\n", dev->name, status);
        }
 
        while ((status = inw(ioaddr + EL3_STATUS)) &
@@ -917,7 +920,7 @@ el3_interrupt(int irq, void *dev_id)
 
                if (status & TxAvailable) {
                        if (el3_debug > 5)
-                               printk(KERN_DEBUG "     TX room bit was handled.\n");
+                               pr_debug("      TX room bit was handled.\n");
                        /* There's room in the FIFO for a full-sized packet. */
                        outw(AckIntr | TxAvailable, ioaddr + EL3_CMD);
                        netif_wake_queue (dev);
@@ -931,12 +934,11 @@ el3_interrupt(int irq, void *dev_id)
                                outw(AckIntr | RxEarly, ioaddr + EL3_CMD);
                        }
                        if (status & TxComplete) {                      /* Really Tx error. */
-                               struct el3_private *lp = netdev_priv(dev);
                                short tx_status;
                                int i = 4;
 
                                while (--i>0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) {
-                                       if (tx_status & 0x38) lp->stats.tx_aborted_errors++;
+                                       if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
                                        if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD);
                                        if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD);
                                        outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */
@@ -956,7 +958,7 @@ el3_interrupt(int irq, void *dev_id)
                }
 
                if (--i < 0) {
-                       printk(KERN_ERR "%s: Infinite loop in interrupt, status %4.4x.\n",
+                       pr_err("%s: Infinite loop in interrupt, status %4.4x.\n",
                                   dev->name, status);
                        /* Clear all interrupts. */
                        outw(AckIntr | 0xFF, ioaddr + EL3_CMD);
@@ -967,7 +969,7 @@ el3_interrupt(int irq, void *dev_id)
        }
 
        if (el3_debug > 4) {
-               printk(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n", dev->name,
+               pr_debug("%s: exiting interrupt, status %4.4x.\n", dev->name,
                           inw(ioaddr + EL3_STATUS));
        }
        spin_unlock(&lp->lock);
@@ -1002,7 +1004,7 @@ el3_get_stats(struct net_device *dev)
        spin_lock_irqsave(&lp->lock, flags);
        update_stats(dev);
        spin_unlock_irqrestore(&lp->lock, flags);
-       return &lp->stats;
+       return &dev->stats;
 }
 
 /*  Update statistics.  We change to register window 6, so this should be run
@@ -1012,22 +1014,21 @@ el3_get_stats(struct net_device *dev)
        */
 static void update_stats(struct net_device *dev)
 {
-       struct el3_private *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
 
        if (el3_debug > 5)
-               printk("   Updating the statistics.\n");
+               pr_debug("   Updating the statistics.\n");
        /* Turn off statistics updates while reading. */
        outw(StatsDisable, ioaddr + EL3_CMD);
        /* Switch to the stats window, and read everything. */
        EL3WINDOW(6);
-       lp->stats.tx_carrier_errors     += inb(ioaddr + 0);
-       lp->stats.tx_heartbeat_errors   += inb(ioaddr + 1);
+       dev->stats.tx_carrier_errors    += inb(ioaddr + 0);
+       dev->stats.tx_heartbeat_errors  += inb(ioaddr + 1);
        /* Multiple collisions. */         inb(ioaddr + 2);
-       lp->stats.collisions            += inb(ioaddr + 3);
-       lp->stats.tx_window_errors      += inb(ioaddr + 4);
-       lp->stats.rx_fifo_errors        += inb(ioaddr + 5);
-       lp->stats.tx_packets            += inb(ioaddr + 6);
+       dev->stats.collisions           += inb(ioaddr + 3);
+       dev->stats.tx_window_errors     += inb(ioaddr + 4);
+       dev->stats.rx_fifo_errors       += inb(ioaddr + 5);
+       dev->stats.tx_packets           += inb(ioaddr + 6);
        /* Rx packets   */                 inb(ioaddr + 7);
        /* Tx deferrals */                 inb(ioaddr + 8);
        inw(ioaddr + 10);       /* Total Rx and Tx octets. */
@@ -1036,41 +1037,38 @@ static void update_stats(struct net_device *dev)
        /* Back to window 1, and turn statistics back on. */
        EL3WINDOW(1);
        outw(StatsEnable, ioaddr + EL3_CMD);
-       return;
 }
 
 static int
 el3_rx(struct net_device *dev)
 {
-       struct el3_private *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
        short rx_status;
 
        if (el3_debug > 5)
-               printk("   In rx_packet(), status %4.4x, rx_status %4.4x.\n",
+               pr_debug("   In rx_packet(), status %4.4x, rx_status %4.4x.\n",
                           inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS));
        while ((rx_status = inw(ioaddr + RX_STATUS)) > 0) {
                if (rx_status & 0x4000) { /* Error, update stats. */
                        short error = rx_status & 0x3800;
 
                        outw(RxDiscard, ioaddr + EL3_CMD);
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_errors++;
                        switch (error) {
-                       case 0x0000:            lp->stats.rx_over_errors++; break;
-                       case 0x0800:            lp->stats.rx_length_errors++; break;
-                       case 0x1000:            lp->stats.rx_frame_errors++; break;
-                       case 0x1800:            lp->stats.rx_length_errors++; break;
-                       case 0x2000:            lp->stats.rx_frame_errors++; break;
-                       case 0x2800:            lp->stats.rx_crc_errors++; break;
+                       case 0x0000:            dev->stats.rx_over_errors++; break;
+                       case 0x0800:            dev->stats.rx_length_errors++; break;
+                       case 0x1000:            dev->stats.rx_frame_errors++; break;
+                       case 0x1800:            dev->stats.rx_length_errors++; break;
+                       case 0x2000:            dev->stats.rx_frame_errors++; break;
+                       case 0x2800:            dev->stats.rx_crc_errors++; break;
                        }
                } else {
                        short pkt_len = rx_status & 0x7ff;
                        struct sk_buff *skb;
 
                        skb = dev_alloc_skb(pkt_len+5);
-                       lp->stats.rx_bytes += pkt_len;
                        if (el3_debug > 4)
-                               printk("Receiving packet size %d status %4.4x.\n",
+                               pr_debug("Receiving packet size %d status %4.4x.\n",
                                           pkt_len, rx_status);
                        if (skb != NULL) {
                                skb_reserve(skb, 2);     /* Align IP on 16 byte */
@@ -1082,19 +1080,19 @@ el3_rx(struct net_device *dev)
                                outw(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */
                                skb->protocol = eth_type_trans(skb,dev);
                                netif_rx(skb);
-                               dev->last_rx = jiffies;
-                               lp->stats.rx_packets++;
+                               dev->stats.rx_bytes += pkt_len;
+                               dev->stats.rx_packets++;
                                continue;
                        }
                        outw(RxDiscard, ioaddr + EL3_CMD);
-                       lp->stats.rx_dropped++;
+                       dev->stats.rx_dropped++;
                        if (el3_debug)
-                               printk("%s: Couldn't allocate a sk_buff of size %d.\n",
+                               pr_debug("%s: Couldn't allocate a sk_buff of size %d.\n",
                                           dev->name, pkt_len);
                }
                inw(ioaddr + EL3_STATUS);                               /* Delay. */
                while (inw(ioaddr + EL3_STATUS) & 0x1000)
-                       printk(KERN_DEBUG "     Waiting for 3c509 to discard packet, status %x.\n",
+                       pr_debug("      Waiting for 3c509 to discard packet, status %x.\n",
                                   inw(ioaddr + EL3_STATUS) );
        }
 
@@ -1110,12 +1108,14 @@ set_multicast_list(struct net_device *dev)
        unsigned long flags;
        struct el3_private *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
+       int mc_count = netdev_mc_count(dev);
 
        if (el3_debug > 1) {
                static int old;
-               if (old != dev->mc_count) {
-                       old = dev->mc_count;
-                       printk("%s: Setting Rx mode to %d addresses.\n", dev->name, dev->mc_count);
+               if (old != mc_count) {
+                       old = mc_count;
+                       pr_debug("%s: Setting Rx mode to %d addresses.\n",
+                                dev->name, mc_count);
                }
        }
        spin_lock_irqsave(&lp->lock, flags);
@@ -1123,7 +1123,7 @@ set_multicast_list(struct net_device *dev)
                outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm,
                         ioaddr + EL3_CMD);
        }
-       else if (dev->mc_count || (dev->flags&IFF_ALLMULTI)) {
+       else if (mc_count || (dev->flags&IFF_ALLMULTI)) {
                outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast, ioaddr + EL3_CMD);
        }
        else
@@ -1138,7 +1138,7 @@ el3_close(struct net_device *dev)
        struct el3_private *lp = netdev_priv(dev);
 
        if (el3_debug > 2)
-               printk("%s: Shutting down ethercard.\n", dev->name);
+               pr_debug("%s: Shutting down ethercard.\n", dev->name);
 
        el3_down(dev);
 
@@ -1385,30 +1385,30 @@ el3_up(struct net_device *dev)
                EL3WINDOW(4);
                net_diag = inw(ioaddr + WN4_NETDIAG);
                net_diag = (net_diag | FD_ENABLE); /* temporarily assume full-duplex will be set */
-               printk("%s: ", dev->name);
+               pr_info("%s: ", dev->name);
                switch (dev->if_port & 0x0c) {
                        case 12:
                                /* force full-duplex mode if 3c5x9b */
                                if (sw_info & 0x000f) {
-                                       printk("Forcing 3c5x9b full-duplex mode");
+                                       pr_cont("Forcing 3c5x9b full-duplex mode");
                                        break;
                                }
                        case 8:
                                /* set full-duplex mode based on eeprom config setting */
                                if ((sw_info & 0x000f) && (sw_info & 0x8000)) {
-                                       printk("Setting 3c5x9b full-duplex mode (from EEPROM configuration bit)");
+                                       pr_cont("Setting 3c5x9b full-duplex mode (from EEPROM configuration bit)");
                                        break;
                                }
                        default:
                                /* xcvr=(0 || 4) OR user has an old 3c5x9 non "B" model */
-                               printk("Setting 3c5x9/3c5x9B half-duplex mode");
+                               pr_cont("Setting 3c5x9/3c5x9B half-duplex mode");
                                net_diag = (net_diag & ~FD_ENABLE); /* disable full duplex */
                }
 
                outw(net_diag, ioaddr + WN4_NETDIAG);
-               printk(" if_port: %d, sw_info: %4.4x\n", dev->if_port, sw_info);
+               pr_cont(" if_port: %d, sw_info: %4.4x\n", dev->if_port, sw_info);
                if (el3_debug > 3)
-                       printk("%s: 3c5x9 net diag word is now: %4.4x.\n", dev->name, net_diag);
+                       pr_debug("%s: 3c5x9 net diag word is now: %4.4x.\n", dev->name, net_diag);
                /* Enable link beat and jabber check. */
                outw(inw(ioaddr + WN4_MEDIA) | MEDIA_TP, ioaddr + WN4_MEDIA);
        }
@@ -1452,7 +1452,7 @@ el3_suspend(struct device *pdev, pm_message_t state)
        struct el3_private *lp;
        int ioaddr;
 
-       dev = pdev->driver_data;
+       dev = dev_get_drvdata(pdev);
        lp = netdev_priv(dev);
        ioaddr = dev->base_addr;
 
@@ -1476,13 +1476,14 @@ el3_resume(struct device *pdev)
        struct el3_private *lp;
        int ioaddr;
 
-       dev = pdev->driver_data;
+       dev = dev_get_drvdata(pdev);
        lp = netdev_priv(dev);
        ioaddr = dev->base_addr;
 
        spin_lock_irqsave(&lp->lock, flags);
 
        outw(PowerUp, ioaddr + EL3_CMD);
+       EL3WINDOW(0);
        el3_up(dev);
 
        if (netif_running(dev))
@@ -1535,7 +1536,7 @@ static int __init el3_init_module(void)
        }
        if (id_port >= 0x200) {
                id_port = 0;
-               printk(KERN_ERR "No I/O port available for 3c509 activation.\n");
+               pr_err("No I/O port available for 3c509 activation.\n");
        } else {
                ret = isa_register_driver(&el3_isa_driver, EL3_MAX_CARDS);
                if (!ret)