X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fnet%2Flne390.c;h=646e89fc3562f975848af257b45249491db0f673;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=0aa574b109647e79fec8dbbfa72b23dae98b49ac;hpb=9bf4aaab3e101692164d49b7ca357651eb691cb6;p=linux-2.6.git diff --git a/drivers/net/lne390.c b/drivers/net/lne390.c index 0aa574b10..646e89fc3 100644 --- a/drivers/net/lne390.c +++ b/drivers/net/lne390.c @@ -145,14 +145,6 @@ static int __init do_lne390_probe(struct net_device *dev) return -ENODEV; } -static void cleanup_card(struct net_device *dev) -{ - free_irq(dev->irq, dev); - release_region(dev->base_addr, LNE390_IO_EXTENT); - if (ei_status.reg0) - iounmap((void *)dev->mem_start); -} - #ifndef MODULE struct net_device * __init lne390_probe(int unit) { @@ -168,12 +160,7 @@ struct net_device * __init lne390_probe(int unit) err = do_lne390_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); @@ -257,32 +244,22 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr) /* BEWARE!! Some dain-bramaged EISA SCUs will allow you to put the card mem within the region covered by `normal' RAM !!! + + ioremap() will fail in that case. */ - if (dev->mem_start > 1024*1024) { /* phys addr > 1MB */ - if (dev->mem_start < virt_to_phys(high_memory)) { - printk(KERN_CRIT "lne390.c: Card RAM overlaps with normal memory!!!\n"); - printk(KERN_CRIT "lne390.c: Use EISA SCU to set card memory below 1MB,\n"); - printk(KERN_CRIT "lne390.c: or to an address above 0x%lx.\n", virt_to_phys(high_memory)); - printk(KERN_CRIT "lne390.c: Driver NOT installed.\n"); - ret = -EINVAL; - goto cleanup; - } - dev->mem_start = (unsigned long)ioremap(dev->mem_start, LNE390_STOP_PG*0x100); - if (dev->mem_start == 0) { - printk(KERN_ERR "lne390.c: Unable to remap card memory above 1MB !!\n"); - printk(KERN_ERR "lne390.c: Try using EISA SCU to set memory below 1MB.\n"); - printk(KERN_ERR "lne390.c: Driver NOT installed.\n"); - ret = -EAGAIN; - goto cleanup; - } - ei_status.reg0 = 1; /* Use as remap flag */ - printk("lne390.c: remapped %dkB card memory to virtual address %#lx\n", - LNE390_STOP_PG/4, dev->mem_start); + ei_status.mem = ioremap(dev->mem_start, LNE390_STOP_PG*0x100); + if (!ei_status.mem) { + printk(KERN_ERR "lne390.c: Unable to remap card memory above 1MB !!\n"); + printk(KERN_ERR "lne390.c: Try using EISA SCU to set memory below 1MB.\n"); + printk(KERN_ERR "lne390.c: Driver NOT installed.\n"); + ret = -EAGAIN; + goto cleanup; } + printk("lne390.c: remapped %dkB card memory to virtual address %p\n", + LNE390_STOP_PG/4, ei_status.mem); - dev->mem_end = ei_status.rmem_end = dev->mem_start - + (LNE390_STOP_PG - LNE390_START_PG)*256; - ei_status.rmem_start = dev->mem_start + TX_PAGES*256; + dev->mem_start = (unsigned long)ei_status.mem; + dev->mem_end = dev->mem_start + (LNE390_STOP_PG - LNE390_START_PG)*256; /* The 8390 offset is zero for the LNE390 */ dev->base_addr = ioaddr; @@ -307,7 +284,14 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr) dev->poll_controller = ei_poll; #endif NS8390_init(dev, 0); + + ret = register_netdev(dev); + if (ret) + goto unmap; return 0; +unmap: + if (ei_status.reg0) + iounmap(ei_status.mem); cleanup: free_irq(dev->irq, dev); return ret; @@ -352,8 +336,8 @@ static void lne390_reset_8390(struct net_device *dev) static void lne390_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) { - unsigned long hdr_start = dev->mem_start + ((ring_page - LNE390_START_PG)<<8); - isa_memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr)); + void __iomem *hdr_start = ei_status.mem + ((ring_page - LNE390_START_PG)<<8); + memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr)); hdr->count = (hdr->count + 3) & ~3; /* Round up allocation. */ } @@ -366,27 +350,28 @@ lne390_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_ static void lne390_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) { - unsigned long xfer_start = dev->mem_start + ring_offset - (LNE390_START_PG<<8); + void __iomem *xfer_start = ei_status.mem + ring_offset - (LNE390_START_PG<<8); - if (xfer_start + count > ei_status.rmem_end) { + if (ring_offset + count > (LNE390_STOP_PG<<8)) { /* Packet wraps over end of ring buffer. */ - int semi_count = ei_status.rmem_end - xfer_start; - isa_memcpy_fromio(skb->data, xfer_start, semi_count); + int semi_count = (LNE390_STOP_PG<<8) - ring_offset; + memcpy_fromio(skb->data, xfer_start, semi_count); count -= semi_count; - isa_memcpy_fromio(skb->data + semi_count, ei_status.rmem_start, count); + memcpy_fromio(skb->data + semi_count, + ei_status.mem + (TX_PAGES<<8), count); } else { /* Packet is in one chunk. */ - isa_memcpy_fromio(skb->data, xfer_start, count); + memcpy_fromio(skb->data, xfer_start, count); } } static void lne390_block_output(struct net_device *dev, int count, const unsigned char *buf, int start_page) { - unsigned long shmem = dev->mem_start + ((start_page - LNE390_START_PG)<<8); + void __iomem *shmem = ei_status.mem + ((start_page - LNE390_START_PG)<<8); count = (count + 3) & ~3; /* Round up to doubleword */ - isa_memcpy_toio(shmem, buf, count); + memcpy_toio(shmem, buf, count); } static int lne390_open(struct net_device *dev) @@ -412,9 +397,9 @@ static int io[MAX_LNE_CARDS]; static int irq[MAX_LNE_CARDS]; static int mem[MAX_LNE_CARDS]; -MODULE_PARM(io, "1-" __MODULE_STRING(MAX_LNE_CARDS) "i"); -MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_LNE_CARDS) "i"); -MODULE_PARM(mem, "1-" __MODULE_STRING(MAX_LNE_CARDS) "i"); +module_param_array(io, int, NULL, 0); +module_param_array(irq, int, NULL, 0); +module_param_array(mem, 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)"); @@ -436,11 +421,8 @@ int init_module(void) dev->base_addr = io[this_dev]; dev->mem_start = mem[this_dev]; if (do_lne390_probe(dev) == 0) { - if (register_netdev(dev) == 0) { - dev_lne[found++] = dev; - continue; - } - cleanup_card(dev); + dev_lne[found++] = dev; + continue; } free_netdev(dev); printk(KERN_WARNING "lne390.c: No LNE390 card found (i/o = 0x%x).\n", io[this_dev]); @@ -451,6 +433,13 @@ int init_module(void) return -ENXIO; } +static void cleanup_card(struct net_device *dev) +{ + free_irq(dev->irq, dev); + release_region(dev->base_addr, LNE390_IO_EXTENT); + iounmap(ei_status.mem); +} + void cleanup_module(void) { int this_dev;