X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fnet%2Fwd.c;h=fa14255282afe96770d5b44cc887fbaba22814df;hb=1569d9e89a77d51750497dc23d303e27d0d9494d;hp=1f05d9bd05e40b30b80bfaa7c33e4b1a68f6ae14;hpb=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/net/wd.c b/drivers/net/wd.c index 1f05d9b..fa14255 100644 --- a/drivers/net/wd.c +++ b/drivers/net/wd.c @@ -61,7 +61,7 @@ static void wd_block_output(struct net_device *dev, int count, const unsigned char *buf, int start_page); static int wd_close(struct net_device *dev); - + #define WD_START_PG 0x00 /* First page of TX buffer */ #define WD03_STOP_PG 0x20 /* Last page +1 of RX ring */ #define WD13_STOP_PG 0x40 /* Last page +1 of RX ring */ @@ -75,7 +75,7 @@ static int wd_close(struct net_device *dev); #define WD_NIC_OFFSET 16 /* Offset to the 8390 from the base_addr. */ #define WD_IO_EXTENT 32 - + /* Probe for the WD8003 and WD8013. These cards have the station address PROM at I/O ports +8 to +13, with a checksum following. A Soundblaster can have the same checksum as an WDethercard, @@ -93,14 +93,12 @@ static int __init do_wd_probe(struct net_device *dev) int mem_start = dev->mem_start; int mem_end = dev->mem_end; - SET_MODULE_OWNER(dev); - if (base_addr > 0x1ff) { /* Check a user specified location. */ r = request_region(base_addr, WD_IO_EXTENT, "wd-probe"); if ( r == NULL) return -EBUSY; i = wd_probe1(dev, base_addr); - if (i != 0) + if (i != 0) release_region(base_addr, WD_IO_EXTENT); else r->name = dev->name; @@ -127,13 +125,6 @@ static int __init do_wd_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 - WD_NIC_OFFSET, WD_IO_EXTENT); - iounmap(ei_status.mem); -} - #ifndef MODULE struct net_device * __init wd_probe(int unit) { @@ -149,12 +140,7 @@ struct net_device * __init wd_probe(int unit) err = do_wd_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); @@ -164,11 +150,13 @@ out: static int __init wd_probe1(struct net_device *dev, int ioaddr) { int i; + int err; int checksum = 0; int ancient = 0; /* An old card without config registers. */ int word16 = 0; /* 0 = 8 bit, 1 = 16 bit */ const char *model_name; static unsigned version_printed; + DECLARE_MAC_BUF(mac); for (i = 0; i < 8; i++) checksum += inb(ioaddr + 8 + i); @@ -187,9 +175,11 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr) if (ei_debug && version_printed++ == 0) printk(version); - printk("%s: WD80x3 at %#3x,", dev->name, ioaddr); for (i = 0; i < 6; i++) - printk(" %2.2X", dev->dev_addr[i] = inb(ioaddr + 8 + i)); + dev->dev_addr[i] = inb(ioaddr + 8 + i); + + printk("%s: WD80x3 at %#3x, %s", + dev->name, ioaddr, print_mac(mac, dev->dev_addr)); /* The following PureData probe code was contributed by Mike Jagdis . Puredata does software @@ -283,7 +273,7 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr) a reliable way to trigger an interrupt. */ outb_p(E8390_NODMA + E8390_STOP, nic_addr); outb(0x00, nic_addr+EN0_IMR); /* Disable all intrs. */ - + irq_mask = probe_irq_on(); outb_p(0xff, nic_addr + EN0_IMR); /* Enable all interrupts. */ outb_p(0x00, nic_addr + EN0_RCNTLO); @@ -291,7 +281,7 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr) outb(E8390_RREAD+E8390_START, nic_addr); /* Trigger it... */ mdelay(20); dev->irq = probe_irq_off(irq_mask); - + outb_p(0x00, nic_addr+EN0_IMR); /* Mask all intrs. again. */ if (ei_debug > 2) @@ -356,7 +346,10 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr) outb(inb(ioaddr+4)|0x80, ioaddr+4); #endif - return 0; + err = register_netdev(dev); + if (err) + free_irq(dev->irq, dev); + return err; } static int @@ -441,7 +434,7 @@ wd_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_ memcpy_fromio(skb->data + semi_count, ei_status.mem + TX_PAGES * 256, count); } else { /* Packet is in one chunk -- we can copy + cksum. */ - eth_io_copy_and_sum(skb, xfer_start, count, 0); + memcpy_fromio(skb->data, xfer_start, count); } /* Turn off 16 bit access so that reboot works. ISA brain-damage */ @@ -486,7 +479,7 @@ wd_close(struct net_device *dev) return 0; } - + #ifdef MODULE #define MAX_WD_CARDS 4 /* Max number of wd cards per module */ static struct net_device *dev_wd[MAX_WD_CARDS]; @@ -508,8 +501,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; @@ -527,11 +520,8 @@ init_module(void) dev->mem_start = mem[this_dev]; dev->mem_end = mem_end[this_dev]; if (do_wd_probe(dev) == 0) { - if (register_netdev(dev) == 0) { - dev_wd[found++] = dev; - continue; - } - cleanup_card(dev); + dev_wd[found++] = dev; + continue; } free_netdev(dev); printk(KERN_WARNING "wd.c: No wd80x3 card found (i/o = 0x%x).\n", io[this_dev]); @@ -542,7 +532,14 @@ init_module(void) return -ENXIO; } -void +static void cleanup_card(struct net_device *dev) +{ + free_irq(dev->irq, dev); + release_region(dev->base_addr - WD_NIC_OFFSET, WD_IO_EXTENT); + iounmap(ei_status.mem); +} + +void __exit cleanup_module(void) { int this_dev;