fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / e2100.c
index 71c632b..c62d9c6 100644 (file)
@@ -51,6 +51,8 @@ static const char version[] =
 
 #include "8390.h"
 
+#define DRV_NAME "e2100"
+
 static int e21_probe_list[] = {0x300, 0x280, 0x380, 0x220, 0};
 
 /* Offsets from the base_addr.
@@ -70,7 +72,7 @@ static int e21_probe_list[] = {0x300, 0x280, 0x380, 0x220, 0};
 #define E21_SAPROM             0x10    /* Offset to station address data. */
 #define E21_IO_EXTENT   0x20
 
-static inline void mem_on(short port, volatile char *mem_base,
+static inline void mem_on(short port, volatile char __iomem *mem_base,
                                                  unsigned char start_page )
 {
        /* This is a little weird: set the shared memory window by doing a
@@ -108,7 +110,7 @@ static void e21_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
 
 static int e21_close(struct net_device *dev);
 
-\f
+
 /*  Probe for the E2100 series ethercards.  These cards have an 8390 at the
        base address and the station address at both offset 0x10 and 0x18.  I read
        the station address from offset 0x18 to avoid the dataport of NE2000
@@ -138,12 +140,7 @@ static int  __init do_e2100_probe(struct net_device *dev)
        return -ENODEV;
 }
 
-static void cleanup_card(struct net_device *dev)
-{
-       /* NB: e21_close() handles free_irq */
-       release_region(dev->base_addr, E21_IO_EXTENT);
-}
-
+#ifndef MODULE
 struct net_device * __init e2100_probe(int unit)
 {
        struct net_device *dev = alloc_ei_netdev();
@@ -158,16 +155,12 @@ struct net_device * __init e2100_probe(int unit)
        err = do_e2100_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 __init e21_probe1(struct net_device *dev, int ioaddr)
 {
@@ -175,7 +168,7 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
        unsigned char *station_addr = dev->dev_addr;
        static unsigned version_printed;
 
-       if (!request_region(ioaddr, E21_IO_EXTENT, dev->name))
+       if (!request_region(ioaddr, E21_IO_EXTENT, DRV_NAME))
                return -EBUSY;
 
        /* First check the station address for the Ctron prefix. */
@@ -253,6 +246,13 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
        if (dev->mem_start == 0)
                dev->mem_start = 0xd0000;
 
+       ei_status.mem = ioremap(dev->mem_start, 2*1024);
+       if (!ei_status.mem) {
+               printk("unable to remap memory\n");
+               retval = -EAGAIN;
+               goto out;
+       }
+
 #ifdef notdef
        /* These values are unused.  The E2100 has a 2K window into the packet
           buffer.  The window can be set to start on any page boundary. */
@@ -274,6 +274,9 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
 #endif
        NS8390_init(dev, 0);
 
+       retval = register_netdev(dev);
+       if (retval)
+               goto out;
        return 0;
 out:
        release_region(ioaddr, E21_IO_EXTENT);
@@ -325,7 +328,7 @@ e21_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_pag
 {
 
        short ioaddr = dev->base_addr;
-       char *shared_mem = (char *)dev->mem_start;
+       char __iomem *shared_mem = ei_status.mem;
 
        mem_on(ioaddr, shared_mem, ring_page);
 
@@ -348,12 +351,12 @@ static void
 e21_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
 {
        short ioaddr = dev->base_addr;
-       char *shared_mem = (char *)dev->mem_start;
+       char __iomem *shared_mem = ei_status.mem;
 
        mem_on(ioaddr, shared_mem, (ring_offset>>8));
 
        /* Packet is always in one chunk -- we can copy + cksum. */
-       eth_io_copy_and_sum(skb, dev->mem_start + (ring_offset & 0xff), count, 0);
+       eth_io_copy_and_sum(skb, ei_status.mem + (ring_offset & 0xff), count, 0);
 
        mem_off(ioaddr);
 }
@@ -363,7 +366,7 @@ e21_block_output(struct net_device *dev, int count, const unsigned char *buf,
                                 int start_page)
 {
        short ioaddr = dev->base_addr;
-       volatile char *shared_mem = (char *)dev->mem_start;
+       volatile char __iomem *shared_mem = ei_status.mem;
 
        /* Set the shared memory window start by doing a read, with the low address
           bits specifying the starting page. */
@@ -400,7 +403,7 @@ e21_close(struct net_device *dev)
        return 0;
 }
 
-\f
+
 #ifdef MODULE
 #define MAX_E21_CARDS  4       /* Max number of E21 cards per module */
 static struct net_device *dev_e21[MAX_E21_CARDS];
@@ -409,10 +412,10 @@ static int irq[MAX_E21_CARDS];
 static int mem[MAX_E21_CARDS];
 static int xcvr[MAX_E21_CARDS];                /* choose int. or ext. xcvr */
 
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_E21_CARDS) "i");
-MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_E21_CARDS) "i");
-MODULE_PARM(mem, "1-" __MODULE_STRING(MAX_E21_CARDS) "i");
-MODULE_PARM(xcvr, "1-" __MODULE_STRING(MAX_E21_CARDS) "i");
+module_param_array(io, int, NULL, 0);
+module_param_array(irq, int, NULL, 0);
+module_param_array(mem, int, NULL, 0);
+module_param_array(xcvr, int, NULL, 0);
 MODULE_PARM_DESC(io, "I/O base address(es)");
 MODULE_PARM_DESC(irq, "IRQ number(s)");
 MODULE_PARM_DESC(mem, " memory base address(es)");
@@ -422,8 +425,8 @@ MODULE_LICENSE("GPL");
 
 /* This is set up so that only a single autoprobe takes place per call.
 ISA device autoprobes on a running machine are not recommended. */
-int
-init_module(void)
+
+int __init init_module(void)
 {
        struct net_device *dev;
        int this_dev, found = 0;
@@ -441,11 +444,8 @@ init_module(void)
                dev->mem_start = mem[this_dev];
                dev->mem_end = xcvr[this_dev];  /* low 4bits = xcvr sel. */
                if (do_e2100_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_e21[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_e21[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]);
@@ -456,7 +456,14 @@ init_module(void)
        return -ENXIO;
 }
 
-void
+static void cleanup_card(struct net_device *dev)
+{
+       /* NB: e21_close() handles free_irq */
+       iounmap(ei_status.mem);
+       release_region(dev->base_addr, E21_IO_EXTENT);
+}
+
+void __exit
 cleanup_module(void)
 {
        int this_dev;