net:wireless:bcmdhd: rename bcmsdh_remove & bcmsdh_probe
[linux-2.6.git] / drivers / net / qla3xxx.c
old mode 100755 (executable)
new mode 100644 (file)
index 69da95b..2f69140
@@ -5,6 +5,8 @@
  * See LICENSE.qla3xxx for copyright and licensing details.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/skbuff.h>
 #include <linux/rtnetlink.h>
 #include <linux/if_vlan.h>
-#include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/mm.h>
+#include <linux/prefetch.h>
 
 #include "qla3xxx.h"
 
-#define DRV_NAME       "qla3xxx"
-#define DRV_STRING     "QLogic ISP3XXX Network Driver"
-#define DRV_VERSION    "v2.03.00-k4"
-#define PFX            DRV_NAME " "
+#define DRV_NAME       "qla3xxx"
+#define DRV_STRING     "QLogic ISP3XXX Network Driver"
+#define DRV_VERSION    "v2.03.00-k5"
 
 static const char ql3xxx_driver_name[] = DRV_NAME;
 static const char ql3xxx_driver_version[] = DRV_VERSION;
 
+#define TIMED_OUT_MSG                                                  \
+"Timed out waiting for management port to get free before issuing command\n"
+
 MODULE_AUTHOR("QLogic Corporation");
 MODULE_DESCRIPTION("QLogic ISP3XXX Network Driver " DRV_VERSION " ");
 MODULE_LICENSE("GPL");
@@ -62,7 +66,7 @@ static int msi;
 module_param(msi, int, 0);
 MODULE_PARM_DESC(msi, "Turn on Message Signaled Interrupts.");
 
-static struct pci_device_id ql3xxx_pci_tbl[] __devinitdata = {
+static DEFINE_PCI_DEVICE_TABLE(ql3xxx_pci_tbl) = {
        {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QL3022_DEVICE_ID)},
        {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QL3032_DEVICE_ID)},
        /* required last entry */
@@ -74,24 +78,24 @@ MODULE_DEVICE_TABLE(pci, ql3xxx_pci_tbl);
 /*
  *  These are the known PHY's which are used
  */
-typedef enum {
+enum PHY_DEVICE_TYPE {
    PHY_TYPE_UNKNOWN   = 0,
    PHY_VITESSE_VSC8211,
    PHY_AGERE_ET1011C,
    MAX_PHY_DEV_TYPES
-} PHY_DEVICE_et;
-
-typedef struct {
-       PHY_DEVICE_et phyDevice; 
-       u32             phyIdOUI;
-       u16             phyIdModel;
-       char            *name;
-} PHY_DEVICE_INFO_t;
-
-static const PHY_DEVICE_INFO_t PHY_DEVICES[] =
-       {{PHY_TYPE_UNKNOWN,    0x000000, 0x0, "PHY_TYPE_UNKNOWN"},
-        {PHY_VITESSE_VSC8211, 0x0003f1, 0xb, "PHY_VITESSE_VSC8211"},
-        {PHY_AGERE_ET1011C,   0x00a0bc, 0x1, "PHY_AGERE_ET1011C"},
+};
+
+struct PHY_DEVICE_INFO {
+       const enum PHY_DEVICE_TYPE      phyDevice;
+       const u32               phyIdOUI;
+       const u16               phyIdModel;
+       const char              *name;
+};
+
+static const struct PHY_DEVICE_INFO PHY_DEVICES[] = {
+       {PHY_TYPE_UNKNOWN,    0x000000, 0x0, "PHY_TYPE_UNKNOWN"},
+       {PHY_VITESSE_VSC8211, 0x0003f1, 0xb, "PHY_VITESSE_VSC8211"},
+       {PHY_AGERE_ET1011C,   0x00a0bc, 0x1, "PHY_AGERE_ET1011C"},
 };
 
 
@@ -101,7 +105,8 @@ static const PHY_DEVICE_INFO_t PHY_DEVICES[] =
 static int ql_sem_spinlock(struct ql3_adapter *qdev,
                            u32 sem_mask, u32 sem_bits)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
        u32 value;
        unsigned int seconds = 3;
 
@@ -112,20 +117,22 @@ static int ql_sem_spinlock(struct ql3_adapter *qdev,
                if ((value & (sem_mask >> 16)) == sem_bits)
                        return 0;
                ssleep(1);
-       } while(--seconds);
+       } while (--seconds);
        return -1;
 }
 
 static void ql_sem_unlock(struct ql3_adapter *qdev, u32 sem_mask)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
        writel(sem_mask, &port_regs->CommonRegs.semaphoreReg);
        readl(&port_regs->CommonRegs.semaphoreReg);
 }
 
 static int ql_sem_lock(struct ql3_adapter *qdev, u32 sem_mask, u32 sem_bits)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
        u32 value;
 
        writel((sem_mask | sem_bits), &port_regs->CommonRegs.semaphoreReg);
@@ -140,32 +147,28 @@ static int ql_wait_for_drvr_lock(struct ql3_adapter *qdev)
 {
        int i = 0;
 
-       while (1) {
-               if (!ql_sem_lock(qdev,
-                                QL_DRVR_SEM_MASK,
-                                (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index)
-                                 * 2) << 1)) {
-                       if (i < 10) {
-                               ssleep(1);
-                               i++;
-                       } else {
-                               printk(KERN_ERR PFX "%s: Timed out waiting for "
-                                      "driver lock...\n",
-                                      qdev->ndev->name);
-                               return 0;
-                       }
-               } else {
-                       printk(KERN_DEBUG PFX
-                              "%s: driver lock acquired.\n",
-                              qdev->ndev->name);
+       while (i < 10) {
+               if (i)
+                       ssleep(1);
+
+               if (ql_sem_lock(qdev,
+                               QL_DRVR_SEM_MASK,
+                               (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index)
+                                * 2) << 1)) {
+                       netdev_printk(KERN_DEBUG, qdev->ndev,
+                                     "driver lock acquired\n");
                        return 1;
                }
        }
+
+       netdev_err(qdev->ndev, "Timed out waiting for driver lock...\n");
+       return 0;
 }
 
 static void ql_set_register_page(struct ql3_adapter *qdev, u32 page)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
 
        writel(((ISP_CONTROL_NP_MASK << 16) | page),
                        &port_regs->CommonRegs.ispControlStatus);
@@ -173,8 +176,7 @@ static void ql_set_register_page(struct ql3_adapter *qdev, u32 page)
        qdev->current_page = page;
 }
 
-static u32 ql_read_common_reg_l(struct ql3_adapter *qdev,
-                             u32 __iomem * reg)
+static u32 ql_read_common_reg_l(struct ql3_adapter *qdev, u32 __iomem *reg)
 {
        u32 value;
        unsigned long hw_flags;
@@ -186,8 +188,7 @@ static u32 ql_read_common_reg_l(struct ql3_adapter *qdev,
        return value;
 }
 
-static u32 ql_read_common_reg(struct ql3_adapter *qdev,
-                             u32 __iomem * reg)
+static u32 ql_read_common_reg(struct ql3_adapter *qdev, u32 __iomem *reg)
 {
        return readl(reg);
 }
@@ -200,7 +201,7 @@ static u32 ql_read_page0_reg_l(struct ql3_adapter *qdev, u32 __iomem *reg)
        spin_lock_irqsave(&qdev->hw_lock, hw_flags);
 
        if (qdev->current_page != 0)
-               ql_set_register_page(qdev,0);
+               ql_set_register_page(qdev, 0);
        value = readl(reg);
 
        spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
@@ -210,7 +211,7 @@ static u32 ql_read_page0_reg_l(struct ql3_adapter *qdev, u32 __iomem *reg)
 static u32 ql_read_page0_reg(struct ql3_adapter *qdev, u32 __iomem *reg)
 {
        if (qdev->current_page != 0)
-               ql_set_register_page(qdev,0);
+               ql_set_register_page(qdev, 0);
        return readl(reg);
 }
 
@@ -223,7 +224,6 @@ static void ql_write_common_reg_l(struct ql3_adapter *qdev,
        writel(value, reg);
        readl(reg);
        spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
-       return;
 }
 
 static void ql_write_common_reg(struct ql3_adapter *qdev,
@@ -231,7 +231,6 @@ static void ql_write_common_reg(struct ql3_adapter *qdev,
 {
        writel(value, reg);
        readl(reg);
-       return;
 }
 
 static void ql_write_nvram_reg(struct ql3_adapter *qdev,
@@ -240,17 +239,15 @@ static void ql_write_nvram_reg(struct ql3_adapter *qdev,
        writel(value, reg);
        readl(reg);
        udelay(1);
-       return;
 }
 
 static void ql_write_page0_reg(struct ql3_adapter *qdev,
                               u32 __iomem *reg, u32 value)
 {
        if (qdev->current_page != 0)
-               ql_set_register_page(qdev,0);
+               ql_set_register_page(qdev, 0);
        writel(value, reg);
        readl(reg);
-       return;
 }
 
 /*
@@ -260,10 +257,9 @@ static void ql_write_page1_reg(struct ql3_adapter *qdev,
                               u32 __iomem *reg, u32 value)
 {
        if (qdev->current_page != 1)
-               ql_set_register_page(qdev,1);
+               ql_set_register_page(qdev, 1);
        writel(value, reg);
        readl(reg);
-       return;
 }
 
 /*
@@ -273,15 +269,15 @@ static void ql_write_page2_reg(struct ql3_adapter *qdev,
                               u32 __iomem *reg, u32 value)
 {
        if (qdev->current_page != 2)
-               ql_set_register_page(qdev,2);
+               ql_set_register_page(qdev, 2);
        writel(value, reg);
        readl(reg);
-       return;
 }
 
 static void ql_disable_interrupts(struct ql3_adapter *qdev)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
 
        ql_write_common_reg_l(qdev, &port_regs->CommonRegs.ispInterruptMaskReg,
                            (ISP_IMR_ENABLE_INT << 16));
@@ -290,7 +286,8 @@ static void ql_disable_interrupts(struct ql3_adapter *qdev)
 
 static void ql_enable_interrupts(struct ql3_adapter *qdev)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
 
        ql_write_common_reg_l(qdev, &port_regs->CommonRegs.ispInterruptMaskReg,
                            ((0xff << 16) | ISP_IMR_ENABLE_INT));
@@ -315,8 +312,7 @@ static void ql_release_to_lrg_buf_free_list(struct ql3_adapter *qdev,
                lrg_buf_cb->skb = netdev_alloc_skb(qdev->ndev,
                                                   qdev->lrg_buffer_len);
                if (unlikely(!lrg_buf_cb->skb)) {
-                       printk(KERN_ERR PFX "%s: failed netdev_alloc_skb().\n",
-                              qdev->ndev->name);
+                       netdev_err(qdev->ndev, "failed netdev_alloc_skb()\n");
                        qdev->lrg_buf_skb_check++;
                } else {
                        /*
@@ -329,10 +325,11 @@ static void ql_release_to_lrg_buf_free_list(struct ql3_adapter *qdev,
                                             qdev->lrg_buffer_len -
                                             QL_HEADER_SPACE,
                                             PCI_DMA_FROMDEVICE);
-                       err = pci_dma_mapping_error(map);
-                       if(err) {
-                               printk(KERN_ERR "%s: PCI mapping failed with error: %d\n", 
-                                      qdev->ndev->name, err);
+                       err = pci_dma_mapping_error(qdev->pdev, map);
+                       if (err) {
+                               netdev_err(qdev->ndev,
+                                          "PCI mapping failed with error: %d\n",
+                                          err);
                                dev_kfree_skb(lrg_buf_cb->skb);
                                lrg_buf_cb->skb = NULL;
 
@@ -344,8 +341,8 @@ static void ql_release_to_lrg_buf_free_list(struct ql3_adapter *qdev,
                            cpu_to_le32(LS_64BITS(map));
                        lrg_buf_cb->buf_phy_addr_high =
                            cpu_to_le32(MS_64BITS(map));
-                       pci_unmap_addr_set(lrg_buf_cb, mapaddr, map);
-                       pci_unmap_len_set(lrg_buf_cb, maplen,
+                       dma_unmap_addr_set(lrg_buf_cb, mapaddr, map);
+                       dma_unmap_len_set(lrg_buf_cb, maplen,
                                          qdev->lrg_buffer_len -
                                          QL_HEADER_SPACE);
                }
@@ -357,10 +354,11 @@ static void ql_release_to_lrg_buf_free_list(struct ql3_adapter *qdev,
 static struct ql_rcv_buf_cb *ql_get_from_lrg_buf_free_list(struct ql3_adapter
                                                           *qdev)
 {
-       struct ql_rcv_buf_cb *lrg_buf_cb;
+       struct ql_rcv_buf_cb *lrg_buf_cb = qdev->lrg_buf_free_head;
 
-       if ((lrg_buf_cb = qdev->lrg_buf_free_head) != NULL) {
-               if ((qdev->lrg_buf_free_head = lrg_buf_cb->next) == NULL)
+       if (lrg_buf_cb != NULL) {
+               qdev->lrg_buf_free_head = lrg_buf_cb->next;
+               if (qdev->lrg_buf_free_head == NULL)
                        qdev->lrg_buf_free_tail = NULL;
                qdev->lrg_buf_free_count--;
        }
@@ -381,13 +379,13 @@ static void eeprom_readword(struct ql3_adapter *qdev, u32 eepromAddr,
 static void fm93c56a_select(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
+       __iomem u32 *spir = &port_regs->CommonRegs.serialPortInterfaceReg;
 
        qdev->eeprom_cmd_data = AUBURN_EEPROM_CS_1;
-       ql_write_nvram_reg(qdev, &port_regs->CommonRegs.serialPortInterfaceReg,
-                           ISP_NVRAM_MASK | qdev->eeprom_cmd_data);
-       ql_write_nvram_reg(qdev, &port_regs->CommonRegs.serialPortInterfaceReg,
-                           ((ISP_NVRAM_MASK << 16) | qdev->eeprom_cmd_data));
+       ql_write_nvram_reg(qdev, spir, ISP_NVRAM_MASK | qdev->eeprom_cmd_data);
+       ql_write_nvram_reg(qdev, spir,
+                          ((ISP_NVRAM_MASK << 16) | qdev->eeprom_cmd_data));
 }
 
 /*
@@ -400,51 +398,40 @@ static void fm93c56a_cmd(struct ql3_adapter *qdev, u32 cmd, u32 eepromAddr)
        u32 dataBit;
        u32 previousBit;
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
+       __iomem u32 *spir = &port_regs->CommonRegs.serialPortInterfaceReg;
 
        /* Clock in a zero, then do the start bit */
-       ql_write_nvram_reg(qdev, &port_regs->CommonRegs.serialPortInterfaceReg,
-                           ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
-                           AUBURN_EEPROM_DO_1);
-       ql_write_nvram_reg(qdev, &port_regs->CommonRegs.serialPortInterfaceReg,
-                           ISP_NVRAM_MASK | qdev->
-                           eeprom_cmd_data | AUBURN_EEPROM_DO_1 |
-                           AUBURN_EEPROM_CLK_RISE);
-       ql_write_nvram_reg(qdev, &port_regs->CommonRegs.serialPortInterfaceReg,
-                           ISP_NVRAM_MASK | qdev->
-                           eeprom_cmd_data | AUBURN_EEPROM_DO_1 |
-                           AUBURN_EEPROM_CLK_FALL);
+       ql_write_nvram_reg(qdev, spir,
+                          (ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                           AUBURN_EEPROM_DO_1));
+       ql_write_nvram_reg(qdev, spir,
+                          (ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                           AUBURN_EEPROM_DO_1 | AUBURN_EEPROM_CLK_RISE));
+       ql_write_nvram_reg(qdev, spir,
+                          (ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                           AUBURN_EEPROM_DO_1 | AUBURN_EEPROM_CLK_FALL));
 
        mask = 1 << (FM93C56A_CMD_BITS - 1);
        /* Force the previous data bit to be different */
        previousBit = 0xffff;
        for (i = 0; i < FM93C56A_CMD_BITS; i++) {
-               dataBit =
-                   (cmd & mask) ? AUBURN_EEPROM_DO_1 : AUBURN_EEPROM_DO_0;
+               dataBit = (cmd & mask)
+                       ? AUBURN_EEPROM_DO_1
+                       : AUBURN_EEPROM_DO_0;
                if (previousBit != dataBit) {
-                       /*
-                        * If the bit changed, then change the DO state to
-                        * match
-                        */
-                       ql_write_nvram_reg(qdev,
-                                           &port_regs->CommonRegs.
-                                           serialPortInterfaceReg,
-                                           ISP_NVRAM_MASK | qdev->
-                                           eeprom_cmd_data | dataBit);
+                       /* If the bit changed, change the DO state to match */
+                       ql_write_nvram_reg(qdev, spir,
+                                          (ISP_NVRAM_MASK |
+                                           qdev->eeprom_cmd_data | dataBit));
                        previousBit = dataBit;
                }
-               ql_write_nvram_reg(qdev,
-                                   &port_regs->CommonRegs.
-                                   serialPortInterfaceReg,
-                                   ISP_NVRAM_MASK | qdev->
-                                   eeprom_cmd_data | dataBit |
-                                   AUBURN_EEPROM_CLK_RISE);
-               ql_write_nvram_reg(qdev,
-                                   &port_regs->CommonRegs.
-                                   serialPortInterfaceReg,
-                                   ISP_NVRAM_MASK | qdev->
-                                   eeprom_cmd_data | dataBit |
-                                   AUBURN_EEPROM_CLK_FALL);
+               ql_write_nvram_reg(qdev, spir,
+                                  (ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                                   dataBit | AUBURN_EEPROM_CLK_RISE));
+               ql_write_nvram_reg(qdev, spir,
+                                  (ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                                   dataBit | AUBURN_EEPROM_CLK_FALL));
                cmd = cmd << 1;
        }
 
@@ -452,33 +439,24 @@ static void fm93c56a_cmd(struct ql3_adapter *qdev, u32 cmd, u32 eepromAddr)
        /* Force the previous data bit to be different */
        previousBit = 0xffff;
        for (i = 0; i < addrBits; i++) {
-               dataBit =
-                   (eepromAddr & mask) ? AUBURN_EEPROM_DO_1 :
-                   AUBURN_EEPROM_DO_0;
+               dataBit = (eepromAddr & mask) ? AUBURN_EEPROM_DO_1
+                       : AUBURN_EEPROM_DO_0;
                if (previousBit != dataBit) {
                        /*
                         * If the bit changed, then change the DO state to
                         * match
                         */
-                       ql_write_nvram_reg(qdev,
-                                           &port_regs->CommonRegs.
-                                           serialPortInterfaceReg,
-                                           ISP_NVRAM_MASK | qdev->
-                                           eeprom_cmd_data | dataBit);
+                       ql_write_nvram_reg(qdev, spir,
+                                          (ISP_NVRAM_MASK |
+                                           qdev->eeprom_cmd_data | dataBit));
                        previousBit = dataBit;
                }
-               ql_write_nvram_reg(qdev,
-                                   &port_regs->CommonRegs.
-                                   serialPortInterfaceReg,
-                                   ISP_NVRAM_MASK | qdev->
-                                   eeprom_cmd_data | dataBit |
-                                   AUBURN_EEPROM_CLK_RISE);
-               ql_write_nvram_reg(qdev,
-                                   &port_regs->CommonRegs.
-                                   serialPortInterfaceReg,
-                                   ISP_NVRAM_MASK | qdev->
-                                   eeprom_cmd_data | dataBit |
-                                   AUBURN_EEPROM_CLK_FALL);
+               ql_write_nvram_reg(qdev, spir,
+                                  (ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                                   dataBit | AUBURN_EEPROM_CLK_RISE));
+               ql_write_nvram_reg(qdev, spir,
+                                  (ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                                   dataBit | AUBURN_EEPROM_CLK_FALL));
                eepromAddr = eepromAddr << 1;
        }
 }
@@ -489,10 +467,11 @@ static void fm93c56a_cmd(struct ql3_adapter *qdev, u32 cmd, u32 eepromAddr)
 static void fm93c56a_deselect(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
+       __iomem u32 *spir = &port_regs->CommonRegs.serialPortInterfaceReg;
+
        qdev->eeprom_cmd_data = AUBURN_EEPROM_CS_0;
-       ql_write_nvram_reg(qdev, &port_regs->CommonRegs.serialPortInterfaceReg,
-                           ISP_NVRAM_MASK | qdev->eeprom_cmd_data);
+       ql_write_nvram_reg(qdev, spir, ISP_NVRAM_MASK | qdev->eeprom_cmd_data);
 }
 
 /*
@@ -504,29 +483,23 @@ static void fm93c56a_datain(struct ql3_adapter *qdev, unsigned short *value)
        u32 data = 0;
        u32 dataBit;
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
+       __iomem u32 *spir = &port_regs->CommonRegs.serialPortInterfaceReg;
 
        /* Read the data bits */
        /* The first bit is a dummy.  Clock right over it. */
        for (i = 0; i < dataBits; i++) {
-               ql_write_nvram_reg(qdev,
-                                   &port_regs->CommonRegs.
-                                   serialPortInterfaceReg,
-                                   ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
-                                   AUBURN_EEPROM_CLK_RISE);
-               ql_write_nvram_reg(qdev,
-                                   &port_regs->CommonRegs.
-                                   serialPortInterfaceReg,
-                                   ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
-                                   AUBURN_EEPROM_CLK_FALL);
-               dataBit =
-                   (ql_read_common_reg
-                    (qdev,
-                     &port_regs->CommonRegs.
-                     serialPortInterfaceReg) & AUBURN_EEPROM_DI_1) ? 1 : 0;
+               ql_write_nvram_reg(qdev, spir,
+                                  ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                                  AUBURN_EEPROM_CLK_RISE);
+               ql_write_nvram_reg(qdev, spir,
+                                  ISP_NVRAM_MASK | qdev->eeprom_cmd_data |
+                                  AUBURN_EEPROM_CLK_FALL);
+               dataBit = (ql_read_common_reg(qdev, spir) &
+                          AUBURN_EEPROM_DI_1) ? 1 : 0;
                data = (data << 1) | dataBit;
        }
-       *value = (u16) data;
+       *value = (u16)data;
 }
 
 /*
@@ -541,20 +514,12 @@ static void eeprom_readword(struct ql3_adapter *qdev,
        fm93c56a_deselect(qdev);
 }
 
-static void ql_swap_mac_addr(u8 * macAddress)
+static void ql_set_mac_addr(struct net_device *ndev, u16 *addr)
 {
-#ifdef __BIG_ENDIAN
-       u8 temp;
-       temp = macAddress[0];
-       macAddress[0] = macAddress[1];
-       macAddress[1] = temp;
-       temp = macAddress[2];
-       macAddress[2] = macAddress[3];
-       macAddress[3] = temp;
-       temp = macAddress[4];
-       macAddress[4] = macAddress[5];
-       macAddress[5] = temp;
-#endif
+       __le16 *p = (__le16 *)ndev->dev_addr;
+       p[0] = cpu_to_le16(addr[0]);
+       p[1] = cpu_to_le16(addr[1]);
+       p[2] = cpu_to_le16(addr[2]);
 }
 
 static int ql_get_nvram_params(struct ql3_adapter *qdev)
@@ -566,13 +531,12 @@ static int ql_get_nvram_params(struct ql3_adapter *qdev)
 
        spin_lock_irqsave(&qdev->hw_lock, hw_flags);
 
-       pEEPROMData = (u16 *) & qdev->nvram_data;
+       pEEPROMData = (u16 *)&qdev->nvram_data;
        qdev->eeprom_cmd_data = 0;
-       if(ql_sem_spinlock(qdev, QL_NVRAM_SEM_MASK,
+       if (ql_sem_spinlock(qdev, QL_NVRAM_SEM_MASK,
                        (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
                         2) << 10)) {
-               printk(KERN_ERR PFX"%s: Failed ql_sem_spinlock().\n",
-                       __func__);
+               pr_err("%s: Failed ql_sem_spinlock()\n", __func__);
                spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
                return -1;
        }
@@ -585,24 +549,12 @@ static int ql_get_nvram_params(struct ql3_adapter *qdev)
        ql_sem_unlock(qdev, QL_NVRAM_SEM_MASK);
 
        if (checksum != 0) {
-               printk(KERN_ERR PFX "%s: checksum should be zero, is %x!!\n",
-                      qdev->ndev->name, checksum);
+               netdev_err(qdev->ndev, "checksum should be zero, is %x!!\n",
+                          checksum);
                spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
                return -1;
        }
 
-       /*
-        * We have a problem with endianness for the MAC addresses
-        * and the two 8-bit values version, and numPorts.  We
-        * have to swap them on big endian systems.
-        */
-       ql_swap_mac_addr(qdev->nvram_data.funcCfg_fn0.macAddress);
-       ql_swap_mac_addr(qdev->nvram_data.funcCfg_fn1.macAddress);
-       ql_swap_mac_addr(qdev->nvram_data.funcCfg_fn2.macAddress);
-       ql_swap_mac_addr(qdev->nvram_data.funcCfg_fn3.macAddress);
-       pEEPROMData = (u16 *) & qdev->nvram_data.version;
-       *pEEPROMData = le16_to_cpu(*pEEPROMData);
-
        spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
        return checksum;
 }
@@ -614,7 +566,7 @@ static const u32 PHYAddr[2] = {
 static int ql_wait_for_mii_ready(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 temp;
        int count = 1000;
 
@@ -631,7 +583,7 @@ static int ql_wait_for_mii_ready(struct ql3_adapter *qdev)
 static void ql_mii_enable_scan_mode(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 scanControl;
 
        if (qdev->numPorts > 1) {
@@ -659,7 +611,7 @@ static u8 ql_mii_disable_scan_mode(struct ql3_adapter *qdev)
 {
        u8 ret;
        struct ql3xxx_port_registers __iomem *port_regs =
-                                       qdev->mem_map_registers;
+                                       qdev->mem_map_registers;
 
        /* See if scan mode is enabled before we turn it off */
        if (ql_read_page0_reg(qdev, &port_regs->macMIIMgmtControlReg) &
@@ -689,17 +641,13 @@ static int ql_mii_write_reg_ex(struct ql3_adapter *qdev,
                               u16 regAddr, u16 value, u32 phyAddr)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u8 scanWasEnabled;
 
        scanWasEnabled = ql_mii_disable_scan_mode(qdev);
 
        if (ql_wait_for_mii_ready(qdev)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s Timed out waiting for management port to "
-                              "get free before issuing command.\n",
-                              qdev->ndev->name);
+               netif_warn(qdev, link, qdev->ndev, TIMED_OUT_MSG);
                return -1;
        }
 
@@ -710,11 +658,7 @@ static int ql_mii_write_reg_ex(struct ql3_adapter *qdev,
 
        /* Wait for write to complete 9/10/04 SJP */
        if (ql_wait_for_mii_ready(qdev)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Timed out waiting for management port to"
-                              "get free before issuing command.\n",
-                              qdev->ndev->name);
+               netif_warn(qdev, link, qdev->ndev, TIMED_OUT_MSG);
                return -1;
        }
 
@@ -725,21 +669,17 @@ static int ql_mii_write_reg_ex(struct ql3_adapter *qdev,
 }
 
 static int ql_mii_read_reg_ex(struct ql3_adapter *qdev, u16 regAddr,
-                             u16 * value, u32 phyAddr)
+                             u16 *value, u32 phyAddr)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u8 scanWasEnabled;
        u32 temp;
 
        scanWasEnabled = ql_mii_disable_scan_mode(qdev);
 
        if (ql_wait_for_mii_ready(qdev)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Timed out waiting for management port to "
-                              "get free before issuing command.\n",
-                              qdev->ndev->name);
+               netif_warn(qdev, link, qdev->ndev, TIMED_OUT_MSG);
                return -1;
        }
 
@@ -754,11 +694,7 @@ static int ql_mii_read_reg_ex(struct ql3_adapter *qdev, u16 regAddr,
 
        /* Wait for the read to complete */
        if (ql_wait_for_mii_ready(qdev)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Timed out waiting for management port to "
-                              "get free after issuing command.\n",
-                              qdev->ndev->name);
+               netif_warn(qdev, link, qdev->ndev, TIMED_OUT_MSG);
                return -1;
        }
 
@@ -774,16 +710,12 @@ static int ql_mii_read_reg_ex(struct ql3_adapter *qdev, u16 regAddr,
 static int ql_mii_write_reg(struct ql3_adapter *qdev, u16 regAddr, u16 value)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
 
        ql_mii_disable_scan_mode(qdev);
 
        if (ql_wait_for_mii_ready(qdev)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Timed out waiting for management port to "
-                              "get free before issuing command.\n",
-                              qdev->ndev->name);
+               netif_warn(qdev, link, qdev->ndev, TIMED_OUT_MSG);
                return -1;
        }
 
@@ -794,11 +726,7 @@ static int ql_mii_write_reg(struct ql3_adapter *qdev, u16 regAddr, u16 value)
 
        /* Wait for write to complete. */
        if (ql_wait_for_mii_ready(qdev)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Timed out waiting for management port to "
-                              "get free before issuing command.\n",
-                              qdev->ndev->name);
+               netif_warn(qdev, link, qdev->ndev, TIMED_OUT_MSG);
                return -1;
        }
 
@@ -811,16 +739,12 @@ static int ql_mii_read_reg(struct ql3_adapter *qdev, u16 regAddr, u16 *value)
 {
        u32 temp;
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
 
        ql_mii_disable_scan_mode(qdev);
 
        if (ql_wait_for_mii_ready(qdev)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Timed out waiting for management port to "
-                              "get free before issuing command.\n",
-                              qdev->ndev->name);
+               netif_warn(qdev, link, qdev->ndev, TIMED_OUT_MSG);
                return -1;
        }
 
@@ -835,11 +759,7 @@ static int ql_mii_read_reg(struct ql3_adapter *qdev, u16 regAddr, u16 *value)
 
        /* Wait for the read to complete */
        if (ql_wait_for_mii_ready(qdev)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Timed out waiting for management port to "
-                              "get free before issuing command.\n",
-                              qdev->ndev->name);
+               netif_warn(qdev, link, qdev->ndev, TIMED_OUT_MSG);
                return -1;
        }
 
@@ -885,14 +805,14 @@ static void ql_petbi_start_neg_ex(struct ql3_adapter *qdev)
        u16 reg;
 
        /* Enable Auto-negotiation sense */
-       ql_mii_read_reg_ex(qdev, PETBI_TBI_CTRL, &reg, 
+       ql_mii_read_reg_ex(qdev, PETBI_TBI_CTRL, &reg,
                           PHYAddr[qdev->mac_index]);
        reg |= PETBI_TBI_AUTO_SENSE;
-       ql_mii_write_reg_ex(qdev, PETBI_TBI_CTRL, reg, 
+       ql_mii_write_reg_ex(qdev, PETBI_TBI_CTRL, reg,
                            PHYAddr[qdev->mac_index]);
 
        ql_mii_write_reg_ex(qdev, PETBI_NEG_ADVER,
-                           PETBI_NEG_PAUSE | PETBI_NEG_DUPLEX, 
+                           PETBI_NEG_PAUSE | PETBI_NEG_DUPLEX,
                            PHYAddr[qdev->mac_index]);
 
        ql_mii_write_reg_ex(qdev, PETBI_CONTROL_REG,
@@ -925,7 +845,7 @@ static int ql_is_petbi_neg_pause(struct ql3_adapter *qdev)
 
 static void phyAgereSpecificInit(struct ql3_adapter *qdev, u32 miiAddr)
 {
-       printk(KERN_INFO "%s: enabling Agere specific PHY\n", qdev->ndev->name);
+       netdev_info(qdev->ndev, "enabling Agere specific PHY\n");
        /* power down device bit 11 = 1 */
        ql_mii_write_reg_ex(qdev, 0x00, 0x1940, miiAddr);
        /* enable diagnostic mode bit 2 = 1 */
@@ -945,8 +865,9 @@ static void phyAgereSpecificInit(struct ql3_adapter *qdev, u32 miiAddr)
        /* point to hidden reg 0x2806 */
        ql_mii_write_reg_ex(qdev, 0x10, 0x2806, miiAddr);
        /* Write new PHYAD w/bit 5 set */
-       ql_mii_write_reg_ex(qdev, 0x11, 0x0020 | (PHYAddr[qdev->mac_index] >> 8), miiAddr);
-       /* 
+       ql_mii_write_reg_ex(qdev, 0x11,
+                           0x0020 | (PHYAddr[qdev->mac_index] >> 8), miiAddr);
+       /*
         * Disable diagnostic mode bit 2 = 0
         * Power up device bit 11 = 0
         * Link up (on) and activity (blink)
@@ -956,21 +877,19 @@ static void phyAgereSpecificInit(struct ql3_adapter *qdev, u32 miiAddr)
        ql_mii_write_reg(qdev, 0x1c, 0xfaf0);
 }
 
-static PHY_DEVICE_et getPhyType (struct ql3_adapter *qdev, 
-                                u16 phyIdReg0, u16 phyIdReg1)
+static enum PHY_DEVICE_TYPE getPhyType(struct ql3_adapter *qdev,
+                                      u16 phyIdReg0, u16 phyIdReg1)
 {
-       PHY_DEVICE_et result = PHY_TYPE_UNKNOWN;
-       u32   oui;     
+       enum PHY_DEVICE_TYPE result = PHY_TYPE_UNKNOWN;
+       u32   oui;
        u16   model;
-       int i;   
+       int i;
 
-       if (phyIdReg0 == 0xffff) {
+       if (phyIdReg0 == 0xffff)
                return result;
-       }
-   
-       if (phyIdReg1 == 0xffff) {
+
+       if (phyIdReg1 == 0xffff)
                return result;
-       }
 
        /* oui is split between two registers */
        oui = (phyIdReg0 << 6) | ((phyIdReg1 & PHY_OUI_1_MASK) >> 10);
@@ -978,15 +897,13 @@ static PHY_DEVICE_et getPhyType (struct ql3_adapter *qdev,
        model = (phyIdReg1 & PHY_MODEL_MASK) >> 4;
 
        /* Scan table for this PHY */
-       for(i = 0; i < MAX_PHY_DEV_TYPES; i++) {
-               if ((oui == PHY_DEVICES[i].phyIdOUI) && (model == PHY_DEVICES[i].phyIdModel))
-               {
+       for (i = 0; i < MAX_PHY_DEV_TYPES; i++) {
+               if ((oui == PHY_DEVICES[i].phyIdOUI) &&
+                   (model == PHY_DEVICES[i].phyIdModel)) {
+                       netdev_info(qdev->ndev, "Phy: %s\n",
+                                   PHY_DEVICES[i].name);
                        result = PHY_DEVICES[i].phyDevice;
-
-                       printk(KERN_INFO "%s: Phy: %s\n",
-                               qdev->ndev->name, PHY_DEVICES[i].name);
-                       
-                       break;
+                       break;
                }
        }
 
@@ -997,9 +914,8 @@ static int ql_phy_get_speed(struct ql3_adapter *qdev)
 {
        u16 reg;
 
-       switch(qdev->phyType) {
-       case PHY_AGERE_ET1011C:
-       {
+       switch (qdev->phyType) {
+       case PHY_AGERE_ET1011C: {
                if (ql_mii_read_reg(qdev, 0x1A, &reg) < 0)
                        return 0;
 
@@ -1007,20 +923,20 @@ static int ql_phy_get_speed(struct ql3_adapter *qdev)
                break;
        }
        default:
-       if (ql_mii_read_reg(qdev, AUX_CONTROL_STATUS, &reg) < 0)
-               return 0;
+               if (ql_mii_read_reg(qdev, AUX_CONTROL_STATUS, &reg) < 0)
+                       return 0;
 
-       reg = (((reg & 0x18) >> 3) & 3);
+               reg = (((reg & 0x18) >> 3) & 3);
        }
 
-       switch(reg) {
-               case 2:
+       switch (reg) {
+       case 2:
                return SPEED_1000;
-               case 1:
+       case 1:
                return SPEED_100;
-               case 0:
+       case 0:
                return SPEED_10;
-               default:
+       default:
                return -1;
        }
 }
@@ -1029,17 +945,15 @@ static int ql_is_full_dup(struct ql3_adapter *qdev)
 {
        u16 reg;
 
-       switch(qdev->phyType) {
-       case PHY_AGERE_ET1011C:
-       {
+       switch (qdev->phyType) {
+       case PHY_AGERE_ET1011C: {
                if (ql_mii_read_reg(qdev, 0x1A, &reg))
                        return 0;
-                       
+
                return ((reg & 0x0080) && (reg & 0x1000)) != 0;
        }
        case PHY_VITESSE_VSC8211:
-       default:
-       {
+       default: {
                if (ql_mii_read_reg(qdev, AUX_CONTROL_STATUS, &reg) < 0)
                        return 0;
                return (reg & PHY_AUX_DUPLEX_STAT) != 0;
@@ -1067,46 +981,42 @@ static int PHY_Setup(struct ql3_adapter *qdev)
 
        /*  Determine the PHY we are using by reading the ID's */
        err = ql_mii_read_reg(qdev, PHY_ID_0_REG, &reg1);
-       if(err != 0) {
-               printk(KERN_ERR "%s: Could not read from reg PHY_ID_0_REG\n",
-                      qdev->ndev->name);
-                return err;
+       if (err != 0) {
+               netdev_err(qdev->ndev, "Could not read from reg PHY_ID_0_REG\n");
+               return err;
        }
 
        err = ql_mii_read_reg(qdev, PHY_ID_1_REG, &reg2);
-       if(err != 0) {
-               printk(KERN_ERR "%s: Could not read from reg PHY_ID_0_REG\n",
-                      qdev->ndev->name);
-                return err;
+       if (err != 0) {
+               netdev_err(qdev->ndev, "Could not read from reg PHY_ID_1_REG\n");
+               return err;
        }
 
        /*  Check if we have a Agere PHY */
        if ((reg1 == 0xffff) || (reg2 == 0xffff)) {
 
-               /* Determine which MII address we should be using 
+               /* Determine which MII address we should be using
                   determined by the index of the card */
-               if (qdev->mac_index == 0) {
+               if (qdev->mac_index == 0)
                        miiAddr = MII_AGERE_ADDR_1;
-               } else {
+               else
                        miiAddr = MII_AGERE_ADDR_2;
-               }
-      
-               err =ql_mii_read_reg_ex(qdev, PHY_ID_0_REG, &reg1, miiAddr);
-               if(err != 0) {
-                       printk(KERN_ERR "%s: Could not read from reg PHY_ID_0_REG after Agere detected\n",
-                              qdev->ndev->name);
-                       return err; 
+
+               err = ql_mii_read_reg_ex(qdev, PHY_ID_0_REG, &reg1, miiAddr);
+               if (err != 0) {
+                       netdev_err(qdev->ndev,
+                                  "Could not read from reg PHY_ID_0_REG after Agere detected\n");
+                       return err;
                }
 
                err = ql_mii_read_reg_ex(qdev, PHY_ID_1_REG, &reg2, miiAddr);
-               if(err != 0) {
-                       printk(KERN_ERR "%s: Could not read from reg PHY_ID_0_REG after Agere detected\n",
-                              qdev->ndev->name);
-                       return err;
+               if (err != 0) {
+                       netdev_err(qdev->ndev, "Could not read from reg PHY_ID_1_REG after Agere detected\n");
+                       return err;
                }
-   
+
                /*  We need to remember to initialize the Agere PHY */
-               agereAddrChangeNeeded = true; 
+               agereAddrChangeNeeded = true;
        }
 
        /*  Determine the particular PHY we have on board to apply
@@ -1115,9 +1025,9 @@ static int PHY_Setup(struct ql3_adapter *qdev)
 
        if ((qdev->phyType == PHY_AGERE_ET1011C) && agereAddrChangeNeeded) {
                /* need this here so address gets changed */
-               phyAgereSpecificInit(qdev, miiAddr);  
+               phyAgereSpecificInit(qdev, miiAddr);
        } else if (qdev->phyType == PHY_TYPE_UNKNOWN) {
-               printk(KERN_ERR "%s: PHY is unknown\n", qdev->ndev->name);
+               netdev_err(qdev->ndev, "PHY is unknown\n");
                return -EIO;
        }
 
@@ -1130,7 +1040,7 @@ static int PHY_Setup(struct ql3_adapter *qdev)
 static void ql_mac_enable(struct ql3_adapter *qdev, u32 enable)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 value;
 
        if (enable)
@@ -1150,7 +1060,7 @@ static void ql_mac_enable(struct ql3_adapter *qdev, u32 enable)
 static void ql_mac_cfg_soft_reset(struct ql3_adapter *qdev, u32 enable)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 value;
 
        if (enable)
@@ -1170,7 +1080,7 @@ static void ql_mac_cfg_soft_reset(struct ql3_adapter *qdev, u32 enable)
 static void ql_mac_cfg_gig(struct ql3_adapter *qdev, u32 enable)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 value;
 
        if (enable)
@@ -1190,7 +1100,7 @@ static void ql_mac_cfg_gig(struct ql3_adapter *qdev, u32 enable)
 static void ql_mac_cfg_full_dup(struct ql3_adapter *qdev, u32 enable)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 value;
 
        if (enable)
@@ -1210,7 +1120,7 @@ static void ql_mac_cfg_full_dup(struct ql3_adapter *qdev, u32 enable)
 static void ql_mac_cfg_pause(struct ql3_adapter *qdev, u32 enable)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 value;
 
        if (enable)
@@ -1232,7 +1142,7 @@ static void ql_mac_cfg_pause(struct ql3_adapter *qdev, u32 enable)
 static int ql_is_fiber(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 bitToCheck = 0;
        u32 temp;
 
@@ -1262,7 +1172,7 @@ static int ql_is_auto_cfg(struct ql3_adapter *qdev)
 static int ql_is_auto_neg_complete(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 bitToCheck = 0;
        u32 temp;
 
@@ -1277,18 +1187,11 @@ static int ql_is_auto_neg_complete(struct ql3_adapter *qdev)
 
        temp = ql_read_page0_reg(qdev, &port_regs->portStatus);
        if (temp & bitToCheck) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_INFO PFX
-                              "%s: Auto-Negotiate complete.\n",
-                              qdev->ndev->name);
+               netif_info(qdev, link, qdev->ndev, "Auto-Negotiate complete\n");
                return 1;
-       } else {
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Auto-Negotiate incomplete.\n",
-                              qdev->ndev->name);
-               return 0;
        }
+       netif_info(qdev, link, qdev->ndev, "Auto-Negotiate incomplete\n");
+       return 0;
 }
 
 /*
@@ -1305,7 +1208,7 @@ static int ql_is_neg_pause(struct ql3_adapter *qdev)
 static int ql_auto_neg_error(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 bitToCheck = 0;
        u32 temp;
 
@@ -1343,7 +1246,7 @@ static int ql_is_link_full_dup(struct ql3_adapter *qdev)
 static int ql_link_down_detect(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 bitToCheck = 0;
        u32 temp;
 
@@ -1367,7 +1270,7 @@ static int ql_link_down_detect(struct ql3_adapter *qdev)
 static int ql_link_down_detect_clear(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
 
        switch (qdev->mac_index) {
        case 0:
@@ -1397,7 +1300,7 @@ static int ql_link_down_detect_clear(struct ql3_adapter *qdev)
 static int ql_this_adapter_controls_port(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 bitToCheck = 0;
        u32 temp;
 
@@ -1414,21 +1317,18 @@ static int ql_this_adapter_controls_port(struct ql3_adapter *qdev)
 
        temp = ql_read_page0_reg(qdev, &port_regs->portStatus);
        if (temp & bitToCheck) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_DEBUG PFX
-                              "%s: is not link master.\n", qdev->ndev->name);
+               netif_printk(qdev, link, KERN_DEBUG, qdev->ndev,
+                            "not link master\n");
                return 0;
-       } else {
-               if (netif_msg_link(qdev))
-                       printk(KERN_DEBUG PFX
-                              "%s: is link master.\n", qdev->ndev->name);
-               return 1;
        }
+
+       netif_printk(qdev, link, KERN_DEBUG, qdev->ndev, "link master\n");
+       return 1;
 }
 
 static void ql_phy_reset_ex(struct ql3_adapter *qdev)
 {
-       ql_mii_write_reg_ex(qdev, CONTROL_REG, PHY_CTRL_SOFT_RESET, 
+       ql_mii_write_reg_ex(qdev, CONTROL_REG, PHY_CTRL_SOFT_RESET,
                            PHYAddr[qdev->mac_index]);
 }
 
@@ -1437,39 +1337,35 @@ static void ql_phy_start_neg_ex(struct ql3_adapter *qdev)
        u16 reg;
        u16 portConfiguration;
 
-       if(qdev->phyType == PHY_AGERE_ET1011C) {
-               /* turn off external loopback */
-               ql_mii_write_reg(qdev, 0x13, 0x0000); 
-       }
+       if (qdev->phyType == PHY_AGERE_ET1011C)
+               ql_mii_write_reg(qdev, 0x13, 0x0000);
+                                       /* turn off external loopback */
 
-       if(qdev->mac_index == 0)
-               portConfiguration = qdev->nvram_data.macCfg_port0.portConfiguration;
+       if (qdev->mac_index == 0)
+               portConfiguration =
+                       qdev->nvram_data.macCfg_port0.portConfiguration;
        else
-               portConfiguration = qdev->nvram_data.macCfg_port1.portConfiguration;
+               portConfiguration =
+                       qdev->nvram_data.macCfg_port1.portConfiguration;
 
        /*  Some HBA's in the field are set to 0 and they need to
            be reinterpreted with a default value */
-       if(portConfiguration == 0)
+       if (portConfiguration == 0)
                portConfiguration = PORT_CONFIG_DEFAULT;
 
        /* Set the 1000 advertisements */
-       ql_mii_read_reg_ex(qdev, PHY_GIG_CONTROL, &reg, 
+       ql_mii_read_reg_ex(qdev, PHY_GIG_CONTROL, &reg,
                           PHYAddr[qdev->mac_index]);
        reg &= ~PHY_GIG_ALL_PARAMS;
 
-       if(portConfiguration & 
-          PORT_CONFIG_FULL_DUPLEX_ENABLED &
-          PORT_CONFIG_1000MB_SPEED) {
-               reg |= PHY_GIG_ADV_1000F;
-       }
-        
-       if(portConfiguration & 
-          PORT_CONFIG_HALF_DUPLEX_ENABLED &
-          PORT_CONFIG_1000MB_SPEED) {
-               reg |= PHY_GIG_ADV_1000H;
+       if (portConfiguration & PORT_CONFIG_1000MB_SPEED) {
+               if (portConfiguration & PORT_CONFIG_FULL_DUPLEX_ENABLED)
+                       reg |= PHY_GIG_ADV_1000F;
+               else
+                       reg |= PHY_GIG_ADV_1000H;
        }
 
-       ql_mii_write_reg_ex(qdev, PHY_GIG_CONTROL, reg, 
+       ql_mii_write_reg_ex(qdev, PHY_GIG_CONTROL, reg,
                            PHYAddr[qdev->mac_index]);
 
        /* Set the 10/100 & pause negotiation advertisements */
@@ -1477,36 +1373,34 @@ static void ql_phy_start_neg_ex(struct ql3_adapter *qdev)
                           PHYAddr[qdev->mac_index]);
        reg &= ~PHY_NEG_ALL_PARAMS;
 
-       if(portConfiguration & PORT_CONFIG_SYM_PAUSE_ENABLED)
+       if (portConfiguration & PORT_CONFIG_SYM_PAUSE_ENABLED)
                reg |= PHY_NEG_ASY_PAUSE | PHY_NEG_SYM_PAUSE;
 
-       if(portConfiguration & PORT_CONFIG_FULL_DUPLEX_ENABLED) {
-               if(portConfiguration & PORT_CONFIG_100MB_SPEED)
+       if (portConfiguration & PORT_CONFIG_FULL_DUPLEX_ENABLED) {
+               if (portConfiguration & PORT_CONFIG_100MB_SPEED)
                        reg |= PHY_NEG_ADV_100F;
-               
-               if(portConfiguration & PORT_CONFIG_10MB_SPEED)
+
+               if (portConfiguration & PORT_CONFIG_10MB_SPEED)
                        reg |= PHY_NEG_ADV_10F;
        }
 
-       if(portConfiguration & PORT_CONFIG_HALF_DUPLEX_ENABLED) {
-               if(portConfiguration & PORT_CONFIG_100MB_SPEED)
+       if (portConfiguration & PORT_CONFIG_HALF_DUPLEX_ENABLED) {
+               if (portConfiguration & PORT_CONFIG_100MB_SPEED)
                        reg |= PHY_NEG_ADV_100H;
-               
-               if(portConfiguration & PORT_CONFIG_10MB_SPEED)
+
+               if (portConfiguration & PORT_CONFIG_10MB_SPEED)
                        reg |= PHY_NEG_ADV_10H;
        }
 
-       if(portConfiguration &
-          PORT_CONFIG_1000MB_SPEED) {
-               reg |= 1;       
-       }
+       if (portConfiguration & PORT_CONFIG_1000MB_SPEED)
+               reg |= 1;
 
-       ql_mii_write_reg_ex(qdev, PHY_NEG_ADVER, reg, 
+       ql_mii_write_reg_ex(qdev, PHY_NEG_ADVER, reg,
                            PHYAddr[qdev->mac_index]);
 
        ql_mii_read_reg_ex(qdev, CONTROL_REG, &reg, PHYAddr[qdev->mac_index]);
-       
-       ql_mii_write_reg_ex(qdev, CONTROL_REG, 
+
+       ql_mii_write_reg_ex(qdev, CONTROL_REG,
                            reg | PHY_CTRL_RESTART_NEG | PHY_CTRL_AUTO_NEG,
                            PHYAddr[qdev->mac_index]);
 }
@@ -1524,7 +1418,7 @@ static void ql_phy_init_ex(struct ql3_adapter *qdev)
 static u32 ql_get_link_state(struct ql3_adapter *qdev)
 {
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        u32 bitToCheck = 0;
        u32 temp, linkState;
 
@@ -1536,25 +1430,22 @@ static u32 ql_get_link_state(struct ql3_adapter *qdev)
                bitToCheck = PORT_STATUS_UP1;
                break;
        }
+
        temp = ql_read_page0_reg(qdev, &port_regs->portStatus);
-       if (temp & bitToCheck) {
+       if (temp & bitToCheck)
                linkState = LS_UP;
-       } else {
+       else
                linkState = LS_DOWN;
-               if (netif_msg_link(qdev))
-                       printk(KERN_WARNING PFX
-                              "%s: Link is down.\n", qdev->ndev->name);
-       }
+
        return linkState;
 }
 
 static int ql_port_start(struct ql3_adapter *qdev)
 {
-       if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
+       if (ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
                (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
                         2) << 7)) {
-               printk(KERN_ERR "%s: Could not get hw lock for GIO\n",
-                      qdev->ndev->name);
+               netdev_err(qdev->ndev, "Could not get hw lock for GIO\n");
                return -1;
        }
 
@@ -1572,19 +1463,16 @@ static int ql_port_start(struct ql3_adapter *qdev)
 static int ql_finish_auto_neg(struct ql3_adapter *qdev)
 {
 
-       if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
+       if (ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
                (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
                         2) << 7))
                return -1;
 
        if (!ql_auto_neg_error(qdev)) {
-               if (test_bit(QL_LINK_MASTER,&qdev->flags)) {
+               if (test_bit(QL_LINK_MASTER, &qdev->flags)) {
                        /* configure the MAC */
-                       if (netif_msg_link(qdev))
-                               printk(KERN_DEBUG PFX
-                                      "%s: Configuring link.\n",
-                                      qdev->ndev->
-                                      name);
+                       netif_printk(qdev, link, KERN_DEBUG, qdev->ndev,
+                                    "Configuring link\n");
                        ql_mac_cfg_soft_reset(qdev, 1);
                        ql_mac_cfg_gig(qdev,
                                       (ql_get_link_speed
@@ -1599,55 +1487,43 @@ static int ql_finish_auto_neg(struct ql3_adapter *qdev)
                        ql_mac_cfg_soft_reset(qdev, 0);
 
                        /* enable the MAC */
-                       if (netif_msg_link(qdev))
-                               printk(KERN_DEBUG PFX
-                                      "%s: Enabling mac.\n",
-                                      qdev->ndev->
-                                              name);
+                       netif_printk(qdev, link, KERN_DEBUG, qdev->ndev,
+                                    "Enabling mac\n");
                        ql_mac_enable(qdev, 1);
                }
 
-               if (netif_msg_link(qdev))
-                       printk(KERN_DEBUG PFX
-                              "%s: Change port_link_state LS_DOWN to LS_UP.\n",
-                              qdev->ndev->name);
                qdev->port_link_state = LS_UP;
                netif_start_queue(qdev->ndev);
                netif_carrier_on(qdev->ndev);
-               if (netif_msg_link(qdev))
-                       printk(KERN_INFO PFX
-                              "%s: Link is up at %d Mbps, %s duplex.\n",
-                              qdev->ndev->name,
-                              ql_get_link_speed(qdev),
-                              ql_is_link_full_dup(qdev)
-                              ? "full" : "half");
+               netif_info(qdev, link, qdev->ndev,
+                          "Link is up at %d Mbps, %s duplex\n",
+                          ql_get_link_speed(qdev),
+                          ql_is_link_full_dup(qdev) ? "full" : "half");
 
        } else {        /* Remote error detected */
 
-               if (test_bit(QL_LINK_MASTER,&qdev->flags)) {
-                       if (netif_msg_link(qdev))
-                               printk(KERN_DEBUG PFX
-                                      "%s: Remote error detected. "
-                                      "Calling ql_port_start().\n",
-                                      qdev->ndev->
-                                      name);
+               if (test_bit(QL_LINK_MASTER, &qdev->flags)) {
+                       netif_printk(qdev, link, KERN_DEBUG, qdev->ndev,
+                                    "Remote error detected. Calling ql_port_start()\n");
                        /*
                         * ql_port_start() is shared code and needs
                         * to lock the PHY on it's own.
                         */
                        ql_sem_unlock(qdev, QL_PHY_GIO_SEM_MASK);
-                       if(ql_port_start(qdev)) {/* Restart port */
+                       if (ql_port_start(qdev))        /* Restart port */
                                return -1;
-                       } else
-                               return 0;
+                       return 0;
                }
        }
        ql_sem_unlock(qdev, QL_PHY_GIO_SEM_MASK);
        return 0;
 }
 
-static void ql_link_state_machine(struct ql3_adapter *qdev)
+static void ql_link_state_machine_work(struct work_struct *work)
 {
+       struct ql3_adapter *qdev =
+               container_of(work, struct ql3_adapter, link_state_work.work);
+
        u32 curr_link_state;
        unsigned long hw_flags;
 
@@ -1655,40 +1531,35 @@ static void ql_link_state_machine(struct ql3_adapter *qdev)
 
        curr_link_state = ql_get_link_state(qdev);
 
-       if (test_bit(QL_RESET_ACTIVE,&qdev->flags)) {
-               if (netif_msg_link(qdev))
-                       printk(KERN_INFO PFX
-                              "%s: Reset in progress, skip processing link "
-                              "state.\n", qdev->ndev->name);
+       if (test_bit(QL_RESET_ACTIVE, &qdev->flags)) {
+               netif_info(qdev, link, qdev->ndev,
+                          "Reset in progress, skip processing link state\n");
+
+               spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
+
+               /* Restart timer on 2 second interval. */
+               mod_timer(&qdev->adapter_timer, jiffies + HZ * 1);
 
-               spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);               
                return;
        }
 
        switch (qdev->port_link_state) {
        default:
-               if (test_bit(QL_LINK_MASTER,&qdev->flags)) {
+               if (test_bit(QL_LINK_MASTER, &qdev->flags))
                        ql_port_start(qdev);
-               }
                qdev->port_link_state = LS_DOWN;
                /* Fall Through */
 
        case LS_DOWN:
-               if (netif_msg_link(qdev))
-                       printk(KERN_DEBUG PFX
-                              "%s: port_link_state = LS_DOWN.\n",
-                              qdev->ndev->name);
                if (curr_link_state == LS_UP) {
-                       if (netif_msg_link(qdev))
-                               printk(KERN_DEBUG PFX
-                                      "%s: curr_link_state = LS_UP.\n",
-                                      qdev->ndev->name);
+                       netif_info(qdev, link, qdev->ndev, "Link is up\n");
                        if (ql_is_auto_neg_complete(qdev))
                                ql_finish_auto_neg(qdev);
 
                        if (qdev->port_link_state == LS_UP)
                                ql_link_down_detect_clear(qdev);
 
+                       qdev->port_link_state = LS_UP;
                }
                break;
 
@@ -1697,15 +1568,18 @@ static void ql_link_state_machine(struct ql3_adapter *qdev)
                 * See if the link is currently down or went down and came
                 * back up
                 */
-               if ((curr_link_state == LS_DOWN) || ql_link_down_detect(qdev)) {
-                       if (netif_msg_link(qdev))
-                               printk(KERN_INFO PFX "%s: Link is down.\n",
-                                      qdev->ndev->name);
+               if (curr_link_state == LS_DOWN) {
+                       netif_info(qdev, link, qdev->ndev, "Link is down\n");
                        qdev->port_link_state = LS_DOWN;
                }
+               if (ql_link_down_detect(qdev))
+                       qdev->port_link_state = LS_DOWN;
                break;
        }
        spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
+
+       /* Restart timer on 2 second interval. */
+       mod_timer(&qdev->adapter_timer, jiffies + HZ * 1);
 }
 
 /*
@@ -1714,9 +1588,9 @@ static void ql_link_state_machine(struct ql3_adapter *qdev)
 static void ql_get_phy_owner(struct ql3_adapter *qdev)
 {
        if (ql_this_adapter_controls_port(qdev))
-               set_bit(QL_LINK_MASTER,&qdev->flags);
+               set_bit(QL_LINK_MASTER, &qdev->flags);
        else
-               clear_bit(QL_LINK_MASTER,&qdev->flags);
+               clear_bit(QL_LINK_MASTER, &qdev->flags);
 }
 
 /*
@@ -1726,7 +1600,7 @@ static void ql_init_scan_mode(struct ql3_adapter *qdev)
 {
        ql_mii_enable_scan_mode(qdev);
 
-       if (test_bit(QL_LINK_OPTICAL,&qdev->flags)) {
+       if (test_bit(QL_LINK_OPTICAL, &qdev->flags)) {
                if (ql_this_adapter_controls_port(qdev))
                        ql_petbi_init_ex(qdev);
        } else {
@@ -1736,24 +1610,24 @@ static void ql_init_scan_mode(struct ql3_adapter *qdev)
 }
 
 /*
- * MII_Setup needs to be called before taking the PHY out of reset so that the
- * management interface clock speed can be set properly.  It would be better if
- * we had a way to disable MDC until after the PHY is out of reset, but we
- * don't have that capability.
+ * MII_Setup needs to be called before taking the PHY out of reset
+ * so that the management interface clock speed can be set properly.
+ * It would be better if we had a way to disable MDC until after the
+ * PHY is out of reset, but we don't have that capability.
  */
 static int ql_mii_setup(struct ql3_adapter *qdev)
 {
        u32 reg;
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
 
-       if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
+       if (ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
                        (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
                         2) << 7))
                return -1;
 
        if (qdev->device_id == QL3032_DEVICE_ID)
-               ql_write_page0_reg(qdev, 
+               ql_write_page0_reg(qdev,
                        &port_regs->macMIIMgmtControlReg, 0x0f00000);
 
        /* Divide 125MHz clock by 28 to meet PHY timing requirements */
@@ -1766,24 +1640,24 @@ static int ql_mii_setup(struct ql3_adapter *qdev)
        return 0;
 }
 
+#define SUPPORTED_OPTICAL_MODES        (SUPPORTED_1000baseT_Full |     \
+                                SUPPORTED_FIBRE |              \
+                                SUPPORTED_Autoneg)
+#define SUPPORTED_TP_MODES     (SUPPORTED_10baseT_Half |       \
+                                SUPPORTED_10baseT_Full |       \
+                                SUPPORTED_100baseT_Half |      \
+                                SUPPORTED_100baseT_Full |      \
+                                SUPPORTED_1000baseT_Half |     \
+                                SUPPORTED_1000baseT_Full |     \
+                                SUPPORTED_Autoneg |            \
+                                SUPPORTED_TP);                 \
+
 static u32 ql_supported_modes(struct ql3_adapter *qdev)
 {
-       u32 supported;
+       if (test_bit(QL_LINK_OPTICAL, &qdev->flags))
+               return SUPPORTED_OPTICAL_MODES;
 
-       if (test_bit(QL_LINK_OPTICAL,&qdev->flags)) {
-               supported = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE
-                   | SUPPORTED_Autoneg;
-       } else {
-               supported = SUPPORTED_10baseT_Half
-                   | SUPPORTED_10baseT_Full
-                   | SUPPORTED_100baseT_Half
-                   | SUPPORTED_100baseT_Full
-                   | SUPPORTED_1000baseT_Half
-                   | SUPPORTED_1000baseT_Full
-                   | SUPPORTED_Autoneg | SUPPORTED_TP;
-       }
-
-       return supported;
+       return SUPPORTED_TP_MODES;
 }
 
 static int ql_get_auto_cfg_status(struct ql3_adapter *qdev)
@@ -1791,9 +1665,9 @@ static int ql_get_auto_cfg_status(struct ql3_adapter *qdev)
        int status;
        unsigned long hw_flags;
        spin_lock_irqsave(&qdev->hw_lock, hw_flags);
-       if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
-               (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
-                        2) << 7)) {
+       if (ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
+                           (QL_RESOURCE_BITS_BASE_CODE |
+                            (qdev->mac_index) * 2) << 7)) {
                spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
                return 0;
        }
@@ -1808,9 +1682,9 @@ static u32 ql_get_speed(struct ql3_adapter *qdev)
        u32 status;
        unsigned long hw_flags;
        spin_lock_irqsave(&qdev->hw_lock, hw_flags);
-       if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
-               (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
-                        2) << 7)) {
+       if (ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
+                           (QL_RESOURCE_BITS_BASE_CODE |
+                            (qdev->mac_index) * 2) << 7)) {
                spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
                return 0;
        }
@@ -1825,9 +1699,9 @@ static int ql_get_full_dup(struct ql3_adapter *qdev)
        int status;
        unsigned long hw_flags;
        spin_lock_irqsave(&qdev->hw_lock, hw_flags);
-       if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
-               (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
-                        2) << 7)) {
+       if (ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
+                           (QL_RESOURCE_BITS_BASE_CODE |
+                            (qdev->mac_index) * 2) << 7)) {
                spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
                return 0;
        }
@@ -1837,7 +1711,6 @@ static int ql_get_full_dup(struct ql3_adapter *qdev)
        return status;
 }
 
-
 static int ql_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
 {
        struct ql3_adapter *qdev = netdev_priv(ndev);
@@ -1845,7 +1718,7 @@ static int ql_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
        ecmd->transceiver = XCVR_INTERNAL;
        ecmd->supported = ql_supported_modes(qdev);
 
-       if (test_bit(QL_LINK_OPTICAL,&qdev->flags)) {
+       if (test_bit(QL_LINK_OPTICAL, &qdev->flags)) {
                ecmd->port = PORT_FIBRE;
        } else {
                ecmd->port = PORT_TP;
@@ -1853,7 +1726,7 @@ static int ql_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
        }
        ecmd->advertising = ql_supported_modes(qdev);
        ecmd->autoneg = ql_get_auto_cfg_status(qdev);
-       ecmd->speed = ql_get_speed(qdev);
+       ethtool_cmd_speed_set(ecmd, ql_get_speed(qdev));
        ecmd->duplex = ql_get_full_dup(qdev);
        return 0;
 }
@@ -1866,8 +1739,6 @@ static void ql_get_drvinfo(struct net_device *ndev,
        strncpy(drvinfo->version, ql3xxx_driver_version, 32);
        strncpy(drvinfo->fw_version, "N/A", 32);
        strncpy(drvinfo->bus_info, pci_name(qdev->pdev), 32);
-       drvinfo->n_stats = 0;
-       drvinfo->testinfo_len = 0;
        drvinfo->regdump_len = 0;
        drvinfo->eedump_len = 0;
 }
@@ -1888,10 +1759,11 @@ static void ql_get_pauseparam(struct net_device *ndev,
                              struct ethtool_pauseparam *pause)
 {
        struct ql3_adapter *qdev = netdev_priv(ndev);
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
 
        u32 reg;
-       if(qdev->mac_index == 0)
+       if (qdev->mac_index == 0)
                reg = ql_read_page0_reg(qdev, &port_regs->mac0ConfigReg);
        else
                reg = ql_read_page0_reg(qdev, &port_regs->mac1ConfigReg);
@@ -1918,12 +1790,12 @@ static int ql_populate_free_queue(struct ql3_adapter *qdev)
 
        while (lrg_buf_cb) {
                if (!lrg_buf_cb->skb) {
-                       lrg_buf_cb->skb = netdev_alloc_skb(qdev->ndev,
-                                                          qdev->lrg_buffer_len);
+                       lrg_buf_cb->skb =
+                               netdev_alloc_skb(qdev->ndev,
+                                                qdev->lrg_buffer_len);
                        if (unlikely(!lrg_buf_cb->skb)) {
-                               printk(KERN_DEBUG PFX
-                                      "%s: Failed netdev_alloc_skb().\n",
-                                      qdev->ndev->name);
+                               netdev_printk(KERN_DEBUG, qdev->ndev,
+                                             "Failed netdev_alloc_skb()\n");
                                break;
                        } else {
                                /*
@@ -1937,10 +1809,11 @@ static int ql_populate_free_queue(struct ql3_adapter *qdev)
                                                     QL_HEADER_SPACE,
                                                     PCI_DMA_FROMDEVICE);
 
-                               err = pci_dma_mapping_error(map);
-                               if(err) {
-                                       printk(KERN_ERR "%s: PCI mapping failed with error: %d\n", 
-                                              qdev->ndev->name, err);
+                               err = pci_dma_mapping_error(qdev->pdev, map);
+                               if (err) {
+                                       netdev_err(qdev->ndev,
+                                                  "PCI mapping failed with error: %d\n",
+                                                  err);
                                        dev_kfree_skb(lrg_buf_cb->skb);
                                        lrg_buf_cb->skb = NULL;
                                        break;
@@ -1948,11 +1821,11 @@ static int ql_populate_free_queue(struct ql3_adapter *qdev)
 
 
                                lrg_buf_cb->buf_phy_addr_low =
-                                   cpu_to_le32(LS_64BITS(map));
+                                       cpu_to_le32(LS_64BITS(map));
                                lrg_buf_cb->buf_phy_addr_high =
-                                   cpu_to_le32(MS_64BITS(map));
-                               pci_unmap_addr_set(lrg_buf_cb, mapaddr, map);
-                               pci_unmap_len_set(lrg_buf_cb, maplen,
+                                       cpu_to_le32(MS_64BITS(map));
+                               dma_unmap_addr_set(lrg_buf_cb, mapaddr, map);
+                               dma_unmap_len_set(lrg_buf_cb, maplen,
                                                  qdev->lrg_buffer_len -
                                                  QL_HEADER_SPACE);
                                --qdev->lrg_buf_skb_check;
@@ -1970,7 +1843,9 @@ static int ql_populate_free_queue(struct ql3_adapter *qdev)
  */
 static void ql_update_small_bufq_prod_index(struct ql3_adapter *qdev)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
+
        if (qdev->small_buf_release_cnt >= 16) {
                while (qdev->small_buf_release_cnt >= 16) {
                        qdev->small_buf_q_producer_index++;
@@ -1994,10 +1869,11 @@ static void ql_update_lrg_bufq_prod_index(struct ql3_adapter *qdev)
        struct bufq_addr_element *lrg_buf_q_ele;
        int i;
        struct ql_rcv_buf_cb *lrg_buf_cb;
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
 
-       if ((qdev->lrg_buf_free_count >= 8)
-           && (qdev->lrg_buf_release_cnt >= 16)) {
+       if ((qdev->lrg_buf_free_count >= 8) &&
+           (qdev->lrg_buf_release_cnt >= 16)) {
 
                if (qdev->lrg_buf_skb_check)
                        if (!ql_populate_free_queue(qdev))
@@ -2005,8 +1881,8 @@ static void ql_update_lrg_bufq_prod_index(struct ql3_adapter *qdev)
 
                lrg_buf_q_ele = qdev->lrg_buf_next_free;
 
-               while ((qdev->lrg_buf_release_cnt >= 16)
-                      && (qdev->lrg_buf_free_count >= 8)) {
+               while ((qdev->lrg_buf_release_cnt >= 16) &&
+                      (qdev->lrg_buf_free_count >= 8)) {
 
                        for (i = 0; i < 8; i++) {
                                lrg_buf_cb =
@@ -2022,7 +1898,8 @@ static void ql_update_lrg_bufq_prod_index(struct ql3_adapter *qdev)
 
                        qdev->lrg_buf_q_producer_index++;
 
-                       if (qdev->lrg_buf_q_producer_index == qdev->num_lbufq_entries)
+                       if (qdev->lrg_buf_q_producer_index ==
+                           qdev->num_lbufq_entries)
                                qdev->lrg_buf_q_producer_index = 0;
 
                        if (qdev->lrg_buf_q_producer_index ==
@@ -2044,45 +1921,48 @@ static void ql_process_mac_tx_intr(struct ql3_adapter *qdev,
        int i;
        int retval = 0;
 
-       if(mac_rsp->flags & OB_MAC_IOCB_RSP_S) {
-               printk(KERN_WARNING "Frame short but, frame was padded and sent.\n");
+       if (mac_rsp->flags & OB_MAC_IOCB_RSP_S) {
+               netdev_warn(qdev->ndev,
+                           "Frame too short but it was padded and sent\n");
        }
-       
+
        tx_cb = &qdev->tx_buf[mac_rsp->transaction_id];
 
        /*  Check the transmit response flags for any errors */
-       if(mac_rsp->flags & OB_MAC_IOCB_RSP_S) {
-               printk(KERN_ERR "Frame too short to be legal, frame not sent.\n");
+       if (mac_rsp->flags & OB_MAC_IOCB_RSP_S) {
+               netdev_err(qdev->ndev,
+                          "Frame too short to be legal, frame not sent\n");
 
-               qdev->stats.tx_errors++;
+               qdev->ndev->stats.tx_errors++;
                retval = -EIO;
                goto frame_not_sent;
        }
 
-       if(tx_cb->seg_count == 0) {
-               printk(KERN_ERR "tx_cb->seg_count == 0: %d\n", mac_rsp->transaction_id);
+       if (tx_cb->seg_count == 0) {
+               netdev_err(qdev->ndev, "tx_cb->seg_count == 0: %d\n",
+                          mac_rsp->transaction_id);
 
-               qdev->stats.tx_errors++;
+               qdev->ndev->stats.tx_errors++;
                retval = -EIO;
                goto invalid_seg_count;
        }
 
        pci_unmap_single(qdev->pdev,
-                        pci_unmap_addr(&tx_cb->map[0], mapaddr),
-                        pci_unmap_len(&tx_cb->map[0], maplen),
+                        dma_unmap_addr(&tx_cb->map[0], mapaddr),
+                        dma_unmap_len(&tx_cb->map[0], maplen),
                         PCI_DMA_TODEVICE);
        tx_cb->seg_count--;
        if (tx_cb->seg_count) {
                for (i = 1; i < tx_cb->seg_count; i++) {
                        pci_unmap_page(qdev->pdev,
-                                      pci_unmap_addr(&tx_cb->map[i],
+                                      dma_unmap_addr(&tx_cb->map[i],
                                                      mapaddr),
-                                      pci_unmap_len(&tx_cb->map[i], maplen),
+                                      dma_unmap_len(&tx_cb->map[i], maplen),
                                       PCI_DMA_TODEVICE);
                }
        }
-       qdev->stats.tx_packets++;
-       qdev->stats.tx_bytes += tx_cb->skb->len;
+       qdev->ndev->stats.tx_packets++;
+       qdev->ndev->stats.tx_bytes += tx_cb->skb->len;
 
 frame_not_sent:
        dev_kfree_skb_irq(tx_cb->skb);
@@ -2106,18 +1986,18 @@ static struct ql_rcv_buf_cb *ql_get_lbuf(struct ql3_adapter *qdev)
        qdev->lrg_buf_release_cnt++;
        if (++qdev->lrg_buf_index == qdev->num_large_buffers)
                qdev->lrg_buf_index = 0;
-       return(lrg_buf_cb);
+       return lrg_buf_cb;
 }
 
 /*
  * The difference between 3022 and 3032 for inbound completions:
- * 3022 uses two buffers per completion.  The first buffer contains 
- * (some) header info, the second the remainder of the headers plus 
- * the data.  For this chip we reserve some space at the top of the 
- * receive buffer so that the header info in buffer one can be 
- * prepended to the buffer two.  Buffer two is the sent up while 
+ * 3022 uses two buffers per completion.  The first buffer contains
+ * (some) header info, the second the remainder of the headers plus
+ * the data.  For this chip we reserve some space at the top of the
+ * receive buffer so that the header info in buffer one can be
+ * prepended to the buffer two.  Buffer two is the sent up while
  * buffer one is returned to the hardware to be reused.
- * 3032 receives all of it's data and headers in one buffer for a 
+ * 3032 receives all of it's data and headers in one buffer for a
  * simpler process.  3032 also supports checksum verification as
  * can be seen in ql_process_macip_rx_intr().
  */
@@ -2141,20 +2021,19 @@ static void ql_process_mac_rx_intr(struct ql3_adapter *qdev,
        lrg_buf_cb2 = ql_get_lbuf(qdev);
        skb = lrg_buf_cb2->skb;
 
-       qdev->stats.rx_packets++;
-       qdev->stats.rx_bytes += length;
+       qdev->ndev->stats.rx_packets++;
+       qdev->ndev->stats.rx_bytes += length;
 
        skb_put(skb, length);
        pci_unmap_single(qdev->pdev,
-                        pci_unmap_addr(lrg_buf_cb2, mapaddr),
-                        pci_unmap_len(lrg_buf_cb2, maplen),
+                        dma_unmap_addr(lrg_buf_cb2, mapaddr),
+                        dma_unmap_len(lrg_buf_cb2, maplen),
                         PCI_DMA_FROMDEVICE);
        prefetch(skb->data);
-       skb->ip_summed = CHECKSUM_NONE;
+       skb_checksum_none_assert(skb);
        skb->protocol = eth_type_trans(skb, qdev->ndev);
 
        netif_receive_skb(skb);
-       qdev->ndev->last_rx = jiffies;
        lrg_buf_cb2->skb = NULL;
 
        if (qdev->device_id == QL3022_DEVICE_ID)
@@ -2193,12 +2072,12 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
 
        skb_put(skb2, length);  /* Just the second buffer length here. */
        pci_unmap_single(qdev->pdev,
-                        pci_unmap_addr(lrg_buf_cb2, mapaddr),
-                        pci_unmap_len(lrg_buf_cb2, maplen),
+                        dma_unmap_addr(lrg_buf_cb2, mapaddr),
+                        dma_unmap_len(lrg_buf_cb2, maplen),
                         PCI_DMA_FROMDEVICE);
        prefetch(skb2->data);
 
-       skb2->ip_summed = CHECKSUM_NONE;
+       skb_checksum_none_assert(skb2);
        if (qdev->device_id == QL3022_DEVICE_ID) {
                /*
                 * Copy the ethhdr from first buffer to second. This
@@ -2208,15 +2087,14 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
                                                 skb_push(skb2, size), size);
        } else {
                u16 checksum = le16_to_cpu(ib_ip_rsp_ptr->checksum);
-               if (checksum & 
-                       (IB_IP_IOCB_RSP_3032_ICE | 
-                        IB_IP_IOCB_RSP_3032_CE)) { 
-                       printk(KERN_ERR
-                              "%s: Bad checksum for this %s packet, checksum = %x.\n",
-                              __func__,
-                              ((checksum & 
-                               IB_IP_IOCB_RSP_3032_TCP) ? "TCP" :
-                               "UDP"),checksum);
+               if (checksum &
+                       (IB_IP_IOCB_RSP_3032_ICE |
+                        IB_IP_IOCB_RSP_3032_CE)) {
+                       netdev_err(ndev,
+                                  "%s: Bad checksum for this %s packet, checksum = %x\n",
+                                  __func__,
+                                  ((checksum & IB_IP_IOCB_RSP_3032_TCP) ?
+                                   "TCP" : "UDP"), checksum);
                } else if ((checksum & IB_IP_IOCB_RSP_3032_TCP) ||
                                (checksum & IB_IP_IOCB_RSP_3032_UDP &&
                                !(checksum & IB_IP_IOCB_RSP_3032_NUC))) {
@@ -2226,9 +2104,8 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
        skb2->protocol = eth_type_trans(skb2, qdev->ndev);
 
        netif_receive_skb(skb2);
-       qdev->stats.rx_packets++;
-       qdev->stats.rx_bytes += length;
-       ndev->last_rx = jiffies;
+       ndev->stats.rx_packets++;
+       ndev->stats.rx_bytes += length;
        lrg_buf_cb2->skb = NULL;
 
        if (qdev->device_id == QL3022_DEVICE_ID)
@@ -2248,6 +2125,13 @@ static int ql_tx_rx_clean(struct ql3_adapter *qdev,
                qdev->rsp_consumer_index) && (work_done < work_to_do)) {
 
                net_rsp = qdev->rsp_current;
+               rmb();
+               /*
+                * Fix 4032 chip's undocumented "feature" where bit-8 is set
+                * if the inbound completion is for a VLAN.
+                */
+               if (qdev->device_id == QL3032_DEVICE_ID)
+                       net_rsp->opcode &= 0x7f;
                switch (net_rsp->opcode) {
 
                case OPCODE_OB_MAC_IOCB_FN0:
@@ -2270,22 +2154,18 @@ static int ql_tx_rx_clean(struct ql3_adapter *qdev,
                                                 net_rsp);
                        (*rx_cleaned)++;
                        break;
-               default:
-                       {
-                               u32 *tmp = (u32 *) net_rsp;
-                               printk(KERN_ERR PFX
-                                      "%s: Hit default case, not "
-                                      "handled!\n"
-                                      "        dropping the packet, opcode = "
-                                      "%x.\n",
-                                      ndev->name, net_rsp->opcode);
-                               printk(KERN_ERR PFX
-                                      "0x%08lx 0x%08lx 0x%08lx 0x%08lx \n",
-                                      (unsigned long int)tmp[0],
-                                      (unsigned long int)tmp[1],
-                                      (unsigned long int)tmp[2],
-                                      (unsigned long int)tmp[3]);
-                       }
+               default: {
+                       u32 *tmp = (u32 *)net_rsp;
+                       netdev_err(ndev,
+                                  "Hit default case, not handled!\n"
+                                  "    dropping the packet, opcode = %x\n"
+                                  "0x%08lx 0x%08lx 0x%08lx 0x%08lx\n",
+                                  net_rsp->opcode,
+                                  (unsigned long int)tmp[0],
+                                  (unsigned long int)tmp[1],
+                                  (unsigned long int)tmp[2],
+                                  (unsigned long int)tmp[3]);
+               }
                }
 
                qdev->rsp_consumer_index++;
@@ -2303,27 +2183,19 @@ static int ql_tx_rx_clean(struct ql3_adapter *qdev,
        return work_done;
 }
 
-static int ql_poll(struct net_device *ndev, int *budget)
+static int ql_poll(struct napi_struct *napi, int budget)
 {
-       struct ql3_adapter *qdev = netdev_priv(ndev);
-       int work_to_do = min(*budget, ndev->quota);
+       struct ql3_adapter *qdev = container_of(napi, struct ql3_adapter, napi);
        int rx_cleaned = 0, tx_cleaned = 0;
        unsigned long hw_flags;
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
-
-       if (!netif_carrier_ok(ndev))
-               goto quit_polling;
-
-       ql_tx_rx_clean(qdev, &tx_cleaned, &rx_cleaned, work_to_do);
-       *budget -= rx_cleaned;
-       ndev->quota -= rx_cleaned;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
 
-       if( tx_cleaned + rx_cleaned != work_to_do ||
-           !netif_running(ndev)) {
-quit_polling:
-               netif_rx_complete(ndev);
+       ql_tx_rx_clean(qdev, &tx_cleaned, &rx_cleaned, budget);
 
+       if (tx_cleaned + rx_cleaned != budget) {
                spin_lock_irqsave(&qdev->hw_lock, hw_flags);
+               __napi_complete(napi);
                ql_update_small_bufq_prod_index(qdev);
                ql_update_lrg_bufq_prod_index(qdev);
                writel(qdev->rsp_consumer_index,
@@ -2331,9 +2203,8 @@ quit_polling:
                spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
 
                ql_enable_interrupts(qdev);
-               return 0;
        }
-       return 1;
+       return tx_cleaned + rx_cleaned;
 }
 
 static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
@@ -2341,15 +2212,14 @@ static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
 
        struct net_device *ndev = dev_id;
        struct ql3_adapter *qdev = netdev_priv(ndev);
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
        u32 value;
        int handled = 1;
        u32 var;
 
-       port_regs = qdev->mem_map_registers;
-
-       value =
-           ql_read_common_reg_l(qdev, &port_regs->CommonRegs.ispControlStatus);
+       value = ql_read_common_reg_l(qdev,
+                                    &port_regs->CommonRegs.ispControlStatus);
 
        if (value & (ISP_CONTROL_FE | ISP_CONTROL_RI)) {
                spin_lock(&qdev->adapter_lock);
@@ -2357,7 +2227,7 @@ static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
                netif_carrier_off(qdev->ndev);
                ql_disable_interrupts(qdev);
                qdev->port_link_state = LS_DOWN;
-               set_bit(QL_RESET_ACTIVE,&qdev->flags) ;
+               set_bit(QL_RESET_ACTIVE, &qdev->flags) ;
 
                if (value & ISP_CONTROL_FE) {
                        /*
@@ -2366,69 +2236,53 @@ static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
                        var =
                            ql_read_page0_reg_l(qdev,
                                              &port_regs->PortFatalErrStatus);
-                       printk(KERN_WARNING PFX
-                              "%s: Resetting chip. PortFatalErrStatus "
-                              "register = 0x%x\n", ndev->name, var);
-                       set_bit(QL_RESET_START,&qdev->flags) ;
+                       netdev_warn(ndev,
+                                   "Resetting chip. PortFatalErrStatus register = 0x%x\n",
+                                   var);
+                       set_bit(QL_RESET_START, &qdev->flags) ;
                } else {
                        /*
                         * Soft Reset Requested.
                         */
-                       set_bit(QL_RESET_PER_SCSI,&qdev->flags) ;
-                       printk(KERN_ERR PFX
-                              "%s: Another function issued a reset to the "
-                              "chip. ISR value = %x.\n", ndev->name, value);
+                       set_bit(QL_RESET_PER_SCSI, &qdev->flags) ;
+                       netdev_err(ndev,
+                                  "Another function issued a reset to the chip. ISR value = %x\n",
+                                  value);
                }
                queue_delayed_work(qdev->workqueue, &qdev->reset_work, 0);
                spin_unlock(&qdev->adapter_lock);
        } else if (value & ISP_IMR_DISABLE_CMPL_INT) {
                ql_disable_interrupts(qdev);
-               if (likely(netif_rx_schedule_prep(ndev))) {
-                       __netif_rx_schedule(ndev);
-               }
-       } else {
+               if (likely(napi_schedule_prep(&qdev->napi)))
+                       __napi_schedule(&qdev->napi);
+       } else
                return IRQ_NONE;
-       }
 
        return IRQ_RETVAL(handled);
 }
 
 /*
- * Get the total number of segments needed for the 
- * given number of fragments.  This is necessary because
- * outbound address lists (OAL) will be used when more than
- * two frags are given.  Each address list has 5 addr/len 
- * pairs.  The 5th pair in each AOL is used to  point to
- * the next AOL if more frags are coming.  
- * That is why the frags:segment count  ratio is not linear.
+ * Get the total number of segments needed for the given number of fragments.
+ * This is necessary because outbound address lists (OAL) will be used when
+ * more than two frags are given.  Each address list has 5 addr/len pairs.
+ * The 5th pair in each OAL is used to  point to the next OAL if more frags
+ * are coming.  That is why the frags:segment count ratio is not linear.
  */
-static int ql_get_seg_count(struct ql3_adapter *qdev,
-                           unsigned short frags)
+static int ql_get_seg_count(struct ql3_adapter *qdev, unsigned short frags)
 {
        if (qdev->device_id == QL3022_DEVICE_ID)
                return 1;
 
-       switch(frags) {
-       case 0: return 1;       /* just the skb->data seg */
-       case 1: return 2;       /* skb->data + 1 frag */
-       case 2: return 3;       /* skb->data + 2 frags */
-       case 3: return 5;       /* skb->data + 1 frag + 1 AOL containting 2 frags */
-       case 4: return 6;
-       case 5: return 7;
-       case 6: return 8;
-       case 7: return 10;
-       case 8: return 11;
-       case 9: return 12;
-       case 10: return 13;
-       case 11: return 15;
-       case 12: return 16;
-       case 13: return 17;
-       case 14: return 18;
-       case 15: return 20;
-       case 16: return 21;
-       case 17: return 22;
-       case 18: return 23;
-       }
+       if (frags <= 2)
+               return frags + 1;
+       else if (frags <= 6)
+               return frags + 2;
+       else if (frags <= 10)
+               return frags + 3;
+       else if (frags <= 14)
+               return frags + 4;
+       else if (frags <= 18)
+               return frags + 5;
        return -1;
 }
 
@@ -2451,8 +2305,8 @@ static void ql_hw_csum_setup(const struct sk_buff *skb,
 }
 
 /*
- * Map the buffers for this transmit.  This will return
- * NETDEV_TX_BUSY or NETDEV_TX_OK based on success.
+ * Map the buffers for this transmit.
+ * This will return NETDEV_TX_BUSY or NETDEV_TX_OK based on success.
  */
 static int ql_send_map(struct ql3_adapter *qdev,
                                struct ob_mac_iocb_req *mac_iocb_ptr,
@@ -2474,121 +2328,126 @@ static int ql_send_map(struct ql3_adapter *qdev,
         */
        map = pci_map_single(qdev->pdev, skb->data, len, PCI_DMA_TODEVICE);
 
-       err = pci_dma_mapping_error(map);
-       if(err) {
-               printk(KERN_ERR "%s: PCI mapping failed with error: %d\n", 
-                      qdev->ndev->name, err);
+       err = pci_dma_mapping_error(qdev->pdev, map);
+       if (err) {
+               netdev_err(qdev->ndev, "PCI mapping failed with error: %d\n",
+                          err);
 
                return NETDEV_TX_BUSY;
        }
-       
+
        oal_entry = (struct oal_entry *)&mac_iocb_ptr->buf_addr0_low;
        oal_entry->dma_lo = cpu_to_le32(LS_64BITS(map));
        oal_entry->dma_hi = cpu_to_le32(MS_64BITS(map));
        oal_entry->len = cpu_to_le32(len);
-       pci_unmap_addr_set(&tx_cb->map[seg], mapaddr, map);
-       pci_unmap_len_set(&tx_cb->map[seg], maplen, len);
+       dma_unmap_addr_set(&tx_cb->map[seg], mapaddr, map);
+       dma_unmap_len_set(&tx_cb->map[seg], maplen, len);
        seg++;
 
        if (seg_cnt == 1) {
                /* Terminate the last segment. */
-               oal_entry->len =
-                   cpu_to_le32(le32_to_cpu(oal_entry->len) | OAL_LAST_ENTRY);
-       } else {
-               oal = tx_cb->oal;
-               for (completed_segs=0; completed_segs<frag_cnt; completed_segs++,seg++) {
-                       skb_frag_t *frag = &skb_shinfo(skb)->frags[completed_segs];
-                       oal_entry++;
-                       if ((seg == 2 && seg_cnt > 3) ||        /* Check for continuation */
-                           (seg == 7 && seg_cnt > 8) ||        /* requirements. It's strange */
-                           (seg == 12 && seg_cnt > 13) ||      /* but necessary. */
-                           (seg == 17 && seg_cnt > 18)) {
-                               /* Continuation entry points to outbound address list. */
-                               map = pci_map_single(qdev->pdev, oal,
-                                                    sizeof(struct oal),
-                                                    PCI_DMA_TODEVICE);
-
-                               err = pci_dma_mapping_error(map);
-                               if(err) {
-
-                                       printk(KERN_ERR "%s: PCI mapping outbound address list with error: %d\n", 
-                                              qdev->ndev->name, err);
-                                       goto map_error;
-                               }
-
-                               oal_entry->dma_lo = cpu_to_le32(LS_64BITS(map));
-                               oal_entry->dma_hi = cpu_to_le32(MS_64BITS(map));
-                               oal_entry->len =
-                                   cpu_to_le32(sizeof(struct oal) |
-                                               OAL_CONT_ENTRY);
-                               pci_unmap_addr_set(&tx_cb->map[seg], mapaddr,
-                                                  map);
-                               pci_unmap_len_set(&tx_cb->map[seg], maplen,
-                                                 sizeof(struct oal));
-                               oal_entry = (struct oal_entry *)oal;
-                               oal++;
-                               seg++;
-                       }
-
-                       map =
-                           pci_map_page(qdev->pdev, frag->page,
-                                        frag->page_offset, frag->size,
-                                        PCI_DMA_TODEVICE);
-
-                       err = pci_dma_mapping_error(map);
-                       if(err) {
-                               printk(KERN_ERR "%s: PCI mapping frags failed with error: %d\n", 
-                                      qdev->ndev->name, err);
+               oal_entry->len |= cpu_to_le32(OAL_LAST_ENTRY);
+               return NETDEV_TX_OK;
+       }
+       oal = tx_cb->oal;
+       for (completed_segs = 0;
+            completed_segs < frag_cnt;
+            completed_segs++, seg++) {
+               skb_frag_t *frag = &skb_shinfo(skb)->frags[completed_segs];
+               oal_entry++;
+               /*
+                * Check for continuation requirements.
+                * It's strange but necessary.
+                * Continuation entry points to outbound address list.
+                */
+               if ((seg == 2 && seg_cnt > 3) ||
+                   (seg == 7 && seg_cnt > 8) ||
+                   (seg == 12 && seg_cnt > 13) ||
+                   (seg == 17 && seg_cnt > 18)) {
+                       map = pci_map_single(qdev->pdev, oal,
+                                            sizeof(struct oal),
+                                            PCI_DMA_TODEVICE);
+
+                       err = pci_dma_mapping_error(qdev->pdev, map);
+                       if (err) {
+                               netdev_err(qdev->ndev,
+                                          "PCI mapping outbound address list with error: %d\n",
+                                          err);
                                goto map_error;
                        }
 
                        oal_entry->dma_lo = cpu_to_le32(LS_64BITS(map));
                        oal_entry->dma_hi = cpu_to_le32(MS_64BITS(map));
-                       oal_entry->len = cpu_to_le32(frag->size);
-                       pci_unmap_addr_set(&tx_cb->map[seg], mapaddr, map);
-                       pci_unmap_len_set(&tx_cb->map[seg], maplen,
-                                         frag->size);
+                       oal_entry->len = cpu_to_le32(sizeof(struct oal) |
+                                                    OAL_CONT_ENTRY);
+                       dma_unmap_addr_set(&tx_cb->map[seg], mapaddr, map);
+                       dma_unmap_len_set(&tx_cb->map[seg], maplen,
+                                         sizeof(struct oal));
+                       oal_entry = (struct oal_entry *)oal;
+                       oal++;
+                       seg++;
+               }
+
+               map = pci_map_page(qdev->pdev, frag->page,
+                                  frag->page_offset, frag->size,
+                                  PCI_DMA_TODEVICE);
+
+               err = pci_dma_mapping_error(qdev->pdev, map);
+               if (err) {
+                       netdev_err(qdev->ndev,
+                                  "PCI mapping frags failed with error: %d\n",
+                                  err);
+                       goto map_error;
                }
-               /* Terminate the last segment. */
-               oal_entry->len =
-                   cpu_to_le32(le32_to_cpu(oal_entry->len) | OAL_LAST_ENTRY);
-       }
 
+               oal_entry->dma_lo = cpu_to_le32(LS_64BITS(map));
+               oal_entry->dma_hi = cpu_to_le32(MS_64BITS(map));
+               oal_entry->len = cpu_to_le32(frag->size);
+               dma_unmap_addr_set(&tx_cb->map[seg], mapaddr, map);
+               dma_unmap_len_set(&tx_cb->map[seg], maplen, frag->size);
+               }
+       /* Terminate the last segment. */
+       oal_entry->len |= cpu_to_le32(OAL_LAST_ENTRY);
        return NETDEV_TX_OK;
 
 map_error:
        /* A PCI mapping failed and now we will need to back out
-        * We need to traverse through the oal's and associated pages which 
+        * We need to traverse through the oal's and associated pages which
         * have been mapped and now we must unmap them to clean up properly
         */
-       
+
        seg = 1;
        oal_entry = (struct oal_entry *)&mac_iocb_ptr->buf_addr0_low;
        oal = tx_cb->oal;
-       for (i=0; i<completed_segs; i++,seg++) {
+       for (i = 0; i < completed_segs; i++, seg++) {
                oal_entry++;
 
-               if((seg == 2 && seg_cnt > 3) ||        /* Check for continuation */
-                  (seg == 7 && seg_cnt > 8) ||        /* requirements. It's strange */
-                  (seg == 12 && seg_cnt > 13) ||      /* but necessary. */
-                  (seg == 17 && seg_cnt > 18)) {
+               /*
+                * Check for continuation requirements.
+                * It's strange but necessary.
+                */
+
+               if ((seg == 2 && seg_cnt > 3) ||
+                   (seg == 7 && seg_cnt > 8) ||
+                   (seg == 12 && seg_cnt > 13) ||
+                   (seg == 17 && seg_cnt > 18)) {
                        pci_unmap_single(qdev->pdev,
-                               pci_unmap_addr(&tx_cb->map[seg], mapaddr),
-                               pci_unmap_len(&tx_cb->map[seg], maplen),
+                               dma_unmap_addr(&tx_cb->map[seg], mapaddr),
+                               dma_unmap_len(&tx_cb->map[seg], maplen),
                                 PCI_DMA_TODEVICE);
                        oal++;
                        seg++;
                }
 
                pci_unmap_page(qdev->pdev,
-                              pci_unmap_addr(&tx_cb->map[seg], mapaddr),
-                              pci_unmap_len(&tx_cb->map[seg], maplen),
+                              dma_unmap_addr(&tx_cb->map[seg], mapaddr),
+                              dma_unmap_len(&tx_cb->map[seg], maplen),
                               PCI_DMA_TODEVICE);
        }
 
        pci_unmap_single(qdev->pdev,
-                        pci_unmap_addr(&tx_cb->map[0], mapaddr),
-                        pci_unmap_addr(&tx_cb->map[0], maplen),
+                        dma_unmap_addr(&tx_cb->map[0], mapaddr),
+                        dma_unmap_addr(&tx_cb->map[0], maplen),
                         PCI_DMA_TODEVICE);
 
        return NETDEV_TX_BUSY;
@@ -2599,32 +2458,34 @@ map_error:
  * The difference between 3022 and 3032 sends:
  * 3022 only supports a simple single segment transmission.
  * 3032 supports checksumming and scatter/gather lists (fragments).
- * The 3032 supports sglists by using the 3 addr/len pairs (ALP) 
- * in the IOCB plus a chain of outbound address lists (OAL) that 
- * each contain 5 ALPs.  The last ALP of the IOCB (3rd) or OAL (5th) 
- * will used to point to an OAL when more ALP entries are required.  
- * The IOCB is always the top of the chain followed by one or more 
+ * The 3032 supports sglists by using the 3 addr/len pairs (ALP)
+ * in the IOCB plus a chain of outbound address lists (OAL) that
+ * each contain 5 ALPs.  The last ALP of the IOCB (3rd) or OAL (5th)
+ * will be used to point to an OAL when more ALP entries are required.
+ * The IOCB is always the top of the chain followed by one or more
  * OALs (when necessary).
  */
-static int ql3xxx_send(struct sk_buff *skb, struct net_device *ndev)
+static netdev_tx_t ql3xxx_send(struct sk_buff *skb,
+                              struct net_device *ndev)
 {
-       struct ql3_adapter *qdev = (struct ql3_adapter *)netdev_priv(ndev);
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3_adapter *qdev = netdev_priv(ndev);
+       struct ql3xxx_port_registers __iomem *port_regs =
+                       qdev->mem_map_registers;
        struct ql_tx_buf_cb *tx_cb;
        u32 tot_len = skb->len;
        struct ob_mac_iocb_req *mac_iocb_ptr;
 
-       if (unlikely(atomic_read(&qdev->tx_count) < 2)) {
+       if (unlikely(atomic_read(&qdev->tx_count) < 2))
                return NETDEV_TX_BUSY;
-       }
-       
-       tx_cb = &qdev->tx_buf[qdev->req_producer_index] ;
-       if((tx_cb->seg_count = ql_get_seg_count(qdev,
-                                               (skb_shinfo(skb)->nr_frags))) == -1) {
-               printk(KERN_ERR PFX"%s: invalid segment count!\n",__func__);
+
+       tx_cb = &qdev->tx_buf[qdev->req_producer_index];
+       tx_cb->seg_count = ql_get_seg_count(qdev,
+                                            skb_shinfo(skb)->nr_frags);
+       if (tx_cb->seg_count == -1) {
+               netdev_err(ndev, "%s: invalid segment count!\n", __func__);
                return NETDEV_TX_OK;
        }
-       
+
        mac_iocb_ptr = tx_cb->queue_entry;
        memset((void *)mac_iocb_ptr, 0, sizeof(struct ob_mac_iocb_req));
        mac_iocb_ptr->opcode = qdev->mac_ob_opcode;
@@ -2636,12 +2497,12 @@ static int ql3xxx_send(struct sk_buff *skb, struct net_device *ndev)
        if (qdev->device_id == QL3032_DEVICE_ID &&
            skb->ip_summed == CHECKSUM_PARTIAL)
                ql_hw_csum_setup(skb, mac_iocb_ptr);
-       
-       if(ql_send_map(qdev,mac_iocb_ptr,tx_cb,skb) != NETDEV_TX_OK) {
-               printk(KERN_ERR PFX"%s: Could not map the segments!\n",__func__);
+
+       if (ql_send_map(qdev, mac_iocb_ptr, tx_cb, skb) != NETDEV_TX_OK) {
+               netdev_err(ndev, "%s: Could not map the segments!\n", __func__);
                return NETDEV_TX_BUSY;
        }
-       
+
        wmb();
        qdev->req_producer_index++;
        if (qdev->req_producer_index == NUM_REQ_Q_ENTRIES)
@@ -2651,10 +2512,9 @@ static int ql3xxx_send(struct sk_buff *skb, struct net_device *ndev)
                            &port_regs->CommonRegs.reqQProducerIndex,
                            qdev->req_producer_index);
 
-       ndev->trans_start = jiffies;
-       if (netif_msg_tx_queued(qdev))
-               printk(KERN_DEBUG PFX "%s: tx queued, slot %d, len %d\n",
-                      ndev->name, qdev->req_producer_index, skb->len);
+       netif_printk(qdev, tx_queued, KERN_DEBUG, ndev,
+                    "tx queued, slot %d, len %d\n",
+                    qdev->req_producer_index, skb->len);
 
        atomic_dec(&qdev->tx_count);
        return NETDEV_TX_OK;
@@ -2672,8 +2532,7 @@ static int ql_alloc_net_req_rsp_queues(struct ql3_adapter *qdev)
 
        if ((qdev->req_q_virt_addr == NULL) ||
            LS_64BITS(qdev->req_q_phy_addr) & (qdev->req_q_size - 1)) {
-               printk(KERN_ERR PFX "%s: reqQ failed.\n",
-                      qdev->ndev->name);
+               netdev_err(qdev->ndev, "reqQ failed\n");
                return -ENOMEM;
        }
 
@@ -2686,25 +2545,22 @@ static int ql_alloc_net_req_rsp_queues(struct ql3_adapter *qdev)
 
        if ((qdev->rsp_q_virt_addr == NULL) ||
            LS_64BITS(qdev->rsp_q_phy_addr) & (qdev->rsp_q_size - 1)) {
-               printk(KERN_ERR PFX
-                      "%s: rspQ allocation failed\n",
-                      qdev->ndev->name);
+               netdev_err(qdev->ndev, "rspQ allocation failed\n");
                pci_free_consistent(qdev->pdev, (size_t) qdev->req_q_size,
                                    qdev->req_q_virt_addr,
                                    qdev->req_q_phy_addr);
                return -ENOMEM;
        }
 
-       set_bit(QL_ALLOC_REQ_RSP_Q_DONE,&qdev->flags);
+       set_bit(QL_ALLOC_REQ_RSP_Q_DONE, &qdev->flags);
 
        return 0;
 }
 
 static void ql_free_net_req_rsp_queues(struct ql3_adapter *qdev)
 {
-       if (!test_bit(QL_ALLOC_REQ_RSP_Q_DONE,&qdev->flags)) {
-               printk(KERN_INFO PFX
-                      "%s: Already done.\n", qdev->ndev->name);
+       if (!test_bit(QL_ALLOC_REQ_RSP_Q_DONE, &qdev->flags)) {
+               netdev_info(qdev->ndev, "Already done\n");
                return;
        }
 
@@ -2720,34 +2576,34 @@ static void ql_free_net_req_rsp_queues(struct ql3_adapter *qdev)
 
        qdev->rsp_q_virt_addr = NULL;
 
-       clear_bit(QL_ALLOC_REQ_RSP_Q_DONE,&qdev->flags);
+       clear_bit(QL_ALLOC_REQ_RSP_Q_DONE, &qdev->flags);
 }
 
 static int ql_alloc_buffer_queues(struct ql3_adapter *qdev)
 {
        /* Create Large Buffer Queue */
        qdev->lrg_buf_q_size =
-           qdev->num_lbufq_entries * sizeof(struct lrg_buf_q_entry);
+               qdev->num_lbufq_entries * sizeof(struct lrg_buf_q_entry);
        if (qdev->lrg_buf_q_size < PAGE_SIZE)
                qdev->lrg_buf_q_alloc_size = PAGE_SIZE;
        else
                qdev->lrg_buf_q_alloc_size = qdev->lrg_buf_q_size * 2;
 
-       qdev->lrg_buf = kmalloc(qdev->num_large_buffers * sizeof(struct ql_rcv_buf_cb),GFP_KERNEL);
+       qdev->lrg_buf =
+               kmalloc(qdev->num_large_buffers * sizeof(struct ql_rcv_buf_cb),
+                       GFP_KERNEL);
        if (qdev->lrg_buf == NULL) {
-               printk(KERN_ERR PFX
-                      "%s: qdev->lrg_buf alloc failed.\n", qdev->ndev->name);
+               netdev_err(qdev->ndev, "qdev->lrg_buf alloc failed\n");
                return -ENOMEM;
        }
-       
+
        qdev->lrg_buf_q_alloc_virt_addr =
-           pci_alloc_consistent(qdev->pdev,
-                                qdev->lrg_buf_q_alloc_size,
-                                &qdev->lrg_buf_q_alloc_phy_addr);
+               pci_alloc_consistent(qdev->pdev,
+                                    qdev->lrg_buf_q_alloc_size,
+                                    &qdev->lrg_buf_q_alloc_phy_addr);
 
        if (qdev->lrg_buf_q_alloc_virt_addr == NULL) {
-               printk(KERN_ERR PFX
-                      "%s: lBufQ failed\n", qdev->ndev->name);
+               netdev_err(qdev->ndev, "lBufQ failed\n");
                return -ENOMEM;
        }
        qdev->lrg_buf_q_virt_addr = qdev->lrg_buf_q_alloc_virt_addr;
@@ -2755,21 +2611,19 @@ static int ql_alloc_buffer_queues(struct ql3_adapter *qdev)
 
        /* Create Small Buffer Queue */
        qdev->small_buf_q_size =
-           NUM_SBUFQ_ENTRIES * sizeof(struct lrg_buf_q_entry);
+               NUM_SBUFQ_ENTRIES * sizeof(struct lrg_buf_q_entry);
        if (qdev->small_buf_q_size < PAGE_SIZE)
                qdev->small_buf_q_alloc_size = PAGE_SIZE;
        else
                qdev->small_buf_q_alloc_size = qdev->small_buf_q_size * 2;
 
        qdev->small_buf_q_alloc_virt_addr =
-           pci_alloc_consistent(qdev->pdev,
-                                qdev->small_buf_q_alloc_size,
-                                &qdev->small_buf_q_alloc_phy_addr);
+               pci_alloc_consistent(qdev->pdev,
+                                    qdev->small_buf_q_alloc_size,
+                                    &qdev->small_buf_q_alloc_phy_addr);
 
        if (qdev->small_buf_q_alloc_virt_addr == NULL) {
-               printk(KERN_ERR PFX
-                      "%s: Small Buffer Queue allocation failed.\n",
-                      qdev->ndev->name);
+               netdev_err(qdev->ndev, "Small Buffer Queue allocation failed\n");
                pci_free_consistent(qdev->pdev, qdev->lrg_buf_q_alloc_size,
                                    qdev->lrg_buf_q_alloc_virt_addr,
                                    qdev->lrg_buf_q_alloc_phy_addr);
@@ -2778,18 +2632,17 @@ static int ql_alloc_buffer_queues(struct ql3_adapter *qdev)
 
        qdev->small_buf_q_virt_addr = qdev->small_buf_q_alloc_virt_addr;
        qdev->small_buf_q_phy_addr = qdev->small_buf_q_alloc_phy_addr;
-       set_bit(QL_ALLOC_BUFQS_DONE,&qdev->flags);
+       set_bit(QL_ALLOC_BUFQS_DONE, &qdev->flags);
        return 0;
 }
 
 static void ql_free_buffer_queues(struct ql3_adapter *qdev)
 {
-       if (!test_bit(QL_ALLOC_BUFQS_DONE,&qdev->flags)) {
-               printk(KERN_INFO PFX
-                      "%s: Already done.\n", qdev->ndev->name);
+       if (!test_bit(QL_ALLOC_BUFQS_DONE, &qdev->flags)) {
+               netdev_info(qdev->ndev, "Already done\n");
                return;
        }
-       if(qdev->lrg_buf) kfree(qdev->lrg_buf);
+       kfree(qdev->lrg_buf);
        pci_free_consistent(qdev->pdev,
                            qdev->lrg_buf_q_alloc_size,
                            qdev->lrg_buf_q_alloc_virt_addr,
@@ -2804,7 +2657,7 @@ static void ql_free_buffer_queues(struct ql3_adapter *qdev)
 
        qdev->small_buf_q_virt_addr = NULL;
 
-       clear_bit(QL_ALLOC_BUFQS_DONE,&qdev->flags);
+       clear_bit(QL_ALLOC_BUFQS_DONE, &qdev->flags);
 }
 
 static int ql_alloc_small_buffers(struct ql3_adapter *qdev)
@@ -2814,18 +2667,16 @@ static int ql_alloc_small_buffers(struct ql3_adapter *qdev)
 
        /* Currently we allocate on one of memory and use it for smallbuffers */
        qdev->small_buf_total_size =
-           (QL_ADDR_ELE_PER_BUFQ_ENTRY * NUM_SBUFQ_ENTRIES *
-            QL_SMALL_BUFFER_SIZE);
+               (QL_ADDR_ELE_PER_BUFQ_ENTRY * NUM_SBUFQ_ENTRIES *
+                QL_SMALL_BUFFER_SIZE);
 
        qdev->small_buf_virt_addr =
-           pci_alloc_consistent(qdev->pdev,
-                                qdev->small_buf_total_size,
-                                &qdev->small_buf_phy_addr);
+               pci_alloc_consistent(qdev->pdev,
+                                    qdev->small_buf_total_size,
+                                    &qdev->small_buf_phy_addr);
 
        if (qdev->small_buf_virt_addr == NULL) {
-               printk(KERN_ERR PFX
-                      "%s: Failed to get small buffer memory.\n",
-                      qdev->ndev->name);
+               netdev_err(qdev->ndev, "Failed to get small buffer memory\n");
                return -ENOMEM;
        }
 
@@ -2844,15 +2695,14 @@ static int ql_alloc_small_buffers(struct ql3_adapter *qdev)
                small_buf_q_entry++;
        }
        qdev->small_buf_index = 0;
-       set_bit(QL_ALLOC_SMALL_BUF_DONE,&qdev->flags);
+       set_bit(QL_ALLOC_SMALL_BUF_DONE, &qdev->flags);
        return 0;
 }
 
 static void ql_free_small_buffers(struct ql3_adapter *qdev)
 {
-       if (!test_bit(QL_ALLOC_SMALL_BUF_DONE,&qdev->flags)) {
-               printk(KERN_INFO PFX
-                      "%s: Already done.\n", qdev->ndev->name);
+       if (!test_bit(QL_ALLOC_SMALL_BUF_DONE, &qdev->flags)) {
+               netdev_info(qdev->ndev, "Already done\n");
                return;
        }
        if (qdev->small_buf_virt_addr != NULL) {
@@ -2875,8 +2725,8 @@ static void ql_free_large_buffers(struct ql3_adapter *qdev)
                if (lrg_buf_cb->skb) {
                        dev_kfree_skb(lrg_buf_cb->skb);
                        pci_unmap_single(qdev->pdev,
-                                        pci_unmap_addr(lrg_buf_cb, mapaddr),
-                                        pci_unmap_len(lrg_buf_cb, maplen),
+                                        dma_unmap_addr(lrg_buf_cb, mapaddr),
+                                        dma_unmap_len(lrg_buf_cb, maplen),
                                         PCI_DMA_FROMDEVICE);
                        memset(lrg_buf_cb, 0, sizeof(struct ql_rcv_buf_cb));
                } else {
@@ -2914,11 +2764,9 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
                                       qdev->lrg_buffer_len);
                if (unlikely(!skb)) {
                        /* Better luck next round */
-                       printk(KERN_ERR PFX
-                              "%s: large buff alloc failed, "
-                              "for %d bytes at index %d.\n",
-                              qdev->ndev->name,
-                              qdev->lrg_buffer_len * 2, i);
+                       netdev_err(qdev->ndev,
+                                  "large buff alloc failed for %d bytes at index %d\n",
+                                  qdev->lrg_buffer_len * 2, i);
                        ql_free_large_buffers(qdev);
                        return -ENOMEM;
                } else {
@@ -2938,16 +2786,17 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
                                             QL_HEADER_SPACE,
                                             PCI_DMA_FROMDEVICE);
 
-                       err = pci_dma_mapping_error(map);
-                       if(err) {
-                               printk(KERN_ERR "%s: PCI mapping failed with error: %d\n",
-                                      qdev->ndev->name, err);
+                       err = pci_dma_mapping_error(qdev->pdev, map);
+                       if (err) {
+                               netdev_err(qdev->ndev,
+                                          "PCI mapping failed with error: %d\n",
+                                          err);
                                ql_free_large_buffers(qdev);
                                return -ENOMEM;
                        }
 
-                       pci_unmap_addr_set(lrg_buf_cb, mapaddr, map);
-                       pci_unmap_len_set(lrg_buf_cb, maplen,
+                       dma_unmap_addr_set(lrg_buf_cb, mapaddr, map);
+                       dma_unmap_len_set(lrg_buf_cb, maplen,
                                          qdev->lrg_buffer_len -
                                          QL_HEADER_SPACE);
                        lrg_buf_cb->buf_phy_addr_low =
@@ -2966,10 +2815,8 @@ static void ql_free_send_free_list(struct ql3_adapter *qdev)
 
        tx_cb = &qdev->tx_buf[0];
        for (i = 0; i < NUM_REQ_Q_ENTRIES; i++) {
-               if (tx_cb->oal) {
-                       kfree(tx_cb->oal);
-                       tx_cb->oal = NULL;
-               }
+               kfree(tx_cb->oal);
+               tx_cb->oal = NULL;
                tx_cb++;
        }
 }
@@ -2978,8 +2825,7 @@ static int ql_create_send_free_list(struct ql3_adapter *qdev)
 {
        struct ql_tx_buf_cb *tx_cb;
        int i;
-       struct ob_mac_iocb_req *req_q_curr =
-                                       qdev->req_q_virt_addr;
+       struct ob_mac_iocb_req *req_q_curr = qdev->req_q_virt_addr;
 
        /* Create free list of transmit buffers */
        for (i = 0; i < NUM_REQ_Q_ENTRIES; i++) {
@@ -3000,23 +2846,22 @@ static int ql_alloc_mem_resources(struct ql3_adapter *qdev)
        if (qdev->ndev->mtu == NORMAL_MTU_SIZE) {
                qdev->num_lbufq_entries = NUM_LBUFQ_ENTRIES;
                qdev->lrg_buffer_len = NORMAL_MTU_SIZE;
-       }
-       else if (qdev->ndev->mtu == JUMBO_MTU_SIZE) {
+       } else if (qdev->ndev->mtu == JUMBO_MTU_SIZE) {
                /*
                 * Bigger buffers, so less of them.
                 */
                qdev->num_lbufq_entries = JUMBO_NUM_LBUFQ_ENTRIES;
                qdev->lrg_buffer_len = JUMBO_MTU_SIZE;
        } else {
-               printk(KERN_ERR PFX
-                      "%s: Invalid mtu size.  Only 1500 and 9000 are accepted.\n",
-                      qdev->ndev->name);
+               netdev_err(qdev->ndev, "Invalid mtu size: %d.  Only %d and %d are accepted.\n",
+                          qdev->ndev->mtu, NORMAL_MTU_SIZE, JUMBO_MTU_SIZE);
                return -ENOMEM;
        }
-       qdev->num_large_buffers = qdev->num_lbufq_entries * QL_ADDR_ELE_PER_BUFQ_ENTRY;
+       qdev->num_large_buffers =
+               qdev->num_lbufq_entries * QL_ADDR_ELE_PER_BUFQ_ENTRY;
        qdev->lrg_buffer_len += VLAN_ETH_HLEN + VLAN_ID_LEN + QL_HEADER_SPACE;
        qdev->max_frame_size =
-           (qdev->lrg_buffer_len - QL_HEADER_SPACE) + ETHERNET_CRC_SIZE;
+               (qdev->lrg_buffer_len - QL_HEADER_SPACE) + ETHERNET_CRC_SIZE;
 
        /*
         * First allocate a page of shared memory and use it for shadow
@@ -3024,51 +2869,44 @@ static int ql_alloc_mem_resources(struct ql3_adapter *qdev)
         * Network Completion Queue Producer Index Register
         */
        qdev->shadow_reg_virt_addr =
-           pci_alloc_consistent(qdev->pdev,
-                                PAGE_SIZE, &qdev->shadow_reg_phy_addr);
+               pci_alloc_consistent(qdev->pdev,
+                                    PAGE_SIZE, &qdev->shadow_reg_phy_addr);
 
        if (qdev->shadow_reg_virt_addr != NULL) {
-               qdev->preq_consumer_index = (u16 *) qdev->shadow_reg_virt_addr;
+               qdev->preq_consumer_index = qdev->shadow_reg_virt_addr;
                qdev->req_consumer_index_phy_addr_high =
-                   MS_64BITS(qdev->shadow_reg_phy_addr);
+                       MS_64BITS(qdev->shadow_reg_phy_addr);
                qdev->req_consumer_index_phy_addr_low =
-                   LS_64BITS(qdev->shadow_reg_phy_addr);
+                       LS_64BITS(qdev->shadow_reg_phy_addr);
 
                qdev->prsp_producer_index =
-                   (u32 *) (((u8 *) qdev->preq_consumer_index) + 8);
+                       (__le32 *) (((u8 *) qdev->preq_consumer_index) + 8);
                qdev->rsp_producer_index_phy_addr_high =
-                   qdev->req_consumer_index_phy_addr_high;
+                       qdev->req_consumer_index_phy_addr_high;
                qdev->rsp_producer_index_phy_addr_low =
-                   qdev->req_consumer_index_phy_addr_low + 8;
+                       qdev->req_consumer_index_phy_addr_low + 8;
        } else {
-               printk(KERN_ERR PFX
-                      "%s: shadowReg Alloc failed.\n", qdev->ndev->name);
+               netdev_err(qdev->ndev, "shadowReg Alloc failed\n");
                return -ENOMEM;
        }
 
        if (ql_alloc_net_req_rsp_queues(qdev) != 0) {
-               printk(KERN_ERR PFX
-                      "%s: ql_alloc_net_req_rsp_queues failed.\n",
-                      qdev->ndev->name);
+               netdev_err(qdev->ndev, "ql_alloc_net_req_rsp_queues failed\n");
                goto err_req_rsp;
        }
 
        if (ql_alloc_buffer_queues(qdev) != 0) {
-               printk(KERN_ERR PFX
-                      "%s: ql_alloc_buffer_queues failed.\n",
-                      qdev->ndev->name);
+               netdev_err(qdev->ndev, "ql_alloc_buffer_queues failed\n");
                goto err_buffer_queues;
        }
 
        if (ql_alloc_small_buffers(qdev) != 0) {
-               printk(KERN_ERR PFX
-                      "%s: ql_alloc_small_buffers failed\n", qdev->ndev->name);
+               netdev_err(qdev->ndev, "ql_alloc_small_buffers failed\n");
                goto err_small_buffers;
        }
 
        if (ql_alloc_large_buffers(qdev) != 0) {
-               printk(KERN_ERR PFX
-                      "%s: ql_alloc_large_buffers failed\n", qdev->ndev->name);
+               netdev_err(qdev->ndev, "ql_alloc_large_buffers failed\n");
                goto err_small_buffers;
        }
 
@@ -3116,7 +2954,7 @@ static int ql_init_misc_registers(struct ql3_adapter *qdev)
        struct ql3xxx_local_ram_registers __iomem *local_ram =
            (void __iomem *)qdev->mem_map_registers;
 
-       if(ql_sem_spinlock(qdev, QL_DDR_RAM_SEM_MASK,
+       if (ql_sem_spinlock(qdev, QL_DDR_RAM_SEM_MASK,
                        (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
                         2) << 4))
                return -1;
@@ -3172,31 +3010,35 @@ static int ql_init_misc_registers(struct ql3_adapter *qdev)
 static int ql_adapter_initialize(struct ql3_adapter *qdev)
 {
        u32 value;
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
+       __iomem u32 *spir = &port_regs->CommonRegs.serialPortInterfaceReg;
        struct ql3xxx_host_memory_registers __iomem *hmem_regs =
-                                               (void __iomem *)port_regs;
+               (void __iomem *)port_regs;
        u32 delay = 10;
        int status = 0;
+       unsigned long hw_flags = 0;
 
-       if(ql_mii_setup(qdev))
+       if (ql_mii_setup(qdev))
                return -1;
 
        /* Bring out PHY out of reset */
-       ql_write_common_reg(qdev, &port_regs->CommonRegs.serialPortInterfaceReg,
+       ql_write_common_reg(qdev, spir,
                            (ISP_SERIAL_PORT_IF_WE |
                             (ISP_SERIAL_PORT_IF_WE << 16)));
-
+       /* Give the PHY time to come out of reset. */
+       mdelay(100);
        qdev->port_link_state = LS_DOWN;
        netif_carrier_off(qdev->ndev);
 
        /* V2 chip fix for ARS-39168. */
-       ql_write_common_reg(qdev, &port_regs->CommonRegs.serialPortInterfaceReg,
+       ql_write_common_reg(qdev, spir,
                            (ISP_SERIAL_PORT_IF_SDE |
                             (ISP_SERIAL_PORT_IF_SDE << 16)));
 
        /* Request Queue Registers */
-       *((u32 *) (qdev->preq_consumer_index)) = 0;
-       atomic_set(&qdev->tx_count,NUM_REQ_Q_ENTRIES);
+       *((u32 *)(qdev->preq_consumer_index)) = 0;
+       atomic_set(&qdev->tx_count, NUM_REQ_Q_ENTRIES);
        qdev->req_producer_index = 0;
 
        ql_write_page1_reg(qdev,
@@ -3215,7 +3057,7 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
        ql_write_page1_reg(qdev, &hmem_regs->reqLength, NUM_REQ_Q_ENTRIES);
 
        /* Response Queue Registers */
-       *((u16 *) (qdev->prsp_producer_index)) = 0;
+       *((__le16 *) (qdev->prsp_producer_index)) = 0;
        qdev->rsp_consumer_index = 0;
        qdev->rsp_current = qdev->rsp_q_virt_addr;
 
@@ -3246,7 +3088,9 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
                           &hmem_regs->rxLargeQBaseAddrLow,
                           LS_64BITS(qdev->lrg_buf_q_phy_addr));
 
-       ql_write_page1_reg(qdev, &hmem_regs->rxLargeQLength, qdev->num_lbufq_entries);
+       ql_write_page1_reg(qdev,
+                          &hmem_regs->rxLargeQLength,
+                          qdev->num_lbufq_entries);
 
        ql_write_page1_reg(qdev,
                           &hmem_regs->rxLargeBufferLength,
@@ -3270,8 +3114,7 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
        qdev->small_buf_release_cnt = 8;
        qdev->lrg_buf_q_producer_index = qdev->num_lbufq_entries - 1;
        qdev->lrg_buf_release_cnt = 8;
-       qdev->lrg_buf_next_free =
-           (struct bufq_addr_element *)qdev->lrg_buf_q_virt_addr;
+       qdev->lrg_buf_next_free = qdev->lrg_buf_q_virt_addr;
        qdev->small_buf_index = 0;
        qdev->lrg_buf_index = 0;
        qdev->lrg_buf_free_count = 0;
@@ -3296,7 +3139,7 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
        if ((value & PORT_STATUS_IC) == 0) {
 
                /* Chip has not been configured yet, so let it rip. */
-               if(ql_init_misc_registers(qdev)) {
+               if (ql_init_misc_registers(qdev)) {
                        status = -1;
                        goto out;
                }
@@ -3306,7 +3149,7 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
 
                value = (0xFFFF << 16) | qdev->nvram_data.extHwConfig;
 
-               if(ql_sem_spinlock(qdev, QL_FLASH_SEM_MASK,
+               if (ql_sem_spinlock(qdev, QL_FLASH_SEM_MASK,
                                (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index)
                                 * 2) << 13)) {
                        status = -1;
@@ -3329,7 +3172,7 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
                                           &port_regs->mac0MaxFrameLengthReg,
                                           qdev->max_frame_size);
 
-       if(ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
+       if (ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,
                        (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) *
                         2) << 7)) {
                status = -1;
@@ -3385,12 +3228,13 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
                value = ql_read_page0_reg(qdev, &port_regs->portStatus);
                if (value & PORT_STATUS_IC)
                        break;
+               spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
                msleep(500);
+               spin_lock_irqsave(&qdev->hw_lock, hw_flags);
        } while (--delay);
 
        if (delay == 0) {
-               printk(KERN_ERR PFX
-                      "%s: Hw Initialization timeout.\n", qdev->ndev->name);
+               netdev_err(qdev->ndev, "Hw Initialization timeout\n");
                status = -1;
                goto out;
        }
@@ -3421,7 +3265,8 @@ out:
  */
 static int ql_adapter_reset(struct ql3_adapter *qdev)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
        int status = 0;
        u16 value;
        int max_wait_time;
@@ -3432,17 +3277,14 @@ static int ql_adapter_reset(struct ql3_adapter *qdev)
        /*
         * Issue soft reset to chip.
         */
-       printk(KERN_DEBUG PFX
-              "%s: Issue soft reset to chip.\n",
-              qdev->ndev->name);
+       netdev_printk(KERN_DEBUG, qdev->ndev, "Issue soft reset to chip\n");
        ql_write_common_reg(qdev,
                            &port_regs->CommonRegs.ispControlStatus,
                            ((ISP_CONTROL_SR << 16) | ISP_CONTROL_SR));
 
        /* Wait 3 seconds for reset to complete. */
-       printk(KERN_DEBUG PFX
-              "%s: Wait 10 milliseconds for reset to complete.\n",
-              qdev->ndev->name);
+       netdev_printk(KERN_DEBUG, qdev->ndev,
+                     "Wait 10 milliseconds for reset to complete\n");
 
        /* Wait until the firmware tells us the Soft Reset is done */
        max_wait_time = 5;
@@ -3463,8 +3305,8 @@ static int ql_adapter_reset(struct ql3_adapter *qdev)
        value =
            ql_read_common_reg(qdev, &port_regs->CommonRegs.ispControlStatus);
        if (value & ISP_CONTROL_RI) {
-               printk(KERN_DEBUG PFX
-                      "ql_adapter_reset: clearing RI after reset.\n");
+               netdev_printk(KERN_DEBUG, qdev->ndev,
+                             "clearing RI after reset\n");
                ql_write_common_reg(qdev,
                                    &port_regs->CommonRegs.
                                    ispControlStatus,
@@ -3484,13 +3326,11 @@ static int ql_adapter_reset(struct ql3_adapter *qdev)
                 */
                max_wait_time = 5;
                do {
-                       value =
-                           ql_read_common_reg(qdev,
-                                              &port_regs->CommonRegs.
-                                              ispControlStatus);
-                       if ((value & ISP_CONTROL_FSR) == 0) {
+                       value = ql_read_common_reg(qdev,
+                                                  &port_regs->CommonRegs.
+                                                  ispControlStatus);
+                       if ((value & ISP_CONTROL_FSR) == 0)
                                break;
-                       }
                        ssleep(1);
                } while ((--max_wait_time));
        }
@@ -3504,7 +3344,8 @@ static int ql_adapter_reset(struct ql3_adapter *qdev)
 
 static void ql_set_mac_info(struct ql3_adapter *qdev)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
        u32 value, port_status;
        u8 func_number;
 
@@ -3517,73 +3358,61 @@ static void ql_set_mac_info(struct ql3_adapter *qdev)
        case ISP_CONTROL_FN0_NET:
                qdev->mac_index = 0;
                qdev->mac_ob_opcode = OUTBOUND_MAC_IOCB | func_number;
-               qdev->tcp_ob_opcode = OUTBOUND_TCP_IOCB | func_number;
-               qdev->update_ob_opcode = UPDATE_NCB_IOCB | func_number;
                qdev->mb_bit_mask = FN0_MA_BITS_MASK;
                qdev->PHYAddr = PORT0_PHY_ADDRESS;
                if (port_status & PORT_STATUS_SM0)
-                       set_bit(QL_LINK_OPTICAL,&qdev->flags);
+                       set_bit(QL_LINK_OPTICAL, &qdev->flags);
                else
-                       clear_bit(QL_LINK_OPTICAL,&qdev->flags);
+                       clear_bit(QL_LINK_OPTICAL, &qdev->flags);
                break;
 
        case ISP_CONTROL_FN1_NET:
                qdev->mac_index = 1;
                qdev->mac_ob_opcode = OUTBOUND_MAC_IOCB | func_number;
-               qdev->tcp_ob_opcode = OUTBOUND_TCP_IOCB | func_number;
-               qdev->update_ob_opcode = UPDATE_NCB_IOCB | func_number;
                qdev->mb_bit_mask = FN1_MA_BITS_MASK;
                qdev->PHYAddr = PORT1_PHY_ADDRESS;
                if (port_status & PORT_STATUS_SM1)
-                       set_bit(QL_LINK_OPTICAL,&qdev->flags);
+                       set_bit(QL_LINK_OPTICAL, &qdev->flags);
                else
-                       clear_bit(QL_LINK_OPTICAL,&qdev->flags);
+                       clear_bit(QL_LINK_OPTICAL, &qdev->flags);
                break;
 
        case ISP_CONTROL_FN0_SCSI:
        case ISP_CONTROL_FN1_SCSI:
        default:
-               printk(KERN_DEBUG PFX
-                      "%s: Invalid function number, ispControlStatus = 0x%x\n",
-                      qdev->ndev->name,value);
+               netdev_printk(KERN_DEBUG, qdev->ndev,
+                             "Invalid function number, ispControlStatus = 0x%x\n",
+                             value);
                break;
        }
-       qdev->numPorts = qdev->nvram_data.numPorts;
+       qdev->numPorts = qdev->nvram_data.version_and_numPorts >> 8;
 }
 
 static void ql_display_dev_info(struct net_device *ndev)
 {
-       struct ql3_adapter *qdev = (struct ql3_adapter *)netdev_priv(ndev);
+       struct ql3_adapter *qdev = netdev_priv(ndev);
        struct pci_dev *pdev = qdev->pdev;
 
-       printk(KERN_INFO PFX
-              "\n%s Adapter %d RevisionID %d found %s on PCI slot %d.\n",
-              DRV_NAME, qdev->index, qdev->chip_rev_id,
-              (qdev->device_id == QL3032_DEVICE_ID) ? "QLA3032" : "QLA3022",
-              qdev->pci_slot);
-       printk(KERN_INFO PFX
-              "%s Interface.\n",
-              test_bit(QL_LINK_OPTICAL,&qdev->flags) ? "OPTICAL" : "COPPER");
+       netdev_info(ndev,
+                   "%s Adapter %d RevisionID %d found %s on PCI slot %d\n",
+                   DRV_NAME, qdev->index, qdev->chip_rev_id,
+                   qdev->device_id == QL3032_DEVICE_ID ? "QLA3032" : "QLA3022",
+                   qdev->pci_slot);
+       netdev_info(ndev, "%s Interface\n",
+               test_bit(QL_LINK_OPTICAL, &qdev->flags) ? "OPTICAL" : "COPPER");
 
        /*
         * Print PCI bus width/type.
         */
-       printk(KERN_INFO PFX
-              "Bus interface is %s %s.\n",
-              ((qdev->pci_width == 64) ? "64-bit" : "32-bit"),
-              ((qdev->pci_x) ? "PCI-X" : "PCI"));
+       netdev_info(ndev, "Bus interface is %s %s\n",
+                   ((qdev->pci_width == 64) ? "64-bit" : "32-bit"),
+                   ((qdev->pci_x) ? "PCI-X" : "PCI"));
 
-       printk(KERN_INFO PFX
-              "mem  IO base address adjusted = 0x%p\n",
-              qdev->mem_map_registers);
-       printk(KERN_INFO PFX "Interrupt number = %d\n", pdev->irq);
+       netdev_info(ndev, "mem  IO base address adjusted = 0x%p\n",
+                   qdev->mem_map_registers);
+       netdev_info(ndev, "Interrupt number = %d\n", pdev->irq);
 
-       if (netif_msg_probe(qdev))
-               printk(KERN_INFO PFX
-                      "%s: MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
-                      ndev->name, ndev->dev_addr[0], ndev->dev_addr[1],
-                      ndev->dev_addr[2], ndev->dev_addr[3], ndev->dev_addr[4],
-                      ndev->dev_addr[5]);
+       netif_info(qdev, probe, ndev, "MAC address %pM\n", ndev->dev_addr);
 }
 
 static int ql_adapter_down(struct ql3_adapter *qdev, int do_reset)
@@ -3594,23 +3423,22 @@ static int ql_adapter_down(struct ql3_adapter *qdev, int do_reset)
        netif_stop_queue(ndev);
        netif_carrier_off(ndev);
 
-       clear_bit(QL_ADAPTER_UP,&qdev->flags);
-       clear_bit(QL_LINK_MASTER,&qdev->flags);
+       clear_bit(QL_ADAPTER_UP, &qdev->flags);
+       clear_bit(QL_LINK_MASTER, &qdev->flags);
 
        ql_disable_interrupts(qdev);
 
        free_irq(qdev->pdev->irq, ndev);
 
-       if (qdev->msi && test_bit(QL_MSI_ENABLED,&qdev->flags)) {
-               printk(KERN_INFO PFX
-                      "%s: calling pci_disable_msi().\n", qdev->ndev->name);
-               clear_bit(QL_MSI_ENABLED,&qdev->flags);
+       if (qdev->msi && test_bit(QL_MSI_ENABLED, &qdev->flags)) {
+               netdev_info(qdev->ndev, "calling pci_disable_msi()\n");
+               clear_bit(QL_MSI_ENABLED, &qdev->flags);
                pci_disable_msi(qdev->pdev);
        }
 
        del_timer_sync(&qdev->adapter_timer);
 
-       netif_poll_disable(ndev);
+       napi_disable(&qdev->napi);
 
        if (do_reset) {
                int soft_reset;
@@ -3618,17 +3446,16 @@ static int ql_adapter_down(struct ql3_adapter *qdev, int do_reset)
 
                spin_lock_irqsave(&qdev->hw_lock, hw_flags);
                if (ql_wait_for_drvr_lock(qdev)) {
-                       if ((soft_reset = ql_adapter_reset(qdev))) {
-                               printk(KERN_ERR PFX
-                                      "%s: ql_adapter_reset(%d) FAILED!\n",
-                                      ndev->name, qdev->index);
+                       soft_reset = ql_adapter_reset(qdev);
+                       if (soft_reset) {
+                               netdev_err(ndev, "ql_adapter_reset(%d) FAILED!\n",
+                                          qdev->index);
                        }
-                       printk(KERN_ERR PFX
-                               "%s: Releaseing driver lock via chip reset.\n",ndev->name);
+                       netdev_err(ndev,
+                                  "Releasing driver lock via chip reset\n");
                } else {
-                       printk(KERN_ERR PFX
-                              "%s: Could not acquire driver lock to do "
-                              "reset!\n", ndev->name);
+                       netdev_err(ndev,
+                                  "Could not acquire driver lock to do reset!\n");
                        retval = -1;
                }
                spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
@@ -3641,64 +3468,58 @@ static int ql_adapter_up(struct ql3_adapter *qdev)
 {
        struct net_device *ndev = qdev->ndev;
        int err;
-       unsigned long irq_flags = IRQF_SAMPLE_RANDOM | IRQF_SHARED;
+       unsigned long irq_flags = IRQF_SHARED;
        unsigned long hw_flags;
 
        if (ql_alloc_mem_resources(qdev)) {
-               printk(KERN_ERR PFX
-                      "%s Unable to  allocate buffers.\n", ndev->name);
+               netdev_err(ndev, "Unable to  allocate buffers\n");
                return -ENOMEM;
        }
 
        if (qdev->msi) {
                if (pci_enable_msi(qdev->pdev)) {
-                       printk(KERN_ERR PFX
-                              "%s: User requested MSI, but MSI failed to "
-                              "initialize.  Continuing without MSI.\n",
-                              qdev->ndev->name);
+                       netdev_err(ndev,
+                                  "User requested MSI, but MSI failed to initialize.  Continuing without MSI.\n");
                        qdev->msi = 0;
                } else {
-                       printk(KERN_INFO PFX "%s: MSI Enabled...\n", qdev->ndev->name);
-                       set_bit(QL_MSI_ENABLED,&qdev->flags);
+                       netdev_info(ndev, "MSI Enabled...\n");
+                       set_bit(QL_MSI_ENABLED, &qdev->flags);
                        irq_flags &= ~IRQF_SHARED;
                }
        }
 
-       if ((err = request_irq(qdev->pdev->irq,
-                              ql3xxx_isr,
-                              irq_flags, ndev->name, ndev))) {
-               printk(KERN_ERR PFX
-                      "%s: Failed to reserve interrupt %d already in use.\n",
-                      ndev->name, qdev->pdev->irq);
+       err = request_irq(qdev->pdev->irq, ql3xxx_isr,
+                         irq_flags, ndev->name, ndev);
+       if (err) {
+               netdev_err(ndev,
+                          "Failed to reserve interrupt %d - already in use\n",
+                          qdev->pdev->irq);
                goto err_irq;
        }
 
        spin_lock_irqsave(&qdev->hw_lock, hw_flags);
 
-       if ((err = ql_wait_for_drvr_lock(qdev))) {
-               if ((err = ql_adapter_initialize(qdev))) {
-                       printk(KERN_ERR PFX
-                              "%s: Unable to initialize adapter.\n",
-                              ndev->name);
+       err = ql_wait_for_drvr_lock(qdev);
+       if (err) {
+               err = ql_adapter_initialize(qdev);
+               if (err) {
+                       netdev_err(ndev, "Unable to initialize adapter\n");
                        goto err_init;
                }
-               printk(KERN_ERR PFX
-                               "%s: Releaseing driver lock.\n",ndev->name);
+               netdev_err(ndev, "Releasing driver lock\n");
                ql_sem_unlock(qdev, QL_DRVR_SEM_MASK);
        } else {
-               printk(KERN_ERR PFX
-                      "%s: Could not aquire driver lock.\n",
-                      ndev->name);
+               netdev_err(ndev, "Could not acquire driver lock\n");
                goto err_lock;
        }
 
        spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
 
-       set_bit(QL_ADAPTER_UP,&qdev->flags);
+       set_bit(QL_ADAPTER_UP, &qdev->flags);
 
        mod_timer(&qdev->adapter_timer, jiffies + HZ * 1);
 
-       netif_poll_enable(ndev);
+       napi_enable(&qdev->napi);
        ql_enable_interrupts(qdev);
        return 0;
 
@@ -3708,11 +3529,9 @@ err_lock:
        spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
        free_irq(qdev->pdev->irq, ndev);
 err_irq:
-       if (qdev->msi && test_bit(QL_MSI_ENABLED,&qdev->flags)) {
-               printk(KERN_INFO PFX
-                      "%s: calling pci_disable_msi().\n",
-                      qdev->ndev->name);
-               clear_bit(QL_MSI_ENABLED,&qdev->flags);
+       if (qdev->msi && test_bit(QL_MSI_ENABLED, &qdev->flags)) {
+               netdev_info(ndev, "calling pci_disable_msi()\n");
+               clear_bit(QL_MSI_ENABLED, &qdev->flags);
                pci_disable_msi(qdev->pdev);
        }
        return err;
@@ -3720,11 +3539,12 @@ err_irq:
 
 static int ql_cycle_adapter(struct ql3_adapter *qdev, int reset)
 {
-       if( ql_adapter_down(qdev,reset) || ql_adapter_up(qdev)) {
-               printk(KERN_ERR PFX
-                               "%s: Driver up/down cycle failed, "
-                               "closing device\n",qdev->ndev->name);
+       if (ql_adapter_down(qdev, reset) || ql_adapter_up(qdev)) {
+               netdev_err(qdev->ndev,
+                          "Driver up/down cycle failed, closing device\n");
+               rtnl_lock();
                dev_close(qdev->ndev);
+               rtnl_unlock();
                return -1;
        }
        return 0;
@@ -3738,38 +3558,24 @@ static int ql3xxx_close(struct net_device *ndev)
         * Wait for device to recover from a reset.
         * (Rarely happens, but possible.)
         */
-       while (!test_bit(QL_ADAPTER_UP,&qdev->flags))
+       while (!test_bit(QL_ADAPTER_UP, &qdev->flags))
                msleep(50);
 
-       ql_adapter_down(qdev,QL_DO_RESET);
+       ql_adapter_down(qdev, QL_DO_RESET);
        return 0;
 }
 
 static int ql3xxx_open(struct net_device *ndev)
 {
        struct ql3_adapter *qdev = netdev_priv(ndev);
-       return (ql_adapter_up(qdev));
-}
-
-static struct net_device_stats *ql3xxx_get_stats(struct net_device *dev)
-{
-       struct ql3_adapter *qdev = (struct ql3_adapter *)dev->priv;
-       return &qdev->stats;
-}
-
-static void ql3xxx_set_multicast_list(struct net_device *ndev)
-{
-       /*
-        * We are manually parsing the list in the net_device structure.
-        */
-       return;
+       return ql_adapter_up(qdev);
 }
 
 static int ql3xxx_set_mac_address(struct net_device *ndev, void *p)
 {
-       struct ql3_adapter *qdev = (struct ql3_adapter *)netdev_priv(ndev);
+       struct ql3_adapter *qdev = netdev_priv(ndev);
        struct ql3xxx_port_registers __iomem *port_regs =
-                       qdev->mem_map_registers;
+                       qdev->mem_map_registers;
        struct sockaddr *addr = p;
        unsigned long hw_flags;
 
@@ -3802,9 +3608,9 @@ static int ql3xxx_set_mac_address(struct net_device *ndev, void *p)
 
 static void ql3xxx_tx_timeout(struct net_device *ndev)
 {
-       struct ql3_adapter *qdev = (struct ql3_adapter *)netdev_priv(ndev);
+       struct ql3_adapter *qdev = netdev_priv(ndev);
 
-       printk(KERN_ERR PFX "%s: Resetting...\n", ndev->name);
+       netdev_err(ndev, "Resetting...\n");
        /*
         * Stop the queues, we've got a problem.
         */
@@ -3824,11 +3630,12 @@ static void ql_reset_work(struct work_struct *work)
        u32 value;
        struct ql_tx_buf_cb *tx_cb;
        int max_wait_time, i;
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
        unsigned long hw_flags;
 
-       if (test_bit((QL_RESET_PER_SCSI | QL_RESET_START),&qdev->flags)) {
-               clear_bit(QL_LINK_MASTER,&qdev->flags);
+       if (test_bit((QL_RESET_PER_SCSI | QL_RESET_START), &qdev->flags)) {
+               clear_bit(QL_LINK_MASTER, &qdev->flags);
 
                /*
                 * Loop through the active list and return the skb.
@@ -3837,17 +3644,19 @@ static void ql_reset_work(struct work_struct *work)
                        int j;
                        tx_cb = &qdev->tx_buf[i];
                        if (tx_cb->skb) {
-                               printk(KERN_DEBUG PFX
-                                      "%s: Freeing lost SKB.\n",
-                                      qdev->ndev->name);
+                               netdev_printk(KERN_DEBUG, ndev,
+                                             "Freeing lost SKB\n");
                                pci_unmap_single(qdev->pdev,
-                                        pci_unmap_addr(&tx_cb->map[0], mapaddr),
-                                        pci_unmap_len(&tx_cb->map[0], maplen),
+                                        dma_unmap_addr(&tx_cb->map[0],
+                                                       mapaddr),
+                                        dma_unmap_len(&tx_cb->map[0], maplen),
                                         PCI_DMA_TODEVICE);
-                               for(j=1;j<tx_cb->seg_count;j++) {
+                               for (j = 1; j < tx_cb->seg_count; j++) {
                                        pci_unmap_page(qdev->pdev,
-                                              pci_unmap_addr(&tx_cb->map[j],mapaddr),
-                                              pci_unmap_len(&tx_cb->map[j],maplen),
+                                              dma_unmap_addr(&tx_cb->map[j],
+                                                             mapaddr),
+                                              dma_unmap_len(&tx_cb->map[j],
+                                                            maplen),
                                               PCI_DMA_TODEVICE);
                                }
                                dev_kfree_skb(tx_cb->skb);
@@ -3855,8 +3664,7 @@ static void ql_reset_work(struct work_struct *work)
                        }
                }
 
-               printk(KERN_ERR PFX
-                      "%s: Clearing NRI after reset.\n", qdev->ndev->name);
+               netdev_err(ndev, "Clearing NRI after reset\n");
                spin_lock_irqsave(&qdev->hw_lock, hw_flags);
                ql_write_common_reg(qdev,
                                    &port_regs->CommonRegs.
@@ -3872,16 +3680,14 @@ static void ql_reset_work(struct work_struct *work)
 
                                                   ispControlStatus);
                        if ((value & ISP_CONTROL_SR) == 0) {
-                               printk(KERN_DEBUG PFX
-                                      "%s: reset completed.\n",
-                                      qdev->ndev->name);
+                               netdev_printk(KERN_DEBUG, ndev,
+                                             "reset completed\n");
                                break;
                        }
 
                        if (value & ISP_CONTROL_RI) {
-                               printk(KERN_DEBUG PFX
-                                      "%s: clearing NRI after reset.\n",
-                                      qdev->ndev->name);
+                               netdev_printk(KERN_DEBUG, ndev,
+                                             "clearing NRI after reset\n");
                                ql_write_common_reg(qdev,
                                                    &port_regs->
                                                    CommonRegs.
@@ -3890,7 +3696,9 @@ static void ql_reset_work(struct work_struct *work)
                                                      16) | ISP_CONTROL_RI));
                        }
 
+                       spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
                        ssleep(1);
+                       spin_lock_irqsave(&qdev->hw_lock, hw_flags);
                } while (--max_wait_time);
                spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
 
@@ -3900,21 +3708,19 @@ static void ql_reset_work(struct work_struct *work)
                         * Set the reset flags and clear the board again.
                         * Nothing else to do...
                         */
-                       printk(KERN_ERR PFX
-                              "%s: Timed out waiting for reset to "
-                              "complete.\n", ndev->name);
-                       printk(KERN_ERR PFX
-                              "%s: Do a reset.\n", ndev->name);
-                       clear_bit(QL_RESET_PER_SCSI,&qdev->flags);
-                       clear_bit(QL_RESET_START,&qdev->flags);
-                       ql_cycle_adapter(qdev,QL_DO_RESET);
+                       netdev_err(ndev,
+                                  "Timed out waiting for reset to complete\n");
+                       netdev_err(ndev, "Do a reset\n");
+                       clear_bit(QL_RESET_PER_SCSI, &qdev->flags);
+                       clear_bit(QL_RESET_START, &qdev->flags);
+                       ql_cycle_adapter(qdev, QL_DO_RESET);
                        return;
                }
 
-               clear_bit(QL_RESET_ACTIVE,&qdev->flags);
-               clear_bit(QL_RESET_PER_SCSI,&qdev->flags);
-               clear_bit(QL_RESET_START,&qdev->flags);
-               ql_cycle_adapter(qdev,QL_NO_RESET);
+               clear_bit(QL_RESET_ACTIVE, &qdev->flags);
+               clear_bit(QL_RESET_PER_SCSI, &qdev->flags);
+               clear_bit(QL_RESET_START, &qdev->flags);
+               ql_cycle_adapter(qdev, QL_NO_RESET);
        }
 }
 
@@ -3928,7 +3734,8 @@ static void ql_tx_timeout_work(struct work_struct *work)
 
 static void ql_get_board_info(struct ql3_adapter *qdev)
 {
-       struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
+       struct ql3xxx_port_registers __iomem *port_regs =
+               qdev->mem_map_registers;
        u32 value;
 
        value = ql_read_page0_reg_l(qdev, &port_regs->portStatus);
@@ -3948,68 +3755,62 @@ static void ql_get_board_info(struct ql3_adapter *qdev)
 static void ql3xxx_timer(unsigned long ptr)
 {
        struct ql3_adapter *qdev = (struct ql3_adapter *)ptr;
-
-       if (test_bit(QL_RESET_ACTIVE,&qdev->flags)) {
-               printk(KERN_DEBUG PFX
-                      "%s: Reset in progress.\n",
-                      qdev->ndev->name);
-               goto end;
-       }
-
-       ql_link_state_machine(qdev);
-
-       /* Restart timer on 2 second interval. */
-end:
-       mod_timer(&qdev->adapter_timer, jiffies + HZ * 1);
-}
+       queue_delayed_work(qdev->workqueue, &qdev->link_state_work, 0);
+}
+
+static const struct net_device_ops ql3xxx_netdev_ops = {
+       .ndo_open               = ql3xxx_open,
+       .ndo_start_xmit         = ql3xxx_send,
+       .ndo_stop               = ql3xxx_close,
+       .ndo_set_multicast_list = NULL, /* not allowed on NIC side */
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = ql3xxx_set_mac_address,
+       .ndo_tx_timeout         = ql3xxx_tx_timeout,
+};
 
 static int __devinit ql3xxx_probe(struct pci_dev *pdev,
                                  const struct pci_device_id *pci_entry)
 {
        struct net_device *ndev = NULL;
        struct ql3_adapter *qdev = NULL;
-       static int cards_found = 0;
-       int pci_using_dac, err;
+       static int cards_found;
+       int uninitialized_var(pci_using_dac), err;
 
        err = pci_enable_device(pdev);
        if (err) {
-               printk(KERN_ERR PFX "%s cannot enable PCI device\n",
-                      pci_name(pdev));
+               pr_err("%s cannot enable PCI device\n", pci_name(pdev));
                goto err_out;
        }
 
        err = pci_request_regions(pdev, DRV_NAME);
        if (err) {
-               printk(KERN_ERR PFX "%s cannot obtain PCI resources\n",
-                      pci_name(pdev));
+               pr_err("%s cannot obtain PCI resources\n", pci_name(pdev));
                goto err_out_disable_pdev;
        }
 
        pci_set_master(pdev);
 
-       if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
+       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
                pci_using_dac = 1;
-               err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
-       } else if (!(err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
+               err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+       } else if (!(err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) {
                pci_using_dac = 0;
-               err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+               err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
        }
 
        if (err) {
-               printk(KERN_ERR PFX "%s no usable DMA configuration\n",
-                      pci_name(pdev));
+               pr_err("%s no usable DMA configuration\n", pci_name(pdev));
                goto err_out_free_regions;
        }
 
        ndev = alloc_etherdev(sizeof(struct ql3_adapter));
        if (!ndev) {
-               printk(KERN_ERR PFX "%s could not alloc etherdev\n",
-                      pci_name(pdev));
+               pr_err("%s could not alloc etherdev\n", pci_name(pdev));
                err = -ENOMEM;
                goto err_out_free_regions;
        }
 
-       SET_MODULE_OWNER(ndev);
        SET_NETDEV_DEV(ndev, &pdev->dev);
 
        pci_set_drvdata(pdev, ndev);
@@ -4030,12 +3831,9 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
        if (qdev->device_id == QL3032_DEVICE_ID)
                ndev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
 
-       qdev->mem_map_registers =
-           ioremap_nocache(pci_resource_start(pdev, 1),
-                           pci_resource_len(qdev->pdev, 1));
+       qdev->mem_map_registers = pci_ioremap_bar(pdev, 1);
        if (!qdev->mem_map_registers) {
-               printk(KERN_ERR PFX "%s: cannot map device registers\n",
-                      pci_name(pdev));
+               pr_err("%s: cannot map device registers\n", pci_name(pdev));
                err = -EIO;
                goto err_out_free_ndev;
        }
@@ -4044,26 +3842,18 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
        spin_lock_init(&qdev->hw_lock);
 
        /* Set driver entry points */
-       ndev->open = ql3xxx_open;
-       ndev->hard_start_xmit = ql3xxx_send;
-       ndev->stop = ql3xxx_close;
-       ndev->get_stats = ql3xxx_get_stats;
-       ndev->set_multicast_list = ql3xxx_set_multicast_list;
+       ndev->netdev_ops = &ql3xxx_netdev_ops;
        SET_ETHTOOL_OPS(ndev, &ql3xxx_ethtool_ops);
-       ndev->set_mac_address = ql3xxx_set_mac_address;
-       ndev->tx_timeout = ql3xxx_tx_timeout;
        ndev->watchdog_timeo = 5 * HZ;
 
-       ndev->poll = &ql_poll;
-       ndev->weight = 64;
+       netif_napi_add(ndev, &qdev->napi, ql_poll, 64);
 
        ndev->irq = pdev->irq;
 
        /* make sure the EEPROM is good */
        if (ql_get_nvram_params(qdev)) {
-               printk(KERN_ALERT PFX
-                      "ql3xxx_probe: Adapter #%d, Invalid NVRAM parameters.\n",
-                      qdev->index);
+               pr_alert("%s: Adapter #%d, Invalid NVRAM parameters\n",
+                        __func__, qdev->index);
                err = -EIO;
                goto err_out_iounmap;
        }
@@ -4073,20 +3863,15 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
        /* Validate and set parameters */
        if (qdev->mac_index) {
                ndev->mtu = qdev->nvram_data.macCfg_port1.etherMtu_mac ;
-               memcpy(ndev->dev_addr, &qdev->nvram_data.funcCfg_fn2.macAddress,
-                      ETH_ALEN);
+               ql_set_mac_addr(ndev, qdev->nvram_data.funcCfg_fn2.macAddress);
        } else {
                ndev->mtu = qdev->nvram_data.macCfg_port0.etherMtu_mac ;
-               memcpy(ndev->dev_addr, &qdev->nvram_data.funcCfg_fn0.macAddress,
-                      ETH_ALEN);
+               ql_set_mac_addr(ndev, qdev->nvram_data.funcCfg_fn0.macAddress);
        }
        memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
 
        ndev->tx_queue_len = NUM_REQ_Q_ENTRIES;
 
-       /* Turn off support for multicasting */
-       ndev->flags &= ~IFF_MULTICAST;
-
        /* Record PCI bus information. */
        ql_get_board_info(qdev);
 
@@ -4094,14 +3879,12 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
         * Set the Maximum Memory Read Byte Count value. We do this to handle
         * jumbo frames.
         */
-       if (qdev->pci_x) {
+       if (qdev->pci_x)
                pci_write_config_word(pdev, (int)0x4e, (u16) 0x0036);
-       }
 
        err = register_netdev(ndev);
        if (err) {
-               printk(KERN_ERR PFX "%s: cannot register net device\n",
-                      pci_name(pdev));
+               pr_err("%s: cannot register net device\n", pci_name(pdev));
                goto err_out_iounmap;
        }
 
@@ -4113,16 +3896,17 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
        qdev->workqueue = create_singlethread_workqueue(ndev->name);
        INIT_DELAYED_WORK(&qdev->reset_work, ql_reset_work);
        INIT_DELAYED_WORK(&qdev->tx_timeout_work, ql_tx_timeout_work);
+       INIT_DELAYED_WORK(&qdev->link_state_work, ql_link_state_machine_work);
 
        init_timer(&qdev->adapter_timer);
        qdev->adapter_timer.function = ql3xxx_timer;
        qdev->adapter_timer.expires = jiffies + HZ * 2; /* two second delay */
        qdev->adapter_timer.data = (unsigned long)qdev;
 
-       if(!cards_found) {
-               printk(KERN_ALERT PFX "%s\n", DRV_STRING);
-               printk(KERN_ALERT PFX "Driver name: %s, Version: %s.\n",
-                  DRV_NAME, DRV_VERSION);
+       if (!cards_found) {
+               pr_alert("%s\n", DRV_STRING);
+               pr_alert("Driver name: %s, Version: %s\n",
+                        DRV_NAME, DRV_VERSION);
        }
        ql_display_dev_info(ndev);
 
@@ -4148,7 +3932,6 @@ static void __devexit ql3xxx_remove(struct pci_dev *pdev)
        struct ql3_adapter *qdev = netdev_priv(ndev);
 
        unregister_netdev(ndev);
-       qdev = netdev_priv(ndev);
 
        ql_disable_interrupts(qdev);