fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / ne2.c
index e6df375..089b5bb 100644 (file)
@@ -28,7 +28,7 @@
    - added support for Arco Electronics AE/2-card (experimental)
 
    Mon Sep 14 09:53:42 CET 1998 (David Weinehall)
-   - added support for Compex ENET-16MC/P (experimental) 
+   - added support for Compex ENET-16MC/P (experimental)
 
    Tue Sep 15 16:21:12 CET 1998 (David Weinehall, Magnus Jonsson, Tomas Ogren)
    - Miscellaneous bugfixes
    - Version# bump
 
    Mon Nov 16 15:28:23 CET 1998 (Wim Dumon)
-   - pass 'dev' as last parameter of request_irq in stead of 'NULL'   
+   - pass 'dev' as last parameter of request_irq in stead of 'NULL'
 
    Wed Feb  7 21:24:00 CET 2001 (Alfred Arnold)
    - added support for the D-Link DE-320CT
-   
+
    *    WARNING
        -------
        This is alpha-test software.  It is not guaranteed to work. As a
@@ -75,6 +75,7 @@ static const char *version = "ne2.c:v0.91 Nov 16 1998 Wim Dumon <wimpie@kotnet.o
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/bitops.h>
+#include <linux/jiffies.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -149,9 +150,9 @@ static void ne_block_output(struct net_device *dev, const int count,
 
 
 /*
- * special code to read the DE-320's MAC address EEPROM.  In contrast to a 
+ * special code to read the DE-320's MAC address EEPROM.  In contrast to a
  * standard NE design, this is a serial EEPROM (93C46) that has to be read
- * bit by bit.  The EEPROM cotrol port at base + 0x1e has the following 
+ * bit by bit.  The EEPROM cotrol port at base + 0x1e has the following
  * layout:
  *
  * Bit 0 = Data out (read from EEPROM)
@@ -217,7 +218,7 @@ static unsigned int __init dlink_get_eeprom(unsigned int eeaddr, unsigned int ad
 {
        int z;
        unsigned int value = 0;
+
        /* pull the CS line low for a moment.  This resets the EEPROM-
           internal logic, and makes it ready for a new command. */
 
@@ -252,23 +253,23 @@ static int __init do_ne2_probe(struct net_device *dev)
 
        SET_MODULE_OWNER(dev);
 
-       /* Do not check any supplied i/o locations. 
+       /* Do not check any supplied i/o locations.
           POS registers usually don't fail :) */
 
-       /* MCA cards have POS registers.  
-          Autodetecting MCA cards is extremely simple. 
+       /* MCA cards have POS registers.
+          Autodetecting MCA cards is extremely simple.
           Just search for the card. */
 
        for(i = 0; (ne2_adapters[i].name != NULL) && !adapter_found; i++) {
-               current_mca_slot = 
+               current_mca_slot =
                        mca_find_unused_adapter(ne2_adapters[i].id, 0);
 
                if((current_mca_slot != MCA_NOTFOUND) && !adapter_found) {
                        int res;
-                       mca_set_adapter_name(current_mca_slot, 
+                       mca_set_adapter_name(current_mca_slot,
                                        ne2_adapters[i].name);
                        mca_mark_as_used(current_mca_slot);
-                       
+
                        res = ne2_probe1(dev, current_mca_slot);
                        if (res)
                                mca_mark_as_unused(current_mca_slot);
@@ -306,7 +307,7 @@ static int ne2_procinfo(char *buf, int slot, struct net_device *dev)
 
        len += sprintf(buf+len, "The NE/2 Ethernet Adapter\n" );
        len += sprintf(buf+len, "Driver written by Wim Dumon ");
-       len += sprintf(buf+len, "<wimpie@kotnet.org>\n"); 
+       len += sprintf(buf+len, "<wimpie@kotnet.org>\n");
        len += sprintf(buf+len, "Modified by ");
        len += sprintf(buf+len, "David Weinehall <tao@acc.umu.se>\n");
        len += sprintf(buf+len, "and by Magnus Jonsson <bigfoot@acc.umu.se>\n");
@@ -315,8 +316,8 @@ static int ne2_procinfo(char *buf, int slot, struct net_device *dev)
        len += sprintf(buf+len, "IRQ    : %d\n", dev->irq);
 
 #define HW_ADDR(i) dev->dev_addr[i]
-       len += sprintf(buf+len, "HW addr : %x:%x:%x:%x:%x:%x\n", 
-                       HW_ADDR(0), HW_ADDR(1), HW_ADDR(2), 
+       len += sprintf(buf+len, "HW addr : %x:%x:%x:%x:%x:%x\n",
+                       HW_ADDR(0), HW_ADDR(1), HW_ADDR(2),
                        HW_ADDR(3), HW_ADDR(4), HW_ADDR(5) );
 #undef HW_ADDR
 
@@ -369,7 +370,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
 
 #ifndef CRYNWR_WAY
        /* Reset the card the way they do it in the Crynwr packet driver */
-       for (i=0; i<8; i++) 
+       for (i=0; i<8; i++)
                outb(0x0, base_addr + NE_RESET);
        inb(base_addr + NE_RESET);
        outb(0x21, base_addr + NE_CMD);
@@ -387,15 +388,15 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
 
 #else  /* _I_ never tested it this way .. Go ahead and try ...*/
        /* Reset card. Who knows what dain-bramaged state it was left in. */
-       { 
+       {
                unsigned long reset_start_time = jiffies;
 
-               /* DON'T change these to inb_p/outb_p or reset will fail on 
+               /* DON'T change these to inb_p/outb_p or reset will fail on
                   clones.. */
                outb(inb(base_addr + NE_RESET), base_addr + NE_RESET);
 
                while ((inb_p(base_addr + EN0_ISR) & ENISR_RESET) == 0)
-                       if (jiffies - reset_start_time > 2*HZ/100) {
+                       if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
                                printk(" not found (no reset ack).\n");
                                retval = -ENODEV;
                                goto out;
@@ -407,16 +408,16 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
 
 
        /* Read the 16 bytes of station address PROM.
-          We must first initialize registers, similar to 
+          We must first initialize registers, similar to
           NS8390_init(eifdev, 0).
           We can't reliably read the SAPROM address without this.
           (I learned the hard way!). */
        {
-               struct { 
-                       unsigned char value, offset; 
+               struct {
+                       unsigned char value, offset;
                } program_seq[] = {
                                                /* Select page 0 */
-                       {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, 
+                       {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD},
                        {0x49,  EN0_DCFG},  /* Set WORD-wide (0x49) access. */
                        {0x00,  EN0_RCNTLO},  /* Clear the count regs. */
                        {0x00,  EN0_RCNTHI},
@@ -432,7 +433,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
                };
 
                for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
-                       outb_p(program_seq[i].value, base_addr + 
+                       outb_p(program_seq[i].value, base_addr +
                                program_seq[i].offset);
 
        }
@@ -463,7 +464,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
           share and the board will usually be enabled. */
        retval = request_irq(dev->irq, ei_interrupt, 0, DRV_NAME, dev);
        if (retval) {
-               printk (" unable to get IRQ %d (irqval=%d).\n", 
+               printk (" unable to get IRQ %d (irqval=%d).\n",
                                dev->irq, retval);
                goto out;
        }
@@ -495,9 +496,9 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
        ei_status.block_input = &ne_block_input;
        ei_status.block_output = &ne_block_output;
        ei_status.get_8390_hdr = &ne_get_8390_hdr;
-       
+
        ei_status.priv = slot;
-       
+
        dev->open = &ne_open;
        dev->stop = &ne_close;
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -537,7 +538,7 @@ static void ne_reset_8390(struct net_device *dev)
 {
        unsigned long reset_start_time = jiffies;
 
-       if (ei_debug > 1) 
+       if (ei_debug > 1)
                printk("resetting the 8390 t=%ld...", jiffies);
 
        /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
@@ -548,8 +549,8 @@ static void ne_reset_8390(struct net_device *dev)
 
        /* This check _should_not_ be necessary, omit eventually. */
        while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
-               if (jiffies - reset_start_time > 2*HZ/100) {
-                       printk("%s: ne_reset_8390() did not complete.\n", 
+               if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
+                       printk("%s: ne_reset_8390() did not complete.\n",
                                        dev->name);
                        break;
                }
@@ -560,13 +561,13 @@ static void ne_reset_8390(struct net_device *dev)
    we don't need to be concerned with ring wrap as the header will be at
    the start of a page, so we optimize accordingly. */
 
-static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, 
+static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
                int ring_page)
 {
 
        int nic_base = dev->base_addr;
 
-       /* This *shouldn't* happen. 
+       /* This *shouldn't* happen.
           If it does, it's the last thing you'll see */
        if (ei_status.dmaing) {
                printk("%s: DMAing conflict in ne_get_8390_hdr "
@@ -584,10 +585,10 @@ static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
        outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
 
        if (ei_status.word16)
-               insw(NE_BASE + NE_DATAPORT, hdr, 
+               insw(NE_BASE + NE_DATAPORT, hdr,
                                sizeof(struct e8390_pkt_hdr)>>1);
        else
-               insb(NE_BASE + NE_DATAPORT, hdr, 
+               insb(NE_BASE + NE_DATAPORT, hdr,
                                sizeof(struct e8390_pkt_hdr));
 
        outb_p(ENISR_RDC, nic_base + EN0_ISR);  /* Ack intr. */
@@ -599,7 +600,7 @@ static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
    hints. The NEx000 doesn't share the on-board packet memory -- you have
    to put the packet out through the "remote DMA" dataport using outb. */
 
-static void ne_block_input(struct net_device *dev, int count, struct sk_buff *skb, 
+static void ne_block_input(struct net_device *dev, int count, struct sk_buff *skb,
                int ring_offset)
 {
 #ifdef NE_SANITY_CHECK
@@ -608,7 +609,7 @@ static void ne_block_input(struct net_device *dev, int count, struct sk_buff *sk
        int nic_base = dev->base_addr;
        char *buf = skb->data;
 
-       /* This *shouldn't* happen. 
+       /* This *shouldn't* happen.
           If it does, it's the last thing you'll see */
        if (ei_status.dmaing) {
                printk("%s: DMAing conflict in ne_block_input "
@@ -676,7 +677,7 @@ static void ne_block_output(struct net_device *dev, int count,
        if (ei_status.word16 && (count & 0x01))
                count++;
 
-       /* This *shouldn't* happen. 
+       /* This *shouldn't* happen.
           If it does, it's the last thing you'll see */
        if (ei_status.dmaing) {
                printk("%s: DMAing conflict in ne_block_output."
@@ -749,7 +750,7 @@ retry:
 #endif
 
        while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
-               if (jiffies - dma_start > 2*HZ/100) {           /* 20ms */
+               if (time_after(jiffies, dma_start + 2*HZ/100)) {                /* 20ms */
                        printk("%s: timeout waiting for Tx RDC.\n", dev->name);
                        ne_reset_8390(dev);
                        NS8390_init(dev,1);
@@ -779,7 +780,7 @@ MODULE_PARM_DESC(bad, "(ignored)");
 
 /* Module code fixed by David Weinehall */
 
-int init_module(void)
+int __init init_module(void)
 {
        struct net_device *dev;
        int this_dev, found = 0;
@@ -812,7 +813,7 @@ static void cleanup_card(struct net_device *dev)
        release_region(dev->base_addr, NE_IO_EXTENT);
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;