back ported version 3.66f tg3 driver
[linux-2.6.git] / drivers / net / ne2.c
index 739f92a..e6df375 100644 (file)
@@ -74,14 +74,16 @@ static const char *version = "ne2.c:v0.91 Nov 16 1998 Wim Dumon <wimpie@kotnet.o
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
 #include "8390.h"
 
+#define DRV_NAME "ne2"
+
 /* Some defines that people can play with if so inclined. */
 
 /* Do we perform extra sanity checks on stuff ? */
@@ -276,14 +278,7 @@ static int __init do_ne2_probe(struct net_device *dev)
        return -ENODEV;
 }
 
-static void cleanup_card(struct net_device *dev)
-{
-       mca_mark_as_unused(ei_status.priv);
-       mca_set_adapter_procfn( ei_status.priv, NULL, NULL);
-       free_irq(dev->irq, dev);
-       release_region(dev->base_addr, NE_IO_EXTENT);
-}
-
+#ifndef MODULE
 struct net_device * __init ne2_probe(int unit)
 {
        struct net_device *dev = alloc_ei_netdev();
@@ -298,16 +293,12 @@ struct net_device * __init ne2_probe(int unit)
        err = do_ne2_probe(dev);
        if (err)
                goto out;
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
        return dev;
-out1:
-       cleanup_card(dev);
 out:
        free_netdev(dev);
        return ERR_PTR(err);
 }
+#endif
 
 static int ne2_procinfo(char *buf, int slot, struct net_device *dev)
 {
@@ -368,7 +359,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
                irq = irqs[(POS & 0x60)>>5];
        }
 
-       if (!request_region(base_addr, NE_IO_EXTENT, dev->name))
+       if (!request_region(base_addr, NE_IO_EXTENT, DRV_NAME))
                return -EBUSY;
 
 #ifdef DEBUG
@@ -470,7 +461,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
 
        /* Snarf the interrupt now.  There's no point in waiting since we cannot
           share and the board will usually be enabled. */
-       retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev);
+       retval = request_irq(dev->irq, ei_interrupt, 0, DRV_NAME, dev);
        if (retval) {
                printk (" unable to get IRQ %d (irqval=%d).\n", 
                                dev->irq, retval);
@@ -513,7 +504,14 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
        dev->poll_controller = ei_poll;
 #endif
        NS8390_init(dev, 0);
+
+       retval = register_netdev(dev);
+       if (retval)
+               goto out1;
        return 0;
+out1:
+       mca_set_adapter_procfn( ei_status.priv, NULL, NULL);
+       free_irq(dev->irq, dev);
 out:
        release_region(base_addr, NE_IO_EXTENT);
        return retval;
@@ -772,14 +770,12 @@ static int irq[MAX_NE_CARDS];
 static int bad[MAX_NE_CARDS];  /* 0xbad = bad sig or no reset ack */
 MODULE_LICENSE("GPL");
 
-#ifdef MODULE_PARM
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(bad, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
+module_param_array(io, int, NULL, 0);
+module_param_array(irq, int, NULL, 0);
+module_param_array(bad, int, NULL, 0);
 MODULE_PARM_DESC(io, "(ignored)");
 MODULE_PARM_DESC(irq, "(ignored)");
 MODULE_PARM_DESC(bad, "(ignored)");
-#endif
 
 /* Module code fixed by David Weinehall */
 
@@ -796,11 +792,8 @@ int init_module(void)
                dev->mem_end = bad[this_dev];
                dev->base_addr = io[this_dev];
                if (do_ne2_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_ne[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_ne[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                break;
@@ -811,6 +804,14 @@ int init_module(void)
        return -ENXIO;
 }
 
+static void cleanup_card(struct net_device *dev)
+{
+       mca_mark_as_unused(ei_status.priv);
+       mca_set_adapter_procfn( ei_status.priv, NULL, NULL);
+       free_irq(dev->irq, dev);
+       release_region(dev->base_addr, NE_IO_EXTENT);
+}
+
 void cleanup_module(void)
 {
        int this_dev;