Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / net / hp100.c
index a845c11..247c8ca 100644 (file)
@@ -13,8 +13,8 @@
 ** This driver has only been tested with
 ** -- HP J2585B 10/100 Mbit/s PCI Busmaster
 ** -- HP J2585A 10/100 Mbit/s PCI 
-** -- HP J2970  10 Mbit/s PCI Combo 10base-T/BNC
-** -- HP J2973  10 Mbit/s PCI 10base-T
+** -- HP J2970A 10 Mbit/s PCI Combo 10base-T/BNC
+** -- HP J2973A 10 Mbit/s PCI 10base-T
 ** -- HP J2573  10/100 ISA
 ** -- Compex ReadyLink ENET100-VG4  10/100 Mbit/s PCI / EISA
 ** -- Compex FreedomLine 100/VG  10/100 Mbit/s ISA / EISA / PCI
@@ -96,7 +96,6 @@
 
 #undef HP100_MULTICAST_FILTER  /* Need to be debugged... */
 
-#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/interrupt.h>
 #include <linux/eisa.h>
 #include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/config.h>      /* for CONFIG_PCI */
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
+#include <linux/jiffies.h>
 
-#include <asm/bitops.h>
 #include <asm/io.h>
 
 #include "hp100.h"
@@ -161,7 +162,7 @@ struct hp100_private {
        u_char bus;
        struct pci_dev *pci_dev;
        short mem_mapped;       /* memory mapped access */
-       void *mem_ptr_virt;     /* virtual memory mapped area, maybe NULL */
+       void __iomem *mem_ptr_virt;     /* virtual memory mapped area, maybe NULL */
        unsigned long mem_ptr_phys;     /* physical memory mapped area */
        short lan_type;         /* 10Mb/s, 100Mb/s or -1 (error) */
        int hub_status;         /* was login to hub successful? */
@@ -224,9 +225,9 @@ static int hp100_rx_ratio = HP100_DEFAULT_RX_RATIO;
 static int hp100_priority_tx = HP100_DEFAULT_PRIORITY_TX;
 static int hp100_mode = 1;
 
-MODULE_PARM(hp100_rx_ratio, "1i");
-MODULE_PARM(hp100_priority_tx, "1i");
-MODULE_PARM(hp100_mode, "1i");
+module_param(hp100_rx_ratio, int, 0);
+module_param(hp100_priority_tx, int, 0);
+module_param(hp100_mode, int, 0);
 
 /*
  *  prototypes
@@ -276,12 +277,18 @@ static void hp100_RegisterDump(struct net_device *dev);
  * Convert an address in a kernel buffer to a bus/phys/dma address.
  * This work *only* for memory fragments part of lp->page_vaddr,
  * because it was properly DMA allocated via pci_alloc_consistent(),
- * so we just need to "retreive" the original mapping to bus/phys/dma
+ * so we just need to "retrieve" the original mapping to bus/phys/dma
  * address - Jean II */
 static inline dma_addr_t virt_to_whatever(struct net_device *dev, u32 * ptr)
 {
-       return ((u_long) ptr) +
-               ((struct hp100_private *) (dev->priv))->whatever_offset;
+       struct hp100_private *lp = netdev_priv(dev);
+       return ((u_long) ptr) + lp->whatever_offset;
+}
+
+static inline u_int pdl_map_data(struct hp100_private *lp, void *data)
+{
+       return pci_map_single(lp->pci_dev, data, 
+                             MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE);
 }
 
 /* TODO: This function should not really be needed in a good design... */
@@ -300,7 +307,7 @@ static void wait(void)
  * Read board id and convert to string.
  * Effectively same code as decode_eisa_sig
  */
-static __init const char *hp100_read_id(int ioaddr)
+static __devinit const char *hp100_read_id(int ioaddr)
 {
        int i;
        static char str[HP100_SIG_LEN];
@@ -386,6 +393,7 @@ static int  __init hp100_isa_probe(struct net_device *dev, int addr)
 }
 
 
+#ifndef MODULE
 struct net_device * __init hp100_probe(int unit)
 {
        struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private));
@@ -410,19 +418,15 @@ struct net_device * __init hp100_probe(int unit)
        if (err)
                goto out;
 
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
        return dev;
- out1:
-       release_region(dev->base_addr, HP100_REGION_SIZE);
  out:
        free_netdev(dev);
        return ERR_PTR(err);
 }
+#endif
 
-static int __init hp100_probe1(struct net_device *dev, int ioaddr,
-                              u_char bus, struct pci_dev *pci_dev)
+static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
+                                 u_char bus, struct pci_dev *pci_dev)
 {
        int i;
        int err = -ENODEV;
@@ -433,7 +437,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr,
        u_short local_mode, lsw;
        short mem_mapped;
        unsigned long mem_ptr_phys;
-       void **mem_ptr_virt;
+       void __iomem *mem_ptr_virt;
        struct hp100_private *lp;
 
 #ifdef HP100_DEBUG_B
@@ -554,7 +558,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr,
                         * Also, we can have EISA Busmaster cards (not tested),
                         * so beware !!! - Jean II */
                        if((bus == HP100_BUS_PCI) &&
-                          (pci_set_dma_mask(pci_dev, 0xffffffff))) {
+                          (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK))) {
                                /* Gracefully fallback to shared memory */
                                goto busmasterfail;
                        }
@@ -629,7 +633,7 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr,
        }
 
        /* Initialise the "private" data structure for this card. */
-       lp = (struct hp100_private *) dev->priv;
+       lp = netdev_priv(dev);
 
        spin_lock_init(&lp->lock);
        strlcpy(lp->id, eid, HP100_SIG_LEN);
@@ -768,18 +772,29 @@ static int __init hp100_probe1(struct net_device *dev, int ioaddr,
                printk("Warning! Link down.\n");
        }
 
+       err = register_netdev(dev);
+       if (err)
+               goto out3;
+
        return 0;
+out3:
+       if (local_mode == 1)
+               pci_free_consistent(lp->pci_dev, MAX_RINGSIZE + 0x0f, 
+                                   lp->page_vaddr_algn, 
+                                   virt_to_whatever(dev, lp->page_vaddr_algn));
+       if (mem_ptr_virt)
+               iounmap(mem_ptr_virt);
 out2:
        release_region(ioaddr, HP100_REGION_SIZE);
 out1:
-       return -ENODEV;
+       return err;
 }
 
 /* This procedure puts the card into a stable init state */
 static void hp100_hwinit(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4202, TRACE);
@@ -873,7 +888,7 @@ static void hp100_hwinit(struct net_device *dev)
 static void hp100_mmuinit(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        int i;
 
 #ifdef HP100_DEBUG_B
@@ -1051,7 +1066,7 @@ static void hp100_mmuinit(struct net_device *dev)
 
 static int hp100_open(struct net_device *dev)
 {
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 #ifdef HP100_DEBUG_B
        int ioaddr = dev->base_addr;
 #endif
@@ -1091,7 +1106,7 @@ static int hp100_open(struct net_device *dev)
 static int hp100_close(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4205, TRACE);
@@ -1124,7 +1139,7 @@ static int hp100_close(struct net_device *dev)
  */
 static void hp100_init_pdls(struct net_device *dev)
 {
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        hp100_ring_t *ringptr;
        u_int *pageptr;         /* Warning : increment by 4 - Jean II */
        int i;
@@ -1271,7 +1286,8 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr,
                /* Conversion to new PCI API : map skbuf data to PCI bus.
                 * Doc says it's OK for EISA as well - Jean II */
                ringptr->pdl[0] = 0x00020000;   /* Write PDH */
-               ringptr->pdl[3] = ((u_int) pci_map_single(((struct hp100_private *) (dev->priv))->pci_dev, ringptr->skb->data, MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE));
+               ringptr->pdl[3] = pdl_map_data(netdev_priv(dev), 
+                                              ringptr->skb->data);
                ringptr->pdl[4] = MAX_ETHER_SIZE;       /* Length of Data */
 
 #ifdef HP100_DEBUG_BM
@@ -1308,7 +1324,7 @@ static void hp100_rxfill(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
 
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        hp100_ring_t *ringptr;
 
 #ifdef HP100_DEBUG_B
@@ -1349,7 +1365,7 @@ static void hp100_rxfill(struct net_device *dev)
 static void hp100_BM_shutdown(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        unsigned long time;
 
 #ifdef HP100_DEBUG_B
@@ -1430,7 +1446,7 @@ static void hp100_BM_shutdown(struct net_device *dev)
 
 static int hp100_check_lan(struct net_device *dev)
 {
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
        if (lp->lan_type < 0) { /* no LAN type detected yet? */
                hp100_stop_interface(dev);
@@ -1456,7 +1472,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
        unsigned long flags;
        int i, ok_flag;
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        hp100_ring_t *ringptr;
 
 #ifdef HP100_DEBUG_B
@@ -1484,7 +1500,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
                printk("hp100: %s: start_xmit_bm: No TX PDL available.\n", dev->name);
 #endif
                /* not waited long enough since last tx? */
-               if (jiffies - dev->trans_start < HZ)
+               if (time_before(jiffies, dev->trans_start + HZ))
                        return -EAGAIN;
 
                if (hp100_check_lan(dev))
@@ -1574,7 +1590,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
  */
 static void hp100_clean_txring(struct net_device *dev)
 {
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
        int donecount;
 
@@ -1613,7 +1629,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
        int i, ok_flag;
        int ioaddr = dev->base_addr;
        u_short val;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4212, TRACE);
@@ -1637,7 +1653,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
                printk("hp100: %s: start_xmit: tx free mem = 0x%x\n", dev->name, i);
 #endif
                /* not waited long enough since last failed tx try? */
-               if (jiffies - dev->trans_start < HZ) {
+               if (time_before(jiffies, dev->trans_start + HZ)) {
 #ifdef HP100_DEBUG
                        printk("hp100: %s: trans_start timing problem\n",
                               dev->name);
@@ -1703,17 +1719,10 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
        hp100_outw(i, FRAGMENT_LEN);    /* and first/only fragment length    */
 
        if (lp->mode == 2) {    /* memory mapped */
-               if (lp->mem_ptr_virt) { /* high pci memory was remapped */
-                       /* Note: The J2585B needs alignment to 32bits here!  */
-                       memcpy_toio(lp->mem_ptr_virt, skb->data, (skb->len + 3) & ~3);
-                       if (!ok_flag)
-                               memset_io(lp->mem_ptr_virt, 0, HP100_MIN_PACKET_SIZE - skb->len);
-               } else {
-                       /* Note: The J2585B needs alignment to 32bits here!  */
-                       isa_memcpy_toio(lp->mem_ptr_phys, skb->data, (skb->len + 3) & ~3);
-                       if (!ok_flag)
-                               isa_memset_io(lp->mem_ptr_phys, 0, HP100_MIN_PACKET_SIZE - skb->len);
-               }
+               /* Note: The J2585B needs alignment to 32bits here!  */
+               memcpy_toio(lp->mem_ptr_virt, skb->data, (skb->len + 3) & ~3);
+               if (!ok_flag)
+                       memset_io(lp->mem_ptr_virt, 0, HP100_MIN_PACKET_SIZE - skb->len);
        } else {                /* programmed i/o */
                outsl(ioaddr + HP100_REG_DATA32, skb->data,
                      (skb->len + 3) >> 2);
@@ -1753,7 +1762,7 @@ static void hp100_rx(struct net_device *dev)
 {
        int packets, pkt_len;
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        u_int header;
        struct sk_buff *skb;
 
@@ -1783,10 +1792,7 @@ static void hp100_rx(struct net_device *dev)
                /* First we get the header, which contains information about the */
                /* actual length of the received packet. */
                if (lp->mode == 2) {    /* memory mapped mode */
-                       if (lp->mem_ptr_virt)   /* if memory was remapped */
-                               header = readl(lp->mem_ptr_virt);
-                       else
-                               header = isa_readl(lp->mem_ptr_phys);
+                       header = readl(lp->mem_ptr_virt);
                } else          /* programmed i/o */
                        header = hp100_inl(DATA32);
 
@@ -1818,13 +1824,9 @@ static void hp100_rx(struct net_device *dev)
                        ptr = skb->data;
 
                        /* Now transfer the data from the card into that area */
-                       if (lp->mode == 2) {
-                               if (lp->mem_ptr_virt)
-                                       memcpy_fromio(ptr, lp->mem_ptr_virt,pkt_len);
-                               /* Note alignment to 32bit transfers */
-                               else
-                                       isa_memcpy_fromio(ptr, lp->mem_ptr_phys, pkt_len);
-                       } else  /* io mapped */
+                       if (lp->mode == 2)
+                               memcpy_fromio(ptr, lp->mem_ptr_virt,pkt_len);
+                       else    /* io mapped */
                                insl(ioaddr + HP100_REG_DATA32, ptr, pkt_len >> 2);
 
                        skb->protocol = eth_type_trans(skb, dev);
@@ -1862,7 +1864,7 @@ static void hp100_rx(struct net_device *dev)
 static void hp100_rx_bm(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        hp100_ring_t *ptr;
        u_int header;
        int pkt_len;
@@ -1971,7 +1973,7 @@ static struct net_device_stats *hp100_get_stats(struct net_device *dev)
 {
        unsigned long flags;
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4215, TRACE);
@@ -1989,7 +1991,7 @@ static void hp100_update_stats(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
        u_short val;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4216, TRACE);
@@ -2015,7 +2017,7 @@ static void hp100_misc_interrupt(struct net_device *dev)
 #ifdef HP100_DEBUG_B
        int ioaddr = dev->base_addr;
 #endif
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        int ioaddr = dev->base_addr;
@@ -2059,7 +2061,7 @@ static void hp100_set_multicast_list(struct net_device *dev)
 {
        unsigned long flags;
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4218, TRACE);
@@ -2189,7 +2191,7 @@ static void hp100_set_multicast_list(struct net_device *dev)
 static irqreturn_t hp100_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
        struct net_device *dev = (struct net_device *) dev_id;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
        int ioaddr;
        u_int val;
@@ -2320,7 +2322,7 @@ static void hp100_start_interface(struct net_device *dev)
 {
        unsigned long flags;
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4220, TRACE);
@@ -2379,7 +2381,7 @@ static void hp100_start_interface(struct net_device *dev)
 
 static void hp100_stop_interface(struct net_device *dev)
 {
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
        u_int val;
 
@@ -2440,7 +2442,7 @@ static int hp100_sense_lan(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
        u_short val_VG, val_10;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4223, TRACE);
@@ -2486,7 +2488,7 @@ static int hp100_sense_lan(struct net_device *dev)
 
 static int hp100_down_vg_link(struct net_device *dev)
 {
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
        unsigned long time;
        long savelan, newlan;
@@ -2501,10 +2503,8 @@ static int hp100_down_vg_link(struct net_device *dev)
        do {
                if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST)
                        break;
-               if (!in_interrupt()) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(1);
-               }
+               if (!in_interrupt())
+                       schedule_timeout_interruptible(1);
        } while (time_after(time, jiffies));
 
        if (time_after_eq(jiffies, time))       /* no signal->no logout */
@@ -2520,10 +2520,8 @@ static int hp100_down_vg_link(struct net_device *dev)
        do {
                if (!(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST))
                        break;
-               if (!in_interrupt()) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(1);
-               }
+               if (!in_interrupt())
+                       schedule_timeout_interruptible(1);
        } while (time_after(time, jiffies));
 
 #ifdef HP100_DEBUG
@@ -2561,10 +2559,8 @@ static int hp100_down_vg_link(struct net_device *dev)
                do {
                        if (!(hp100_inb(MAC_CFG_4) & HP100_MAC_SEL_ST))
                                break;
-                       if (!in_interrupt()) {
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               schedule_timeout(1);
-                       }
+                       if (!in_interrupt())
+                               schedule_timeout_interruptible(1);
                } while (time_after(time, jiffies));
 
                hp100_orb(HP100_AUTO_MODE, MAC_CFG_3);  /* Autosel back on */
@@ -2575,10 +2571,8 @@ static int hp100_down_vg_link(struct net_device *dev)
        do {
                if ((hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) == 0)
                        break;
-               if (!in_interrupt()) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(1);
-               }
+               if (!in_interrupt())
+                       schedule_timeout_interruptible(1);
        } while (time_after(time, jiffies));
 
        if (time_before_eq(time, jiffies)) {
@@ -2590,10 +2584,8 @@ static int hp100_down_vg_link(struct net_device *dev)
 
        time = jiffies + (2 * HZ);      /* This seems to take a while.... */
        do {
-               if (!in_interrupt()) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(1);
-               }
+               if (!in_interrupt())
+                       schedule_timeout_interruptible(1);
        } while (time_after(time, jiffies));
 
        return 0;
@@ -2602,7 +2594,7 @@ static int hp100_down_vg_link(struct net_device *dev)
 static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin)
 {
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
        u_short val = 0;
        unsigned long time;
        int startst;
@@ -2643,10 +2635,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin)
                do {
                        if (~(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST))
                                break;
-                       if (!in_interrupt()) {
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               schedule_timeout(1);
-                       }
+                       if (!in_interrupt())
+                               schedule_timeout_interruptible(1);
                } while (time_after(time, jiffies));
 
                /* Start an addressed training and optionally request promiscuous port */
@@ -2681,10 +2671,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin)
                do {
                        if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST)
                                break;
-                       if (!in_interrupt()) {
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               schedule_timeout(1);
-                       }
+                       if (!in_interrupt())
+                               schedule_timeout_interruptible(1);
                } while (time_before(jiffies, time));
 
                if (time_after_eq(jiffies, time)) {
@@ -2707,10 +2695,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin)
 #endif
                                        break;
                                }
-                               if (!in_interrupt()) {
-                                       set_current_state(TASK_INTERRUPTIBLE);
-                                       schedule_timeout(1);
-                               }
+                               if (!in_interrupt())
+                                       schedule_timeout_interruptible(1);
                        } while (time_after(time, jiffies));
                }
 
@@ -2773,7 +2759,7 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin)
 static void hp100_cascade_reset(struct net_device *dev, u_short enable)
 {
        int ioaddr = dev->base_addr;
-       struct hp100_private *lp = (struct hp100_private *) dev->priv;
+       struct hp100_private *lp = netdev_priv(dev);
 
 #ifdef HP100_DEBUG_B
        hp100_outw(0x4226, TRACE);
@@ -2834,7 +2820,7 @@ void hp100_RegisterDump(struct net_device *dev)
 
 static void cleanup_dev(struct net_device *d)
 {
-       struct hp100_private *p = (struct hp100_private *) d->priv;
+       struct hp100_private *p = netdev_priv(d);
 
        unregister_netdev(d);
        release_region(d->base_addr, HP100_REGION_SIZE);
@@ -2866,18 +2852,12 @@ static int __init hp100_eisa_probe (struct device *gendev)
        if (err)
                goto out1;
 
-       err = register_netdev(dev);
-       if (err)
-               goto out2;
-       
 #ifdef HP100_DEBUG
        printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name, 
               dev->base_addr);
 #endif
        gendev->driver_data = dev;
        return 0;
- out2:
-       release_region(dev->base_addr, HP100_REGION_SIZE);
  out1:
        free_netdev(dev);
        return err;
@@ -2904,13 +2884,19 @@ static struct eisa_driver hp100_eisa_driver = {
 static int __devinit hp100_pci_probe (struct pci_dev *pdev,
                                     const struct pci_device_id *ent)
 {
-       struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private));
-       int ioaddr = pci_resource_start(pdev, 0);
+       struct net_device *dev;
+       int ioaddr;
        u_short pci_command;
        int err;
-       
-       if (!dev)
-               return -ENOMEM;
+
+       if (pci_enable_device(pdev))
+               return -ENODEV;
+
+       dev = alloc_etherdev(sizeof(struct hp100_private));
+       if (!dev) {
+               err = -ENOMEM;
+               goto out0;
+       }
 
        SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
@@ -2932,23 +2918,20 @@ static int __devinit hp100_pci_probe (struct pci_dev *pdev,
                pci_write_config_word(pdev, PCI_COMMAND, pci_command);
        }
        
-
+       ioaddr = pci_resource_start(pdev, 0);
        err = hp100_probe1(dev, ioaddr, HP100_BUS_PCI, pdev);
        if (err) 
                goto out1;
-       err = register_netdev(dev);
-       if (err)
-               goto out2;
        
 #ifdef HP100_DEBUG
        printk("hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr);
 #endif
        pci_set_drvdata(pdev, dev);
        return 0;
- out2:
-       release_region(dev->base_addr, HP100_REGION_SIZE);
  out1:
        free_netdev(dev);
+ out0:
+       pci_disable_device(pdev);
        return err;
 }
 
@@ -2957,6 +2940,7 @@ static void __devexit hp100_pci_remove (struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
 
        cleanup_dev(dev);
+       pci_disable_device(pdev);
 }
 
 
@@ -2987,7 +2971,7 @@ MODULE_DESCRIPTION("HP CASCADE Architecture Driver for 100VG-AnyLan Network Adap
 #define HP100_DEVICES 5
 /* Parameters set by insmod */
 static int hp100_port[HP100_DEVICES] = { 0, [1 ... (HP100_DEVICES-1)] = -1 };
-MODULE_PARM(hp100_port, "1-" __MODULE_STRING(HP100_DEVICES) "i");
+module_param_array(hp100_port, int, NULL, 0);
 
 /* List of devices */
 static struct net_device *hp100_devlist[HP100_DEVICES];
@@ -3014,15 +2998,9 @@ static int __init hp100_isa_init(void)
                SET_MODULE_OWNER(dev);
 
                err = hp100_isa_probe(dev, hp100_port[i]);
-               if (!err) {
-                       err = register_netdev(dev);
-                       if (!err) 
-                               hp100_devlist[cards++] = dev;
-                       else
-                               release_region(dev->base_addr, HP100_REGION_SIZE);
-               }
-
-               if (err)
+               if (!err)
+                       hp100_devlist[cards++] = dev;
+               else
                        free_netdev(dev);
        }