can: Fix SJA1000 command register writes on SMP systems
[safe/jmp/linux-2.6] / drivers / net / tulip / winbond-840.c
index 136a70c..608b279 100644 (file)
                        Copyright (C) 2001 Manfred Spraul
        * ethtool support (jgarzik)
        * Replace some MII-related magic numbers with constants (jgarzik)
-  
+
        TODO:
        * enable pci_power_off
        * Wake-On-LAN
 */
-  
+
 #define DRV_NAME       "winbond-840"
-#define DRV_VERSION    "1.01-d"
-#define DRV_RELDATE    "Nov-17-2001"
+#define DRV_VERSION    "1.01-e"
+#define DRV_RELDATE    "Sep-11-2006"
 
 
 /* Automatically extracted configuration info:
@@ -57,7 +57,7 @@ c-help-name: Winbond W89c840 PCI Ethernet support
 c-help-symbol: CONFIG_WINBOND_840
 c-help: This driver is for the Winbond W89c840 chip.  It also works with
 c-help: the TX9882 chip on the Compex RL100-ATX board.
-c-help: More specific information and updates are available from 
+c-help: More specific information and updates are available from
 c-help: http://www.scyld.com/network/drivers.html
 */
 
@@ -90,10 +90,8 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
    Making the Tx ring too large decreases the effectiveness of channel
    bonding and packet priority.
    There are no ill effects from too-large receive rings. */
-#define TX_RING_SIZE   16
 #define TX_QUEUE_LEN   10              /* Limit ring entries actually used.  */
 #define TX_QUEUE_LEN_RESTART   5
-#define RX_RING_SIZE   32
 
 #define TX_BUFLIMIT    (1024-128)
 
@@ -109,8 +107,6 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
 /* Time in jiffies before concluding the transmitter is hung. */
 #define TX_TIMEOUT  (2*HZ)
 
-#define PKT_BUF_SZ             1536                    /* Size of each temporary Rx buffer.*/
-
 /* Include files, designed to support most kernel versions 2.0.0 and later. */
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -118,7 +114,6 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
 #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/dma-mapping.h>
@@ -137,10 +132,16 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
 #include <asm/io.h>
 #include <asm/irq.h>
 
+#include "tulip.h"
+
+#undef PKT_BUF_SZ                      /* tulip.h also defines this */
+#define PKT_BUF_SZ             1536    /* Size of each temporary Rx buffer.*/
+
 /* These identify the driver base version and may not be removed. */
-static char version[] __devinitdata =
-KERN_INFO DRV_NAME ".c:v" DRV_VERSION " (2.4 port) " DRV_RELDATE "  Donald Becker <becker@scyld.com>\n"
-KERN_INFO "  http://www.scyld.com/network/drivers.html\n";
+static const char version[] __initconst =
+       KERN_INFO DRV_NAME ".c:v" DRV_VERSION " (2.4 port) "
+       DRV_RELDATE "  Donald Becker <becker@scyld.com>\n"
+       "  http://www.scyld.com/network/drivers.html\n";
 
 MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
 MODULE_DESCRIPTION("Winbond W89c840 Ethernet driver");
@@ -207,58 +208,43 @@ Test with 'ping -s 10000' on a fast computer.
 
 */
 
-\f
+
 
 /*
   PCI probe table.
 */
-enum pci_id_flags_bits {
-        /* Set PCI command register bits before calling probe1(). */
-        PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
-        /* Read and map the single following PCI BAR. */
-        PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
-        PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
-};
 enum chip_capability_flags {
-       CanHaveMII=1, HasBrokenTx=2, AlwaysFDX=4, FDXOnNoMII=8,};
-#ifdef USE_IO_OPS
-#define W840_FLAGS (PCI_USES_IO | PCI_ADDR0 | PCI_USES_MASTER)
-#else
-#define W840_FLAGS (PCI_USES_MEM | PCI_ADDR1 | PCI_USES_MASTER)
-#endif
+       CanHaveMII=1, HasBrokenTx=2, AlwaysFDX=4, FDXOnNoMII=8,
+};
 
-static struct pci_device_id w840_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(w840_pci_tbl) = {
        { 0x1050, 0x0840, PCI_ANY_ID, 0x8153,     0, 0, 0 },
        { 0x1050, 0x0840, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
        { 0x11f6, 0x2011, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
-       { 0, }
+       { }
 };
 MODULE_DEVICE_TABLE(pci, w840_pci_tbl);
 
+enum {
+       netdev_res_size         = 128,  /* size of PCI BAR resource */
+};
+
 struct pci_id_info {
         const char *name;
-        struct match_info {
-                int     pci, pci_mask, subsystem, subsystem_mask;
-                int revision, revision_mask;                            /* Only 8 bits. */
-        } id;
-        enum pci_id_flags_bits pci_flags;
-        int io_size;                            /* Needed for I/O region check or ioremap(). */
-        int drv_flags;                          /* Driver use, intended as capability flags. */
+        int drv_flags;         /* Driver use, intended as capability flags. */
 };
-static struct pci_id_info pci_id_tbl[] = {
-       {"Winbond W89c840",                     /* Sometime a Level-One switch card. */
-        { 0x08401050, 0xffffffff, 0x81530000, 0xffff0000 },
-        W840_FLAGS, 128, CanHaveMII | HasBrokenTx | FDXOnNoMII},
-       {"Winbond W89c840", { 0x08401050, 0xffffffff, },
-        W840_FLAGS, 128, CanHaveMII | HasBrokenTx},
-       {"Compex RL100-ATX", { 0x201111F6, 0xffffffff,},
-        W840_FLAGS, 128, CanHaveMII | HasBrokenTx},
-       {NULL,},                                        /* 0 terminated list. */
+
+static const struct pci_id_info pci_id_tbl[] __devinitdata = {
+       {                               /* Sometime a Level-One switch card. */
+         "Winbond W89c840",    CanHaveMII | HasBrokenTx | FDXOnNoMII},
+       { "Winbond W89c840",    CanHaveMII | HasBrokenTx},
+       { "Compex RL100-ATX",   CanHaveMII | HasBrokenTx},
+       { }     /* terminate list. */
 };
 
 /* This driver was written to use PCI memory space, however some x86 systems
-   work only with I/O space accesses.  Pass -DUSE_IO_OPS to use PCI I/O space
-   accesses instead of memory space. */
+   work only with I/O space accesses. See CONFIG_TULIP_MMIO in .config
+*/
 
 /* Offsets to the Command and Status Registers, "CSRs".
    While similar to the Tulip, these registers are longword aligned.
@@ -276,21 +262,11 @@ enum w840_offsets {
        CurTxDescAddr=0x4C, CurTxBufAddr=0x50,
 };
 
-/* Bits in the interrupt status/enable registers. */
-/* The bits in the Intr Status/Enable registers, mostly interrupt sources. */
-enum intr_status_bits {
-       NormalIntr=0x10000, AbnormalIntr=0x8000,
-       IntrPCIErr=0x2000, TimerInt=0x800,
-       IntrRxDied=0x100, RxNoBuf=0x80, IntrRxDone=0x40,
-       TxFIFOUnderflow=0x20, RxErrIntr=0x10,
-       TxIdle=0x04, IntrTxStopped=0x02, IntrTxDone=0x01,
-};
-
 /* Bits in the NetworkConfig register. */
 enum rx_mode_bits {
-       AcceptErr=0x80, AcceptRunt=0x40,
-       AcceptBroadcast=0x20, AcceptMulticast=0x10,
-       AcceptAllPhys=0x08, AcceptMyPhys=0x02,
+       AcceptErr=0x80,
+       RxAcceptBroadcast=0x20, AcceptMulticast=0x10,
+       RxAcceptAllPhys=0x08, AcceptMyPhys=0x02,
 };
 
 enum mii_reg_bits {
@@ -312,13 +288,6 @@ struct w840_tx_desc {
        u32 buffer1, buffer2;
 };
 
-/* Bits in network_desc.status */
-enum desc_status_bits {
-       DescOwn=0x80000000, DescEndRing=0x02000000, DescUseLink=0x01000000,
-       DescWholePkt=0x60000000, DescStartPkt=0x20000000, DescEndPkt=0x40000000,
-       DescIntr=0x80000000,
-};
-
 #define MII_CNT                1 /* winbond only supports one MII */
 struct netdev_private {
        struct w840_rx_desc *rx_ring;
@@ -363,18 +332,29 @@ static void init_registers(struct net_device *dev);
 static void tx_timeout(struct net_device *dev);
 static int alloc_ringdesc(struct net_device *dev);
 static void free_ringdesc(struct netdev_private *np);
-static int  start_tx(struct sk_buff *skb, struct net_device *dev);
-static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *regs);
+static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev);
+static irqreturn_t intr_handler(int irq, void *dev_instance);
 static void netdev_error(struct net_device *dev, int intr_status);
 static int  netdev_rx(struct net_device *dev);
 static u32 __set_rx_mode(struct net_device *dev);
 static void set_rx_mode(struct net_device *dev);
 static struct net_device_stats *get_stats(struct net_device *dev);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-static struct ethtool_ops netdev_ethtool_ops;
+static const struct ethtool_ops netdev_ethtool_ops;
 static int  netdev_close(struct net_device *dev);
 
-\f
+static const struct net_device_ops netdev_ops = {
+       .ndo_open               = netdev_open,
+       .ndo_stop               = netdev_close,
+       .ndo_start_xmit         = start_tx,
+       .ndo_get_stats          = get_stats,
+       .ndo_set_multicast_list = set_rx_mode,
+       .ndo_do_ioctl           = netdev_ioctl,
+       .ndo_tx_timeout         = tx_timeout,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
 
 static int __devinit w840_probe1 (struct pci_dev *pdev,
                                  const struct pci_device_id *ent)
@@ -386,7 +366,6 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
        int irq;
        int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
        void __iomem *ioaddr;
-       int bar = 1;
 
        i = pci_enable_device(pdev);
        if (i) return i;
@@ -395,28 +374,25 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
 
        irq = pdev->irq;
 
-       if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
-               printk(KERN_WARNING "Winbond-840: Device %s disabled due to DMA limitations.\n",
-                      pci_name(pdev));
+       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
+               pr_warning("Winbond-840: Device %s disabled due to DMA limitations\n",
+                          pci_name(pdev));
                return -EIO;
        }
        dev = alloc_etherdev(sizeof(*np));
        if (!dev)
                return -ENOMEM;
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        if (pci_request_regions(pdev, DRV_NAME))
                goto err_out_netdev;
-#ifdef USE_IO_OPS
-       bar = 0;
-#endif
-       ioaddr = pci_iomap(pdev, bar, pci_id_tbl[chip_idx].io_size);
+
+       ioaddr = pci_iomap(pdev, TULIP_BAR, netdev_res_size);
        if (!ioaddr)
                goto err_out_free_res;
 
        for (i = 0; i < 3; i++)
-               ((u16 *)dev->dev_addr)[i] = le16_to_cpu(eeprom_read(ioaddr, i));
+               ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(eeprom_read(ioaddr, i));
 
        /* Reset the chip to erase previous misconfiguration.
           No hold time required! */
@@ -434,7 +410,7 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
        np->mii_if.mdio_read = mdio_read;
        np->mii_if.mdio_write = mdio_write;
        np->base_addr = ioaddr;
-       
+
        pci_set_drvdata(pdev, dev);
 
        if (dev->mem_start)
@@ -445,8 +421,9 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
                if (option & 0x200)
                        np->mii_if.full_duplex = 1;
                if (option & 15)
-                       printk(KERN_INFO "%s: ignoring user supplied media type %d",
-                               dev->name, option & 15);
+                       dev_info(&dev->dev,
+                                "ignoring user supplied media type %d",
+                                option & 15);
        }
        if (find_cnt < MAX_UNITS  &&  full_duplex[find_cnt] > 0)
                np->mii_if.full_duplex = 1;
@@ -455,25 +432,16 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
                np->mii_if.force_media = 1;
 
        /* The chip-specific entries in the device structure. */
-       dev->open = &netdev_open;
-       dev->hard_start_xmit = &start_tx;
-       dev->stop = &netdev_close;
-       dev->get_stats = &get_stats;
-       dev->set_multicast_list = &set_rx_mode;
-       dev->do_ioctl = &netdev_ioctl;
+       dev->netdev_ops = &netdev_ops;
        dev->ethtool_ops = &netdev_ethtool_ops;
-       dev->tx_timeout = &tx_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
 
        i = register_netdev(dev);
        if (i)
                goto err_out_cleardev;
 
-       printk(KERN_INFO "%s: %s at %p, ",
-                  dev->name, pci_id_tbl[chip_idx].name, ioaddr);
-       for (i = 0; i < 5; i++)
-                       printk("%2.2x:", dev->dev_addr[i]);
-       printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq);
+       dev_info(&dev->dev, "%s at %p, %pM, IRQ %d\n",
+                pci_id_tbl[chip_idx].name, ioaddr, dev->dev_addr, irq);
 
        if (np->drv_flags & CanHaveMII) {
                int phy, phy_idx = 0;
@@ -484,16 +452,17 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
                                np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE);
                                np->mii = (mdio_read(dev, phy, MII_PHYSID1) << 16)+
                                                mdio_read(dev, phy, MII_PHYSID2);
-                               printk(KERN_INFO "%s: MII PHY %8.8xh found at address %d, status "
-                                          "0x%4.4x advertising %4.4x.\n",
-                                          dev->name, np->mii, phy, mii_status, np->mii_if.advertising);
+                               dev_info(&dev->dev,
+                                        "MII PHY %08xh found at address %d, status 0x%04x advertising %04x\n",
+                                        np->mii, phy, mii_status,
+                                        np->mii_if.advertising);
                        }
                }
                np->mii_cnt = phy_idx;
                np->mii_if.phy_id = np->phys[0];
                if (phy_idx == 0) {
-                               printk(KERN_WARNING "%s: MII PHY not found -- this device may "
-                                          "not operate correctly.\n", dev->name);
+                       dev_warn(&dev->dev,
+                                "MII PHY not found -- this device may not operate correctly\n");
                }
        }
 
@@ -510,7 +479,7 @@ err_out_netdev:
        return -ENODEV;
 }
 
-\f
+
 /* Read the EEPROM and MII Management Data I/O (MDIO) interfaces.  These are
    often serial bit streams generated by the host processor.
    The example below is for the common 93c46 EEPROM, 64 16 bit words. */
@@ -520,7 +489,7 @@ err_out_netdev:
    a delay.  Note that pre-2.0.34 kernels had a cache-alignment bug that
    made udelay() unreliable.
    The old method of using an ISA access as a delay, __SLOW_DOWN_IO__, is
-   depricated.
+   deprecated.
 */
 #define eeprom_delay(ee_addr)  ioread32(ee_addr)
 
@@ -657,10 +626,9 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
                iowrite32(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
                mdio_delay(mdio_addr);
        }
-       return;
 }
 
-\f
+
 static int netdev_open(struct net_device *dev)
 {
        struct netdev_private *np = netdev_priv(dev);
@@ -670,13 +638,13 @@ static int netdev_open(struct net_device *dev)
        iowrite32(0x00000001, ioaddr + PCIBusCfg);              /* Reset */
 
        netif_device_detach(dev);
-       i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev);
+       i = request_irq(dev->irq, intr_handler, IRQF_SHARED, dev->name, dev);
        if (i)
                goto out_err;
 
        if (debug > 1)
-               printk(KERN_DEBUG "%s: w89c840_open() irq %d.\n",
-                          dev->name, dev->irq);
+               printk(KERN_DEBUG "%s: w89c840_open() irq %d\n",
+                      dev->name, dev->irq);
 
        if((i=alloc_ringdesc(dev)))
                goto out_err;
@@ -688,7 +656,7 @@ static int netdev_open(struct net_device *dev)
 
        netif_start_queue(dev);
        if (debug > 2)
-               printk(KERN_DEBUG "%s: Done netdev_open().\n", dev->name);
+               printk(KERN_DEBUG "%s: Done netdev_open()\n", dev->name);
 
        /* Set the timer to check for link beat. */
        init_timer(&np->timer);
@@ -719,19 +687,21 @@ static int update_link(struct net_device *dev)
        if (!(mii_reg & 0x4)) {
                if (netif_carrier_ok(dev)) {
                        if (debug)
-                               printk(KERN_INFO "%s: MII #%d reports no link. Disabling watchdog.\n",
-                                       dev->name, np->phys[0]);
+                               dev_info(&dev->dev,
+                                        "MII #%d reports no link. Disabling watchdog\n",
+                                        np->phys[0]);
                        netif_carrier_off(dev);
                }
                return np->csr6;
        }
        if (!netif_carrier_ok(dev)) {
                if (debug)
-                       printk(KERN_INFO "%s: MII #%d link is back. Enabling watchdog.\n",
-                               dev->name, np->phys[0]);
+                       dev_info(&dev->dev,
+                                "MII #%d link is back. Enabling watchdog\n",
+                                np->phys[0]);
                netif_carrier_on(dev);
        }
-       
+
        if ((np->mii & ~0xf) == MII_DAVICOM_DM9101) {
                /* If the link partner doesn't support autonegotiation
                 * the MII detects it's abilities with the "parallel detection".
@@ -760,9 +730,10 @@ static int update_link(struct net_device *dev)
        if (fasteth)
                result |= 0x20000000;
        if (result != np->csr6 && debug)
-               printk(KERN_INFO "%s: Setting %dMBit-%s-duplex based on MII#%d\n",
-                                dev->name, fasteth ? 100 : 10, 
-                               duplex ? "full" : "half", np->phys[0]);
+               dev_info(&dev->dev,
+                        "Setting %dMBit-%s-duplex based on MII#%d\n",
+                        fasteth ? 100 : 10, duplex ? "full" : "half",
+                        np->phys[0]);
        return result;
 }
 
@@ -794,8 +765,8 @@ static inline void update_csr6(struct net_device *dev, int new)
 
                limit--;
                if(!limit) {
-                       printk(KERN_INFO "%s: couldn't stop rxtx, IntrStatus %xh.\n",
-                                       dev->name, csr5);
+                       dev_info(&dev->dev,
+                                "couldn't stop rxtx, IntrStatus %xh\n", csr5);
                        break;
                }
                udelay(1);
@@ -814,10 +785,9 @@ static void netdev_timer(unsigned long data)
        void __iomem *ioaddr = np->base_addr;
 
        if (debug > 2)
-               printk(KERN_DEBUG "%s: Media selection timer tick, status %8.8x "
-                          "config %8.8x.\n",
-                          dev->name, ioread32(ioaddr + IntrStatus),
-                          ioread32(ioaddr + NetworkConfig));
+               printk(KERN_DEBUG "%s: Media selection timer tick, status %08x config %08x\n",
+                      dev->name, ioread32(ioaddr + IntrStatus),
+                      ioread32(ioaddr + NetworkConfig));
        spin_lock_irq(&np->lock);
        update_csr6(dev, update_link(dev));
        spin_unlock_irq(&np->lock);
@@ -848,12 +818,11 @@ static void init_rxtx_rings(struct net_device *dev)
                np->rx_skbuff[i] = skb;
                if (skb == NULL)
                        break;
-               skb->dev = dev;                 /* Mark as being used by this device. */
                np->rx_addr[i] = pci_map_single(np->pci_dev,skb->data,
                                        np->rx_buf_sz,PCI_DMA_FROMDEVICE);
 
                np->rx_ring[i].buffer1 = np->rx_addr[i];
-               np->rx_ring[i].status = DescOwn;
+               np->rx_ring[i].status = DescOwned;
        }
 
        np->cur_rx = 0;
@@ -931,14 +900,14 @@ static void init_registers(struct net_device *dev)
        /* When not a module we can work around broken '486 PCI boards. */
        if (boot_cpu_data.x86 <= 4) {
                i |= 0x4800;
-               printk(KERN_INFO "%s: This is a 386/486 PCI system, setting cache "
-                          "alignment to 8 longwords.\n", dev->name);
+               dev_info(&dev->dev,
+                        "This is a 386/486 PCI system, setting cache alignment to 8 longwords\n");
        } else {
                i |= 0xE000;
        }
 #elif defined(__powerpc__) || defined(__i386__) || defined(__alpha__) || defined(__ia64__) || defined(__x86_64__)
        i |= 0xE000;
-#elif defined(__sparc__)
+#elif defined(CONFIG_SPARC) || defined (CONFIG_PARISC)
        i |= 0x4800;
 #else
 #warning Processor architecture undefined
@@ -947,7 +916,7 @@ static void init_registers(struct net_device *dev)
        iowrite32(i, ioaddr + PCIBusCfg);
 
        np->csr6 = 0;
-       /* 128 byte Tx threshold; 
+       /* 128 byte Tx threshold;
                Transmit on; Receive on; */
        update_csr6(dev, 0x00022002 | update_link(dev) | __set_rx_mode(dev));
 
@@ -963,22 +932,23 @@ static void tx_timeout(struct net_device *dev)
        struct netdev_private *np = netdev_priv(dev);
        void __iomem *ioaddr = np->base_addr;
 
-       printk(KERN_WARNING "%s: Transmit timed out, status %8.8x,"
-                  " resetting...\n", dev->name, ioread32(ioaddr + IntrStatus));
+       dev_warn(&dev->dev, "Transmit timed out, status %08x, resetting...\n",
+                ioread32(ioaddr + IntrStatus));
 
        {
                int i;
                printk(KERN_DEBUG "  Rx ring %p: ", np->rx_ring);
                for (i = 0; i < RX_RING_SIZE; i++)
-                       printk(" %8.8x", (unsigned int)np->rx_ring[i].status);
-               printk("\n"KERN_DEBUG"  Tx ring %p: ", np->tx_ring);
+                       printk(KERN_CONT " %08x", (unsigned int)np->rx_ring[i].status);
+               printk(KERN_CONT "\n");
+               printk(KERN_DEBUG "  Tx ring %p: ", np->tx_ring);
                for (i = 0; i < TX_RING_SIZE; i++)
-                       printk(" %8.8x", np->tx_ring[i].status);
-               printk("\n");
+                       printk(KERN_CONT " %08x", np->tx_ring[i].status);
+               printk(KERN_CONT "\n");
        }
-       printk(KERN_DEBUG "Tx cur %d Tx dirty %d Tx Full %d, q bytes %d.\n",
-                               np->cur_tx, np->dirty_tx, np->tx_full, np->tx_q_bytes);
-       printk(KERN_DEBUG "Tx Descriptor addr %xh.\n",ioread32(ioaddr+0x4C));
+       printk(KERN_DEBUG "Tx cur %d Tx dirty %d Tx Full %d, q bytes %d\n",
+              np->cur_tx, np->dirty_tx, np->tx_full, np->tx_q_bytes);
+       printk(KERN_DEBUG "Tx Descriptor addr %xh\n", ioread32(ioaddr+0x4C));
 
        disable_irq(dev->irq);
        spin_lock_irq(&np->lock);
@@ -998,9 +968,8 @@ static void tx_timeout(struct net_device *dev)
        enable_irq(dev->irq);
 
        netif_wake_queue(dev);
-       dev->trans_start = jiffies;
+       dev->trans_start = jiffies; /* prevent tx timeout */
        np->stats.tx_errors++;
-       return;
 }
 
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
@@ -1029,7 +998,7 @@ static void free_ringdesc(struct netdev_private *np)
 
 }
 
-static int start_tx(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev)
 {
        struct netdev_private *np = netdev_priv(dev);
        unsigned entry;
@@ -1057,12 +1026,12 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
                np->tx_ring[entry].length |= DescEndRing;
 
        /* Now acquire the irq spinlock.
-        * The difficult race is the the ordering between
-        * increasing np->cur_tx and setting DescOwn:
+        * The difficult race is the ordering between
+        * increasing np->cur_tx and setting DescOwned:
         * - if np->cur_tx is increased first the interrupt
         *   handler could consider the packet as transmitted
-        *   since DescOwn is cleared.
-        * - If DescOwn is set first the NIC could report the
+        *   since DescOwned is cleared.
+        * - If DescOwned is set first the NIC could report the
         *   packet as sent, but the interrupt handler would ignore it
         *   since the np->cur_tx was not yet increased.
         */
@@ -1070,7 +1039,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
        np->cur_tx++;
 
        wmb(); /* flush length, buffer1, buffer2 */
-       np->tx_ring[entry].status = DescOwn;
+       np->tx_ring[entry].status = DescOwned;
        wmb(); /* flush status and kick the hardware */
        iowrite32(0, np->base_addr + TxStartDemand);
        np->tx_q_bytes += skb->len;
@@ -1084,13 +1053,11 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
        }
        spin_unlock_irq(&np->lock);
 
-       dev->trans_start = jiffies;
-
        if (debug > 4) {
-               printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n",
-                          dev->name, np->cur_tx, entry);
+               printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d\n",
+                      dev->name, np->cur_tx, entry);
        }
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void netdev_tx_done(struct net_device *dev)
@@ -1105,8 +1072,8 @@ static void netdev_tx_done(struct net_device *dev)
                if (tx_status & 0x8000) {       /* There was an error, log it. */
 #ifndef final_version
                        if (debug > 1)
-                               printk(KERN_DEBUG "%s: Transmit error, Tx status %8.8x.\n",
-                                          dev->name, tx_status);
+                               printk(KERN_DEBUG "%s: Transmit error, Tx status %08x\n",
+                                      dev->name, tx_status);
 #endif
                        np->stats.tx_errors++;
                        if (tx_status & 0x0104) np->stats.tx_aborted_errors++;
@@ -1118,8 +1085,8 @@ static void netdev_tx_done(struct net_device *dev)
                } else {
 #ifndef final_version
                        if (debug > 3)
-                               printk(KERN_DEBUG "%s: Transmit slot %d ok, Tx status %8.8x.\n",
-                                          dev->name, entry, tx_status);
+                               printk(KERN_DEBUG "%s: Transmit slot %d ok, Tx status %08x\n",
+                                      dev->name, entry, tx_status);
 #endif
                        np->stats.tx_bytes += np->tx_skbuff[entry]->len;
                        np->stats.collisions += (tx_status >> 3) & 15;
@@ -1145,7 +1112,7 @@ static void netdev_tx_done(struct net_device *dev)
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
+static irqreturn_t intr_handler(int irq, void *dev_instance)
 {
        struct net_device *dev = (struct net_device *)dev_instance;
        struct netdev_private *np = netdev_priv(dev);
@@ -1162,20 +1129,20 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
                iowrite32(intr_status & 0x001ffff, ioaddr + IntrStatus);
 
                if (debug > 4)
-                       printk(KERN_DEBUG "%s: Interrupt, status %4.4x.\n",
-                                  dev->name, intr_status);
+                       printk(KERN_DEBUG "%s: Interrupt, status %04x\n",
+                              dev->name, intr_status);
 
                if ((intr_status & (NormalIntr|AbnormalIntr)) == 0)
                        break;
 
                handled = 1;
 
-               if (intr_status & (IntrRxDone | RxNoBuf))
+               if (intr_status & (RxIntr | RxNoBuf))
                        netdev_rx(dev);
                if (intr_status & RxNoBuf)
                        iowrite32(0, ioaddr + RxStartDemand);
 
-               if (intr_status & (TxIdle | IntrTxDone) &&
+               if (intr_status & (TxNoBuf | TxIntr) &&
                        np->cur_tx != np->dirty_tx) {
                        spin_lock(&np->lock);
                        netdev_tx_done(dev);
@@ -1183,13 +1150,14 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
                }
 
                /* Abnormal error summary/uncommon events handlers. */
-               if (intr_status & (AbnormalIntr | TxFIFOUnderflow | IntrPCIErr |
-                                                  TimerInt | IntrTxStopped))
+               if (intr_status & (AbnormalIntr | TxFIFOUnderflow | SystemError |
+                                                  TimerInt | TxDied))
                        netdev_error(dev, intr_status);
 
                if (--work_limit < 0) {
-                       printk(KERN_WARNING "%s: Too much work at interrupt, "
-                                  "status=0x%4.4x.\n", dev->name, intr_status);
+                       dev_warn(&dev->dev,
+                                "Too much work at interrupt, status=0x%04x\n",
+                                intr_status);
                        /* Set the timer to re-enable the other interrupts after
                           10*82usec ticks. */
                        spin_lock(&np->lock);
@@ -1203,8 +1171,8 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
        } while (1);
 
        if (debug > 3)
-               printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
-                          dev->name, ioread32(ioaddr + IntrStatus));
+               printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x\n",
+                      dev->name, ioread32(ioaddr + IntrStatus));
        return IRQ_RETVAL(handled);
 }
 
@@ -1217,8 +1185,8 @@ static int netdev_rx(struct net_device *dev)
        int work_limit = np->dirty_rx + RX_RING_SIZE - np->cur_rx;
 
        if (debug > 4) {
-               printk(KERN_DEBUG " In netdev_rx(), entry %d status %4.4x.\n",
-                          entry, np->rx_ring[entry].status);
+               printk(KERN_DEBUG " In netdev_rx(), entry %d status %04x\n",
+                      entry, np->rx_ring[entry].status);
        }
 
        /* If EOP is set on the next entry, it's a new packet. Send it up. */
@@ -1227,24 +1195,24 @@ static int netdev_rx(struct net_device *dev)
                s32 status = desc->status;
 
                if (debug > 4)
-                       printk(KERN_DEBUG "  netdev_rx() status was %8.8x.\n",
-                                  status);
+                       printk(KERN_DEBUG "  netdev_rx() status was %08x\n",
+                              status);
                if (status < 0)
                        break;
                if ((status & 0x38008300) != 0x0300) {
                        if ((status & 0x38000300) != 0x0300) {
                                /* Ingore earlier buffers. */
                                if ((status & 0xffff) != 0x7fff) {
-                                       printk(KERN_WARNING "%s: Oversized Ethernet frame spanned "
-                                                  "multiple buffers, entry %#x status %4.4x!\n",
-                                                  dev->name, np->cur_rx, status);
+                                       dev_warn(&dev->dev,
+                                                "Oversized Ethernet frame spanned multiple buffers, entry %#x status %04x!\n",
+                                                np->cur_rx, status);
                                        np->stats.rx_length_errors++;
                                }
                        } else if (status & 0x8000) {
                                /* There was a fatal error. */
                                if (debug > 2)
-                                       printk(KERN_DEBUG "%s: Receive error, Rx status %8.8x.\n",
-                                                  dev->name, status);
+                                       printk(KERN_DEBUG "%s: Receive error, Rx status %08x\n",
+                                              dev->name, status);
                                np->stats.rx_errors++; /* end of a packet.*/
                                if (status & 0x0890) np->stats.rx_length_errors++;
                                if (status & 0x004C) np->stats.rx_frame_errors++;
@@ -1257,19 +1225,18 @@ static int netdev_rx(struct net_device *dev)
 
 #ifndef final_version
                        if (debug > 4)
-                               printk(KERN_DEBUG "  netdev_rx() normal Rx pkt length %d"
-                                          " status %x.\n", pkt_len, status);
+                               printk(KERN_DEBUG "  netdev_rx() normal Rx pkt length %d status %x\n",
+                                      pkt_len, status);
 #endif
                        /* Check if the packet is long enough to accept without copying
                           to a minimally-sized skbuff. */
-                       if (pkt_len < rx_copybreak
-                               && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
-                               skb->dev = dev;
+                       if (pkt_len < rx_copybreak &&
+                           (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
                                skb_reserve(skb, 2);    /* 16 byte align the IP header */
                                pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry],
                                                            np->rx_skbuff[entry]->len,
                                                            PCI_DMA_FROMDEVICE);
-                               eth_copy_and_sum(skb, np->rx_skbuff[entry]->data, pkt_len, 0);
+                               skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len);
                                skb_put(skb, pkt_len);
                                pci_dma_sync_single_for_device(np->pci_dev,np->rx_addr[entry],
                                                               np->rx_skbuff[entry]->len,
@@ -1284,19 +1251,13 @@ static int netdev_rx(struct net_device *dev)
 #ifndef final_version                          /* Remove after testing. */
                        /* You will want this info for the initial debug. */
                        if (debug > 5)
-                               printk(KERN_DEBUG "  Rx data %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:"
-                                          "%2.2x %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x %2.2x%2.2x "
-                                          "%d.%d.%d.%d.\n",
-                                          skb->data[0], skb->data[1], skb->data[2], skb->data[3],
-                                          skb->data[4], skb->data[5], skb->data[6], skb->data[7],
-                                          skb->data[8], skb->data[9], skb->data[10],
-                                          skb->data[11], skb->data[12], skb->data[13],
-                                          skb->data[14], skb->data[15], skb->data[16],
-                                          skb->data[17]);
+                               printk(KERN_DEBUG "  Rx data %pM %pM %02x%02x %pI4\n",
+                                      &skb->data[0], &skb->data[6],
+                                      skb->data[12], skb->data[13],
+                                      &skb->data[14]);
 #endif
                        skb->protocol = eth_type_trans(skb, dev);
                        netif_rx(skb);
-                       dev->last_rx = jiffies;
                        np->stats.rx_packets++;
                        np->stats.rx_bytes += pkt_len;
                }
@@ -1313,14 +1274,13 @@ static int netdev_rx(struct net_device *dev)
                        np->rx_skbuff[entry] = skb;
                        if (skb == NULL)
                                break;                  /* Better luck next round. */
-                       skb->dev = dev;                 /* Mark as being used by this device. */
                        np->rx_addr[entry] = pci_map_single(np->pci_dev,
                                                        skb->data,
                                                        np->rx_buf_sz, PCI_DMA_FROMDEVICE);
                        np->rx_ring[entry].buffer1 = np->rx_addr[entry];
                }
                wmb();
-               np->rx_ring[entry].status = DescOwn;
+               np->rx_ring[entry].status = DescOwned;
        }
 
        return 0;
@@ -1332,8 +1292,8 @@ static void netdev_error(struct net_device *dev, int intr_status)
        void __iomem *ioaddr = np->base_addr;
 
        if (debug > 2)
-               printk(KERN_DEBUG "%s: Abnormal event, %8.8x.\n",
-                          dev->name, intr_status);
+               printk(KERN_DEBUG "%s: Abnormal event, %08x\n",
+                      dev->name, intr_status);
        if (intr_status == 0xffffffff)
                return;
        spin_lock(&np->lock);
@@ -1353,11 +1313,11 @@ static void netdev_error(struct net_device *dev, int intr_status)
                        new = 127; /* load full packet before starting */
                new = (np->csr6 & ~(0x7F << 14)) | (new<<14);
 #endif
-               printk(KERN_DEBUG "%s: Tx underflow, new csr6 %8.8x.\n",
-                          dev->name, new);
+               printk(KERN_DEBUG "%s: Tx underflow, new csr6 %08x\n",
+                      dev->name, new);
                update_csr6(dev, new);
        }
-       if (intr_status & IntrRxDied) {         /* Missed a Rx frame. */
+       if (intr_status & RxDied) {             /* Missed a Rx frame. */
                np->stats.rx_errors++;
        }
        if (intr_status & TimerInt) {
@@ -1393,27 +1353,26 @@ static u32 __set_rx_mode(struct net_device *dev)
        u32 rx_mode;
 
        if (dev->flags & IFF_PROMISC) {                 /* Set promiscuous. */
-               /* Unconditionally log net taps. */
-               printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
                memset(mc_filter, 0xff, sizeof(mc_filter));
-               rx_mode = AcceptBroadcast | AcceptMulticast | AcceptAllPhys
+               rx_mode = RxAcceptBroadcast | AcceptMulticast | RxAcceptAllPhys
                        | AcceptMyPhys;
-       } else if ((dev->mc_count > multicast_filter_limit)
-                          ||  (dev->flags & IFF_ALLMULTI)) {
+       } else if ((netdev_mc_count(dev) > multicast_filter_limit) ||
+                  (dev->flags & IFF_ALLMULTI)) {
                /* Too many to match, or accept all multicasts. */
                memset(mc_filter, 0xff, sizeof(mc_filter));
-               rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
+               rx_mode = RxAcceptBroadcast | AcceptMulticast | AcceptMyPhys;
        } else {
-               struct dev_mc_list *mclist;
-               int i;
+               struct netdev_hw_addr *ha;
+
                memset(mc_filter, 0, sizeof(mc_filter));
-               for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
-                        i++, mclist = mclist->next) {
-                       int filterbit = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F;
-                       filterbit &= 0x3f;
-                       mc_filter[filterbit >> 5] |= 1 << (filterbit & 31);
+               netdev_for_each_mc_addr(ha, dev) {
+                       int filbit;
+
+                       filbit = (ether_crc(ETH_ALEN, ha->addr) >> 26) ^ 0x3F;
+                       filbit &= 0x3f;
+                       mc_filter[filbit >> 5] |= 1 << (filbit & 31);
                }
-               rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
+               rx_mode = RxAcceptBroadcast | AcceptMulticast | AcceptMyPhys;
        }
        iowrite32(mc_filter[0], ioaddr + MulticastFilter0);
        iowrite32(mc_filter[1], ioaddr + MulticastFilter1);
@@ -1484,7 +1443,7 @@ static void netdev_set_msglevel(struct net_device *dev, u32 value)
        debug = value;
 }
 
-static struct ethtool_ops netdev_ethtool_ops = {
+static const struct ethtool_ops netdev_ethtool_ops = {
        .get_drvinfo            = netdev_get_drvinfo,
        .get_settings           = netdev_get_settings,
        .set_settings           = netdev_set_settings,
@@ -1492,8 +1451,6 @@ static struct ethtool_ops netdev_ethtool_ops = {
        .get_link               = netdev_get_link,
        .get_msglevel           = netdev_get_msglevel,
        .set_msglevel           = netdev_set_msglevel,
-       .get_sg                 = ethtool_op_get_sg,
-       .get_tx_csum            = ethtool_op_get_tx_csum,
 };
 
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
@@ -1513,8 +1470,6 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                return 0;
 
        case SIOCSMIIREG:               /* Write MII PHY register. */
-               if (!capable(CAP_NET_ADMIN))
-                       return -EPERM;
                spin_lock_irq(&np->lock);
                mdio_write(dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
                spin_unlock_irq(&np->lock);
@@ -1532,11 +1487,13 @@ static int netdev_close(struct net_device *dev)
        netif_stop_queue(dev);
 
        if (debug > 1) {
-               printk(KERN_DEBUG "%s: Shutting down ethercard, status was %8.8x "
-                          "Config %8.8x.\n", dev->name, ioread32(ioaddr + IntrStatus),
-                          ioread32(ioaddr + NetworkConfig));
-               printk(KERN_DEBUG "%s: Queue pointers were Tx %d / %d,  Rx %d / %d.\n",
-                          dev->name, np->cur_tx, np->dirty_tx, np->cur_rx, np->dirty_rx);
+               printk(KERN_DEBUG "%s: Shutting down ethercard, status was %08x Config %08x\n",
+                      dev->name, ioread32(ioaddr + IntrStatus),
+                      ioread32(ioaddr + NetworkConfig));
+               printk(KERN_DEBUG "%s: Queue pointers were Tx %d / %d,  Rx %d / %d\n",
+                      dev->name,
+                      np->cur_tx, np->dirty_tx,
+                      np->cur_rx, np->dirty_rx);
        }
 
        /* Stop the chip's Tx and Rx processes. */
@@ -1557,18 +1514,16 @@ static int netdev_close(struct net_device *dev)
        if (debug > 2) {
                int i;
 
-               printk(KERN_DEBUG"  Tx ring at %8.8x:\n",
-                          (int)np->tx_ring);
+               printk(KERN_DEBUG"  Tx ring at %08x:\n", (int)np->tx_ring);
                for (i = 0; i < TX_RING_SIZE; i++)
-                       printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x.\n",
-                                  i, np->tx_ring[i].length,
-                                  np->tx_ring[i].status, np->tx_ring[i].buffer1);
-               printk("\n"KERN_DEBUG "  Rx ring %8.8x:\n",
-                          (int)np->rx_ring);
+                       printk(KERN_DEBUG " #%d desc. %04x %04x %08x\n",
+                              i, np->tx_ring[i].length,
+                              np->tx_ring[i].status, np->tx_ring[i].buffer1);
+               printk(KERN_DEBUG "  Rx ring %08x:\n", (int)np->rx_ring);
                for (i = 0; i < RX_RING_SIZE; i++) {
-                       printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x\n",
-                                  i, np->rx_ring[i].length,
-                                  np->rx_ring[i].status, np->rx_ring[i].buffer1);
+                       printk(KERN_DEBUG " #%d desc. %04x %04x %08x\n",
+                              i, np->rx_ring[i].length,
+                              np->rx_ring[i].status, np->rx_ring[i].buffer1);
                }
        }
 #endif /* __i386__ debugging only */
@@ -1584,7 +1539,7 @@ static int netdev_close(struct net_device *dev)
 static void __devexit w840_remove1 (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
-       
+
        if (dev) {
                struct netdev_private *np = netdev_priv(dev);
                unregister_netdev(dev);
@@ -1604,12 +1559,12 @@ static void __devexit w840_remove1 (struct pci_dev *pdev)
  *     rtnl_lock, & netif_device_detach after the rtnl_unlock.
  * - get_stats:
  *     spin_lock_irq(np->lock), doesn't touch hw if not present
- * - hard_start_xmit:
- *     netif_stop_queue + spin_unlock_wait(&dev->xmit_lock);
+ * - start_xmit:
+ *     synchronize_irq + netif_tx_disable;
  * - tx_timeout:
- *     netif_device_detach + spin_unlock_wait(&dev->xmit_lock);
+ *     netif_device_detach + netif_tx_disable;
  * - set_multicast_list
- *     netif_device_detach + spin_unlock_wait(&dev->xmit_lock);
+ *     netif_device_detach + netif_tx_disable;
  * - interrupt handler
  *     doesn't touch hw if not present, synchronize_irq waits for
  *     running instances of the interrupt handler.
@@ -1635,18 +1590,16 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
                netif_device_detach(dev);
                update_csr6(dev, 0);
                iowrite32(0, ioaddr + IntrEnable);
-               netif_stop_queue(dev);
                spin_unlock_irq(&np->lock);
 
-               spin_unlock_wait(&dev->xmit_lock);
                synchronize_irq(dev->irq);
-       
+               netif_tx_disable(dev);
+
                np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
 
                /* no more hardware accesses behind this line. */
 
-               BUG_ON(np->csr6);
-               if (ioread32(ioaddr + IntrEnable)) BUG();
+               BUG_ON(np->csr6 || ioread32(ioaddr + IntrEnable));
 
                /* pci_power_off(pdev, -1); */
 
@@ -1662,14 +1615,17 @@ static int w840_resume (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
        struct netdev_private *np = netdev_priv(dev);
+       int retval = 0;
 
        rtnl_lock();
        if (netif_device_present(dev))
                goto out; /* device not suspended */
        if (netif_running(dev)) {
-               pci_enable_device(pdev);
-       /*      pci_power_on(pdev); */
-
+               if ((retval = pci_enable_device(pdev))) {
+                       dev_err(&dev->dev,
+                               "pci_enable_device failed in resume\n");
+                       goto out;
+               }
                spin_lock_irq(&np->lock);
                iowrite32(1, np->base_addr+PCIBusCfg);
                ioread32(np->base_addr+PCIBusCfg);
@@ -1687,7 +1643,7 @@ static int w840_resume (struct pci_dev *pdev)
        }
 out:
        rtnl_unlock();
-       return 0;
+       return retval;
 }
 #endif
 
@@ -1705,7 +1661,7 @@ static struct pci_driver w840_driver = {
 static int __init w840_init(void)
 {
        printk(version);
-       return pci_module_init(&w840_driver);
+       return pci_register_driver(&w840_driver);
 }
 
 static void __exit w840_exit(void)