aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
author <herbert@gondor.apana.org.au>2005-05-12 20:11:55 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-05-12 20:11:55 -0400
commitb1fc5505e0dbcc3fd7c75bfe6bee39ec50080963 (patch)
treef8c0bb679dc8e72816e16820c3dbcccf924097eb /drivers
parent88d7bd8cb9eb8d64bf7997600b0d64f7834047c5 (diff)
[netdrvr] Fix register_netdev() races in older ISA net drivers
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/3c503.c16
-rw-r--r--drivers/net/3c515.c12
-rw-r--r--drivers/net/3c523.c18
-rw-r--r--drivers/net/ac3200.c19
-rw-r--r--drivers/net/cs89x0.c19
-rw-r--r--drivers/net/e2100.c15
-rw-r--r--drivers/net/eepro.c21
-rw-r--r--drivers/net/eexpress.c12
-rw-r--r--drivers/net/es3210.c16
-rw-r--r--drivers/net/eth16i.c20
-rw-r--r--drivers/net/hp-plus.c15
-rw-r--r--drivers/net/hp.c17
-rw-r--r--drivers/net/hp100.c41
-rw-r--r--drivers/net/isa-skeleton.c20
-rw-r--r--drivers/net/lance.c15
-rw-r--r--drivers/net/lne390.c19
-rw-r--r--drivers/net/ne-h8300.c19
-rw-r--r--drivers/net/ne.c18
-rw-r--r--drivers/net/ne2.c19
-rw-r--r--drivers/net/smc-ultra.c15
-rw-r--r--drivers/net/wd.c18
21 files changed, 156 insertions, 228 deletions
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index 29dfd47f41d2..5c5eebdb6914 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -171,12 +171,7 @@ struct net_device * __init el2_probe(int unit)
171 err = do_el2_probe(dev); 171 err = do_el2_probe(dev);
172 if (err) 172 if (err)
173 goto out; 173 goto out;
174 err = register_netdev(dev);
175 if (err)
176 goto out1;
177 return dev; 174 return dev;
178out1:
179 cleanup_card(dev);
180out: 175out:
181 free_netdev(dev); 176 free_netdev(dev);
182 return ERR_PTR(err); 177 return ERR_PTR(err);
@@ -356,6 +351,10 @@ el2_probe1(struct net_device *dev, int ioaddr)
356 dev->poll_controller = ei_poll; 351 dev->poll_controller = ei_poll;
357#endif 352#endif
358 353
354 retval = register_netdev(dev);
355 if (retval)
356 goto out1;
357
359 if (dev->mem_start) 358 if (dev->mem_start)
360 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n", 359 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
361 dev->name, ei_status.name, (wordlength+1)<<3, 360 dev->name, ei_status.name, (wordlength+1)<<3,
@@ -715,11 +714,8 @@ init_module(void)
715 dev->base_addr = io[this_dev]; 714 dev->base_addr = io[this_dev];
716 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */ 715 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
717 if (do_el2_probe(dev) == 0) { 716 if (do_el2_probe(dev) == 0) {
718 if (register_netdev(dev) == 0) { 717 dev_el2[found++] = dev;
719 dev_el2[found++] = dev; 718 continue;
720 continue;
721 }
722 cleanup_card(dev);
723 } 719 }
724 free_netdev(dev); 720 free_netdev(dev);
725 printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]); 721 printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index c4cf4fcd1344..d272ea36a578 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -365,7 +365,7 @@ static int nopnp;
365#endif /* __ISAPNP__ */ 365#endif /* __ISAPNP__ */
366 366
367static struct net_device *corkscrew_scan(int unit); 367static struct net_device *corkscrew_scan(int unit);
368static void corkscrew_setup(struct net_device *dev, int ioaddr, 368static int corkscrew_setup(struct net_device *dev, int ioaddr,
369 struct pnp_dev *idev, int card_number); 369 struct pnp_dev *idev, int card_number);
370static int corkscrew_open(struct net_device *dev); 370static int corkscrew_open(struct net_device *dev);
371static void corkscrew_timer(unsigned long arg); 371static void corkscrew_timer(unsigned long arg);
@@ -539,10 +539,9 @@ static struct net_device *corkscrew_scan(int unit)
539 printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n", 539 printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n",
540 inl(ioaddr + 0x2002), inw(ioaddr + 0x2000)); 540 inl(ioaddr + 0x2002), inw(ioaddr + 0x2000));
541 /* irq = inw(ioaddr + 0x2002) & 15; */ /* Use the irq from isapnp */ 541 /* irq = inw(ioaddr + 0x2002) & 15; */ /* Use the irq from isapnp */
542 corkscrew_setup(dev, ioaddr, idev, cards_found++);
543 SET_NETDEV_DEV(dev, &idev->dev); 542 SET_NETDEV_DEV(dev, &idev->dev);
544 pnp_cards++; 543 pnp_cards++;
545 err = register_netdev(dev); 544 err = corkscrew_setup(dev, ioaddr, idev, cards_found++);
546 if (!err) 545 if (!err)
547 return dev; 546 return dev;
548 cleanup_card(dev); 547 cleanup_card(dev);
@@ -558,8 +557,7 @@ no_pnp:
558 557
559 printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n", 558 printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n",
560 inl(ioaddr + 0x2002), inw(ioaddr + 0x2000)); 559 inl(ioaddr + 0x2002), inw(ioaddr + 0x2000));
561 corkscrew_setup(dev, ioaddr, NULL, cards_found++); 560 err = corkscrew_setup(dev, ioaddr, NULL, cards_found++);
562 err = register_netdev(dev);
563 if (!err) 561 if (!err)
564 return dev; 562 return dev;
565 cleanup_card(dev); 563 cleanup_card(dev);
@@ -568,7 +566,7 @@ no_pnp:
568 return NULL; 566 return NULL;
569} 567}
570 568
571static void corkscrew_setup(struct net_device *dev, int ioaddr, 569static int corkscrew_setup(struct net_device *dev, int ioaddr,
572 struct pnp_dev *idev, int card_number) 570 struct pnp_dev *idev, int card_number)
573{ 571{
574 struct corkscrew_private *vp = netdev_priv(dev); 572 struct corkscrew_private *vp = netdev_priv(dev);
@@ -691,6 +689,8 @@ static void corkscrew_setup(struct net_device *dev, int ioaddr,
691 dev->get_stats = &corkscrew_get_stats; 689 dev->get_stats = &corkscrew_get_stats;
692 dev->set_multicast_list = &set_rx_mode; 690 dev->set_multicast_list = &set_rx_mode;
693 dev->ethtool_ops = &netdev_ethtool_ops; 691 dev->ethtool_ops = &netdev_ethtool_ops;
692
693 return register_netdev(dev);
694} 694}
695 695
696 696
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index 8f6b2fa13e28..1247a25f1093 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -572,6 +572,10 @@ static int __init do_elmc_probe(struct net_device *dev)
572 dev->flags&=~IFF_MULTICAST; /* Multicast doesn't work */ 572 dev->flags&=~IFF_MULTICAST; /* Multicast doesn't work */
573#endif 573#endif
574 574
575 retval = register_netdev(dev);
576 if (retval)
577 goto err_out;
578
575 return 0; 579 return 0;
576err_out: 580err_out:
577 mca_set_adapter_procfn(slot, NULL, NULL); 581 mca_set_adapter_procfn(slot, NULL, NULL);
@@ -600,12 +604,7 @@ struct net_device * __init elmc_probe(int unit)
600 err = do_elmc_probe(dev); 604 err = do_elmc_probe(dev);
601 if (err) 605 if (err)
602 goto out; 606 goto out;
603 err = register_netdev(dev);
604 if (err)
605 goto out1;
606 return dev; 607 return dev;
607out1:
608 cleanup_card(dev);
609out: 608out:
610 free_netdev(dev); 609 free_netdev(dev);
611 return ERR_PTR(err); 610 return ERR_PTR(err);
@@ -1288,12 +1287,9 @@ int init_module(void)
1288 dev->irq=irq[this_dev]; 1287 dev->irq=irq[this_dev];
1289 dev->base_addr=io[this_dev]; 1288 dev->base_addr=io[this_dev];
1290 if (do_elmc_probe(dev) == 0) { 1289 if (do_elmc_probe(dev) == 0) {
1291 if (register_netdev(dev) == 0) { 1290 dev_elmc[this_dev] = dev;
1292 dev_elmc[this_dev] = dev; 1291 found++;
1293 found++; 1292 continue;
1294 continue;
1295 }
1296 cleanup_card(dev);
1297 } 1293 }
1298 free_netdev(dev); 1294 free_netdev(dev);
1299 if (io[this_dev]==0) 1295 if (io[this_dev]==0)
diff --git a/drivers/net/ac3200.c b/drivers/net/ac3200.c
index 24fba36b5c1d..91791ba37769 100644
--- a/drivers/net/ac3200.c
+++ b/drivers/net/ac3200.c
@@ -146,12 +146,7 @@ struct net_device * __init ac3200_probe(int unit)
146 err = do_ac3200_probe(dev); 146 err = do_ac3200_probe(dev);
147 if (err) 147 if (err)
148 goto out; 148 goto out;
149 err = register_netdev(dev);
150 if (err)
151 goto out1;
152 return dev; 149 return dev;
153out1:
154 cleanup_card(dev);
155out: 150out:
156 free_netdev(dev); 151 free_netdev(dev);
157 return ERR_PTR(err); 152 return ERR_PTR(err);
@@ -273,7 +268,14 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
273 dev->poll_controller = ei_poll; 268 dev->poll_controller = ei_poll;
274#endif 269#endif
275 NS8390_init(dev, 0); 270 NS8390_init(dev, 0);
271
272 retval = register_netdev(dev);
273 if (retval)
274 goto out2;
276 return 0; 275 return 0;
276out2:
277 if (ei_status.reg0)
278 iounmap((void *)dev->mem_start);
277out1: 279out1:
278 free_irq(dev->irq, dev); 280 free_irq(dev->irq, dev);
279out: 281out:
@@ -392,11 +394,8 @@ init_module(void)
392 dev->base_addr = io[this_dev]; 394 dev->base_addr = io[this_dev];
393 dev->mem_start = mem[this_dev]; /* Currently ignored by driver */ 395 dev->mem_start = mem[this_dev]; /* Currently ignored by driver */
394 if (do_ac3200_probe(dev) == 0) { 396 if (do_ac3200_probe(dev) == 0) {
395 if (register_netdev(dev) == 0) { 397 dev_ac32[found++] = dev;
396 dev_ac32[found++] = dev; 398 continue;
397 continue;
398 }
399 cleanup_card(dev);
400 } 399 }
401 free_netdev(dev); 400 free_netdev(dev);
402 printk(KERN_WARNING "ac3200.c: No ac3200 card found (i/o = 0x%x).\n", io[this_dev]); 401 printk(KERN_WARNING "ac3200.c: No ac3200 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index 5c5f540da26a..25e4495de79e 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -319,13 +319,7 @@ struct net_device * __init cs89x0_probe(int unit)
319 } 319 }
320 if (err) 320 if (err)
321 goto out; 321 goto out;
322 err = register_netdev(dev);
323 if (err)
324 goto out1;
325 return dev; 322 return dev;
326out1:
327 outw(PP_ChipID, dev->base_addr + ADD_PORT);
328 release_region(dev->base_addr, NETCARD_IO_EXTENT);
329out: 323out:
330 free_netdev(dev); 324 free_netdev(dev);
331 printk(KERN_WARNING "cs89x0: no cs8900 or cs8920 detected. Be sure to disable PnP with SETUP\n"); 325 printk(KERN_WARNING "cs89x0: no cs8900 or cs8920 detected. Be sure to disable PnP with SETUP\n");
@@ -735,7 +729,13 @@ printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
735 printk("\n"); 729 printk("\n");
736 if (net_debug) 730 if (net_debug)
737 printk("cs89x0_probe1() successful\n"); 731 printk("cs89x0_probe1() successful\n");
732
733 retval = register_netdev(dev);
734 if (retval)
735 goto out3;
738 return 0; 736 return 0;
737out3:
738 outw(PP_ChipID, dev->base_addr + ADD_PORT);
739out2: 739out2:
740 release_region(ioaddr & ~3, NETCARD_IO_EXTENT); 740 release_region(ioaddr & ~3, NETCARD_IO_EXTENT);
741out1: 741out1:
@@ -1831,13 +1831,6 @@ init_module(void)
1831 if (ret) 1831 if (ret)
1832 goto out; 1832 goto out;
1833 1833
1834 if (register_netdev(dev) != 0) {
1835 printk(KERN_ERR "cs89x0.c: No card found at 0x%x\n", io);
1836 ret = -ENXIO;
1837 outw(PP_ChipID, dev->base_addr + ADD_PORT);
1838 release_region(dev->base_addr, NETCARD_IO_EXTENT);
1839 goto out;
1840 }
1841 dev_cs89x0 = dev; 1834 dev_cs89x0 = dev;
1842 return 0; 1835 return 0;
1843out: 1836out:
diff --git a/drivers/net/e2100.c b/drivers/net/e2100.c
index 51c9fa260830..f5a4dd7d8564 100644
--- a/drivers/net/e2100.c
+++ b/drivers/net/e2100.c
@@ -162,12 +162,7 @@ struct net_device * __init e2100_probe(int unit)
162 err = do_e2100_probe(dev); 162 err = do_e2100_probe(dev);
163 if (err) 163 if (err)
164 goto out; 164 goto out;
165 err = register_netdev(dev);
166 if (err)
167 goto out1;
168 return dev; 165 return dev;
169out1:
170 cleanup_card(dev);
171out: 166out:
172 free_netdev(dev); 167 free_netdev(dev);
173 return ERR_PTR(err); 168 return ERR_PTR(err);
@@ -286,6 +281,9 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
286#endif 281#endif
287 NS8390_init(dev, 0); 282 NS8390_init(dev, 0);
288 283
284 retval = register_netdev(dev);
285 if (retval)
286 goto out;
289 return 0; 287 return 0;
290out: 288out:
291 release_region(ioaddr, E21_IO_EXTENT); 289 release_region(ioaddr, E21_IO_EXTENT);
@@ -453,11 +451,8 @@ init_module(void)
453 dev->mem_start = mem[this_dev]; 451 dev->mem_start = mem[this_dev];
454 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */ 452 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
455 if (do_e2100_probe(dev) == 0) { 453 if (do_e2100_probe(dev) == 0) {
456 if (register_netdev(dev) == 0) { 454 dev_e21[found++] = dev;
457 dev_e21[found++] = dev; 455 continue;
458 continue;
459 }
460 cleanup_card(dev);
461 } 456 }
462 free_netdev(dev); 457 free_netdev(dev);
463 printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]); 458 printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index cd2475683027..dcb3028bb60f 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -600,12 +600,7 @@ struct net_device * __init eepro_probe(int unit)
600 err = do_eepro_probe(dev); 600 err = do_eepro_probe(dev);
601 if (err) 601 if (err)
602 goto out; 602 goto out;
603 err = register_netdev(dev);
604 if (err)
605 goto out1;
606 return dev; 603 return dev;
607out1:
608 release_region(dev->base_addr, EEPRO_IO_EXTENT);
609out: 604out:
610 free_netdev(dev); 605 free_netdev(dev);
611 return ERR_PTR(err); 606 return ERR_PTR(err);
@@ -758,6 +753,7 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
758 int i; 753 int i;
759 struct eepro_local *lp; 754 struct eepro_local *lp;
760 int ioaddr = dev->base_addr; 755 int ioaddr = dev->base_addr;
756 int err;
761 757
762 /* Grab the region so we can find another board if autoIRQ fails. */ 758 /* Grab the region so we can find another board if autoIRQ fails. */
763 if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) { 759 if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) {
@@ -873,10 +869,16 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
873 869
874 /* reset 82595 */ 870 /* reset 82595 */
875 eepro_reset(ioaddr); 871 eepro_reset(ioaddr);
872
873 err = register_netdev(dev);
874 if (err)
875 goto err;
876 return 0; 876 return 0;
877exit: 877exit:
878 err = -ENODEV;
879err:
878 release_region(dev->base_addr, EEPRO_IO_EXTENT); 880 release_region(dev->base_addr, EEPRO_IO_EXTENT);
879 return -ENODEV; 881 return err;
880} 882}
881 883
882/* Open/initialize the board. This is called (in the current kernel) 884/* Open/initialize the board. This is called (in the current kernel)
@@ -1834,11 +1836,8 @@ init_module(void)
1834 dev->irq = irq[i]; 1836 dev->irq = irq[i];
1835 1837
1836 if (do_eepro_probe(dev) == 0) { 1838 if (do_eepro_probe(dev) == 0) {
1837 if (register_netdev(dev) == 0) { 1839 dev_eepro[n_eepro++] = dev;
1838 dev_eepro[n_eepro++] = dev; 1840 continue;
1839 continue;
1840 }
1841 release_region(dev->base_addr, EEPRO_IO_EXTENT);
1842 } 1841 }
1843 free_netdev(dev); 1842 free_netdev(dev);
1844 break; 1843 break;
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index fc8e7947b334..82bd356e4f3a 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -436,11 +436,8 @@ struct net_device * __init express_probe(int unit)
436 netdev_boot_setup_check(dev); 436 netdev_boot_setup_check(dev);
437 437
438 err = do_express_probe(dev); 438 err = do_express_probe(dev);
439 if (!err) { 439 if (!err)
440 err = register_netdev(dev); 440 return dev;
441 if (!err)
442 return dev;
443 }
444 free_netdev(dev); 441 free_netdev(dev);
445 return ERR_PTR(err); 442 return ERR_PTR(err);
446} 443}
@@ -1205,7 +1202,8 @@ static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
1205 dev->set_multicast_list = &eexp_set_multicast; 1202 dev->set_multicast_list = &eexp_set_multicast;
1206 dev->tx_timeout = eexp_timeout; 1203 dev->tx_timeout = eexp_timeout;
1207 dev->watchdog_timeo = 2*HZ; 1204 dev->watchdog_timeo = 2*HZ;
1208 return 0; 1205
1206 return register_netdev(dev);
1209} 1207}
1210 1208
1211/* 1209/*
@@ -1716,7 +1714,7 @@ int init_module(void)
1716 break; 1714 break;
1717 printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n"); 1715 printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n");
1718 } 1716 }
1719 if (do_express_probe(dev) == 0 && register_netdev(dev) == 0) { 1717 if (do_express_probe(dev) == 0) {
1720 dev_eexp[this_dev] = dev; 1718 dev_eexp[this_dev] = dev;
1721 found++; 1719 found++;
1722 continue; 1720 continue;
diff --git a/drivers/net/es3210.c b/drivers/net/es3210.c
index f1e8150ed2a0..50f8e23bb9e5 100644
--- a/drivers/net/es3210.c
+++ b/drivers/net/es3210.c
@@ -177,12 +177,7 @@ struct net_device * __init es_probe(int unit)
177 err = do_es_probe(dev); 177 err = do_es_probe(dev);
178 if (err) 178 if (err)
179 goto out; 179 goto out;
180 err = register_netdev(dev);
181 if (err)
182 goto out1;
183 return dev; 180 return dev;
184out1:
185 cleanup_card(dev);
186out: 181out:
187 free_netdev(dev); 182 free_netdev(dev);
188 return ERR_PTR(err); 183 return ERR_PTR(err);
@@ -310,6 +305,10 @@ static int __init es_probe1(struct net_device *dev, int ioaddr)
310 dev->poll_controller = ei_poll; 305 dev->poll_controller = ei_poll;
311#endif 306#endif
312 NS8390_init(dev, 0); 307 NS8390_init(dev, 0);
308
309 retval = register_netdev(dev);
310 if (retval)
311 goto out1;
313 return 0; 312 return 0;
314out1: 313out1:
315 free_irq(dev->irq, dev); 314 free_irq(dev->irq, dev);
@@ -445,11 +444,8 @@ init_module(void)
445 dev->base_addr = io[this_dev]; 444 dev->base_addr = io[this_dev];
446 dev->mem_start = mem[this_dev]; 445 dev->mem_start = mem[this_dev];
447 if (do_es_probe(dev) == 0) { 446 if (do_es_probe(dev) == 0) {
448 if (register_netdev(dev) == 0) { 447 dev_es3210[found++] = dev;
449 dev_es3210[found++] = dev; 448 continue;
450 continue;
451 }
452 cleanup_card(dev);
453 } 449 }
454 free_netdev(dev); 450 free_netdev(dev);
455 printk(KERN_WARNING "es3210.c: No es3210 card found (i/o = 0x%x).\n", io[this_dev]); 451 printk(KERN_WARNING "es3210.c: No es3210 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index ccae6ba5f7c5..f32a6b3acb2a 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -473,13 +473,7 @@ struct net_device * __init eth16i_probe(int unit)
473 err = do_eth16i_probe(dev); 473 err = do_eth16i_probe(dev);
474 if (err) 474 if (err)
475 goto out; 475 goto out;
476 err = register_netdev(dev);
477 if (err)
478 goto out1;
479 return dev; 476 return dev;
480out1:
481 free_irq(dev->irq, dev);
482 release_region(dev->base_addr, ETH16I_IO_EXTENT);
483out: 477out:
484 free_netdev(dev); 478 free_netdev(dev);
485 return ERR_PTR(err); 479 return ERR_PTR(err);
@@ -569,7 +563,13 @@ static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
569 dev->tx_timeout = eth16i_timeout; 563 dev->tx_timeout = eth16i_timeout;
570 dev->watchdog_timeo = TX_TIMEOUT; 564 dev->watchdog_timeo = TX_TIMEOUT;
571 spin_lock_init(&lp->lock); 565 spin_lock_init(&lp->lock);
566
567 retval = register_netdev(dev);
568 if (retval)
569 goto out1;
572 return 0; 570 return 0;
571out1:
572 free_irq(dev->irq, dev);
573out: 573out:
574 release_region(ioaddr, ETH16I_IO_EXTENT); 574 release_region(ioaddr, ETH16I_IO_EXTENT);
575 return retval; 575 return retval;
@@ -1462,12 +1462,8 @@ int init_module(void)
1462 } 1462 }
1463 1463
1464 if (do_eth16i_probe(dev) == 0) { 1464 if (do_eth16i_probe(dev) == 0) {
1465 if (register_netdev(dev) == 0) { 1465 dev_eth16i[found++] = dev;
1466 dev_eth16i[found++] = dev; 1466 continue;
1467 continue;
1468 }
1469 free_irq(dev->irq, dev);
1470 release_region(dev->base_addr, ETH16I_IO_EXTENT);
1471 } 1467 }
1472 printk(KERN_WARNING "eth16i.c No Eth16i card found (i/o = 0x%x).\n", 1468 printk(KERN_WARNING "eth16i.c No Eth16i card found (i/o = 0x%x).\n",
1473 io[this_dev]); 1469 io[this_dev]);
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index 4834314b676d..0abf5dd08b4c 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -159,12 +159,7 @@ struct net_device * __init hp_plus_probe(int unit)
159 err = do_hpp_probe(dev); 159 err = do_hpp_probe(dev);
160 if (err) 160 if (err)
161 goto out; 161 goto out;
162 err = register_netdev(dev);
163 if (err)
164 goto out1;
165 return dev; 162 return dev;
166out1:
167 cleanup_card(dev);
168out: 163out:
169 free_netdev(dev); 164 free_netdev(dev);
170 return ERR_PTR(err); 165 return ERR_PTR(err);
@@ -271,6 +266,9 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr)
271 /* Leave the 8390 and HP chip reset. */ 266 /* Leave the 8390 and HP chip reset. */
272 outw(inw(ioaddr + HPP_OPTION) & ~EnableIRQ, ioaddr + HPP_OPTION); 267 outw(inw(ioaddr + HPP_OPTION) & ~EnableIRQ, ioaddr + HPP_OPTION);
273 268
269 retval = register_netdev(dev);
270 if (retval)
271 goto out;
274 return 0; 272 return 0;
275out: 273out:
276 release_region(ioaddr, HP_IO_EXTENT); 274 release_region(ioaddr, HP_IO_EXTENT);
@@ -463,11 +461,8 @@ init_module(void)
463 dev->irq = irq[this_dev]; 461 dev->irq = irq[this_dev];
464 dev->base_addr = io[this_dev]; 462 dev->base_addr = io[this_dev];
465 if (do_hpp_probe(dev) == 0) { 463 if (do_hpp_probe(dev) == 0) {
466 if (register_netdev(dev) == 0) { 464 dev_hpp[found++] = dev;
467 dev_hpp[found++] = dev; 465 continue;
468 continue;
469 }
470 cleanup_card(dev);
471 } 466 }
472 free_netdev(dev); 467 free_netdev(dev);
473 printk(KERN_WARNING "hp-plus.c: No HP-Plus card found (i/o = 0x%x).\n", io[this_dev]); 468 printk(KERN_WARNING "hp-plus.c: No HP-Plus card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/hp.c b/drivers/net/hp.c
index 026888611d6f..59cf841b14ab 100644
--- a/drivers/net/hp.c
+++ b/drivers/net/hp.c
@@ -123,12 +123,7 @@ struct net_device * __init hp_probe(int unit)
123 err = do_hp_probe(dev); 123 err = do_hp_probe(dev);
124 if (err) 124 if (err)
125 goto out; 125 goto out;
126 err = register_netdev(dev);
127 if (err)
128 goto out1;
129 return dev; 126 return dev;
130out1:
131 cleanup_card(dev);
132out: 127out:
133 free_netdev(dev); 128 free_netdev(dev);
134 return ERR_PTR(err); 129 return ERR_PTR(err);
@@ -227,7 +222,12 @@ static int __init hp_probe1(struct net_device *dev, int ioaddr)
227 ei_status.block_output = &hp_block_output; 222 ei_status.block_output = &hp_block_output;
228 hp_init_card(dev); 223 hp_init_card(dev);
229 224
225 retval = register_netdev(dev);
226 if (retval)
227 goto out1;
230 return 0; 228 return 0;
229out1:
230 free_irq(dev->irq, dev);
231out: 231out:
232 release_region(ioaddr, HP_IO_EXTENT); 232 release_region(ioaddr, HP_IO_EXTENT);
233 return retval; 233 return retval;
@@ -432,11 +432,8 @@ init_module(void)
432 dev->irq = irq[this_dev]; 432 dev->irq = irq[this_dev];
433 dev->base_addr = io[this_dev]; 433 dev->base_addr = io[this_dev];
434 if (do_hp_probe(dev) == 0) { 434 if (do_hp_probe(dev) == 0) {
435 if (register_netdev(dev) == 0) { 435 dev_hp[found++] = dev;
436 dev_hp[found++] = dev; 436 continue;
437 continue;
438 }
439 cleanup_card(dev);
440 } 437 }
441 free_netdev(dev); 438 free_netdev(dev);
442 printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]); 439 printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index b3a898c5a585..c9d1a86d9594 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -417,12 +417,7 @@ struct net_device * __init hp100_probe(int unit)
417 if (err) 417 if (err)
418 goto out; 418 goto out;
419 419
420 err = register_netdev(dev);
421 if (err)
422 goto out1;
423 return dev; 420 return dev;
424 out1:
425 release_region(dev->base_addr, HP100_REGION_SIZE);
426 out: 421 out:
427 free_netdev(dev); 422 free_netdev(dev);
428 return ERR_PTR(err); 423 return ERR_PTR(err);
@@ -776,11 +771,22 @@ static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
776 printk("Warning! Link down.\n"); 771 printk("Warning! Link down.\n");
777 } 772 }
778 773
774 err = register_netdev(dev);
775 if (err)
776 goto out3;
777
779 return 0; 778 return 0;
779out3:
780 if (local_mode == 1)
781 pci_free_consistent(lp->pci_dev, MAX_RINGSIZE + 0x0f,
782 lp->page_vaddr_algn,
783 virt_to_whatever(dev, lp->page_vaddr_algn));
784 if (mem_ptr_virt)
785 iounmap(mem_ptr_virt);
780out2: 786out2:
781 release_region(ioaddr, HP100_REGION_SIZE); 787 release_region(ioaddr, HP100_REGION_SIZE);
782out1: 788out1:
783 return -ENODEV; 789 return err;
784} 790}
785 791
786/* This procedure puts the card into a stable init state */ 792/* This procedure puts the card into a stable init state */
@@ -2875,18 +2881,12 @@ static int __init hp100_eisa_probe (struct device *gendev)
2875 if (err) 2881 if (err)
2876 goto out1; 2882 goto out1;
2877 2883
2878 err = register_netdev(dev);
2879 if (err)
2880 goto out2;
2881
2882#ifdef HP100_DEBUG 2884#ifdef HP100_DEBUG
2883 printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name, 2885 printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name,
2884 dev->base_addr); 2886 dev->base_addr);
2885#endif 2887#endif
2886 gendev->driver_data = dev; 2888 gendev->driver_data = dev;
2887 return 0; 2889 return 0;
2888 out2:
2889 release_region(dev->base_addr, HP100_REGION_SIZE);
2890 out1: 2890 out1:
2891 free_netdev(dev); 2891 free_netdev(dev);
2892 return err; 2892 return err;
@@ -2951,17 +2951,12 @@ static int __devinit hp100_pci_probe (struct pci_dev *pdev,
2951 err = hp100_probe1(dev, ioaddr, HP100_BUS_PCI, pdev); 2951 err = hp100_probe1(dev, ioaddr, HP100_BUS_PCI, pdev);
2952 if (err) 2952 if (err)
2953 goto out1; 2953 goto out1;
2954 err = register_netdev(dev);
2955 if (err)
2956 goto out2;
2957 2954
2958#ifdef HP100_DEBUG 2955#ifdef HP100_DEBUG
2959 printk("hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr); 2956 printk("hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr);
2960#endif 2957#endif
2961 pci_set_drvdata(pdev, dev); 2958 pci_set_drvdata(pdev, dev);
2962 return 0; 2959 return 0;
2963 out2:
2964 release_region(dev->base_addr, HP100_REGION_SIZE);
2965 out1: 2960 out1:
2966 free_netdev(dev); 2961 free_netdev(dev);
2967 out0: 2962 out0:
@@ -3032,15 +3027,9 @@ static int __init hp100_isa_init(void)
3032 SET_MODULE_OWNER(dev); 3027 SET_MODULE_OWNER(dev);
3033 3028
3034 err = hp100_isa_probe(dev, hp100_port[i]); 3029 err = hp100_isa_probe(dev, hp100_port[i]);
3035 if (!err) { 3030 if (!err)
3036 err = register_netdev(dev); 3031 hp100_devlist[cards++] = dev;
3037 if (!err) 3032 else
3038 hp100_devlist[cards++] = dev;
3039 else
3040 release_region(dev->base_addr, HP100_REGION_SIZE);
3041 }
3042
3043 if (err)
3044 free_netdev(dev); 3033 free_netdev(dev);
3045 } 3034 }
3046 3035
diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c
index 50bebb55e9ee..88ae8a04fabc 100644
--- a/drivers/net/isa-skeleton.c
+++ b/drivers/net/isa-skeleton.c
@@ -176,12 +176,7 @@ struct net_device * __init netcard_probe(int unit)
176 err = do_netcard_probe(dev); 176 err = do_netcard_probe(dev);
177 if (err) 177 if (err)
178 goto out; 178 goto out;
179 err = register_netdev(dev);
180 if (err)
181 goto out1;
182 return dev; 179 return dev;
183out1:
184 cleanup_card(dev);
185out: 180out:
186 free_netdev(dev); 181 free_netdev(dev);
187 return ERR_PTR(err); 182 return ERR_PTR(err);
@@ -316,7 +311,15 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr)
316 311
317 dev->tx_timeout = &net_tx_timeout; 312 dev->tx_timeout = &net_tx_timeout;
318 dev->watchdog_timeo = MY_TX_TIMEOUT; 313 dev->watchdog_timeo = MY_TX_TIMEOUT;
314
315 err = register_netdev(dev);
316 if (err)
317 goto out2;
319 return 0; 318 return 0;
319out2:
320#ifdef jumpered_dma
321 free_dma(dev->dma);
322#endif
320out1: 323out1:
321#ifdef jumpered_interrupts 324#ifdef jumpered_interrupts
322 free_irq(dev->irq, dev); 325 free_irq(dev->irq, dev);
@@ -691,11 +694,8 @@ int init_module(void)
691 dev->dma = dma; 694 dev->dma = dma;
692 dev->mem_start = mem; 695 dev->mem_start = mem;
693 if (do_netcard_probe(dev) == 0) { 696 if (do_netcard_probe(dev) == 0) {
694 if (register_netdev(dev) == 0) 697 this_device = dev;
695 this_device = dev; 698 return 0;
696 return 0;
697 }
698 cleanup_card(dev);
699 } 699 }
700 free_netdev(dev); 700 free_netdev(dev);
701 return -ENXIO; 701 return -ENXIO;
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index dec557fb6a99..ca90f0d1e4b0 100644
--- a/drivers/net/lance.c
+++ b/drivers/net/lance.c
@@ -356,11 +356,8 @@ int init_module(void)
356 dev->base_addr = io[this_dev]; 356 dev->base_addr = io[this_dev];
357 dev->dma = dma[this_dev]; 357 dev->dma = dma[this_dev];
358 if (do_lance_probe(dev) == 0) { 358 if (do_lance_probe(dev) == 0) {
359 if (register_netdev(dev) == 0) { 359 dev_lance[found++] = dev;
360 dev_lance[found++] = dev; 360 continue;
361 continue;
362 }
363 cleanup_card(dev);
364 } 361 }
365 free_netdev(dev); 362 free_netdev(dev);
366 break; 363 break;
@@ -448,12 +445,7 @@ struct net_device * __init lance_probe(int unit)
448 err = do_lance_probe(dev); 445 err = do_lance_probe(dev);
449 if (err) 446 if (err)
450 goto out; 447 goto out;
451 err = register_netdev(dev);
452 if (err)
453 goto out1;
454 return dev; 448 return dev;
455out1:
456 cleanup_card(dev);
457out: 449out:
458 free_netdev(dev); 450 free_netdev(dev);
459 return ERR_PTR(err); 451 return ERR_PTR(err);
@@ -724,6 +716,9 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
724 dev->tx_timeout = lance_tx_timeout; 716 dev->tx_timeout = lance_tx_timeout;
725 dev->watchdog_timeo = TX_TIMEOUT; 717 dev->watchdog_timeo = TX_TIMEOUT;
726 718
719 err = register_netdev(dev);
720 if (err)
721 goto out_dma;
727 return 0; 722 return 0;
728out_dma: 723out_dma:
729 if (dev->dma != 4) 724 if (dev->dma != 4)
diff --git a/drivers/net/lne390.c b/drivers/net/lne390.c
index 179a97c0af69..27f0d8ac4c40 100644
--- a/drivers/net/lne390.c
+++ b/drivers/net/lne390.c
@@ -167,12 +167,7 @@ struct net_device * __init lne390_probe(int unit)
167 err = do_lne390_probe(dev); 167 err = do_lne390_probe(dev);
168 if (err) 168 if (err)
169 goto out; 169 goto out;
170 err = register_netdev(dev);
171 if (err)
172 goto out1;
173 return dev; 170 return dev;
174out1:
175 cleanup_card(dev);
176out: 171out:
177 free_netdev(dev); 172 free_netdev(dev);
178 return ERR_PTR(err); 173 return ERR_PTR(err);
@@ -296,7 +291,14 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr)
296 dev->poll_controller = ei_poll; 291 dev->poll_controller = ei_poll;
297#endif 292#endif
298 NS8390_init(dev, 0); 293 NS8390_init(dev, 0);
294
295 ret = register_netdev(dev);
296 if (ret)
297 goto unmap;
299 return 0; 298 return 0;
299unmap:
300 if (ei_status.reg0)
301 iounmap((void *)dev->mem_start);
300cleanup: 302cleanup:
301 free_irq(dev->irq, dev); 303 free_irq(dev->irq, dev);
302 return ret; 304 return ret;
@@ -426,11 +428,8 @@ int init_module(void)
426 dev->base_addr = io[this_dev]; 428 dev->base_addr = io[this_dev];
427 dev->mem_start = mem[this_dev]; 429 dev->mem_start = mem[this_dev];
428 if (do_lne390_probe(dev) == 0) { 430 if (do_lne390_probe(dev) == 0) {
429 if (register_netdev(dev) == 0) { 431 dev_lne[found++] = dev;
430 dev_lne[found++] = dev; 432 continue;
431 continue;
432 }
433 cleanup_card(dev);
434 } 433 }
435 free_netdev(dev); 434 free_netdev(dev);
436 printk(KERN_WARNING "lne390.c: No LNE390 card found (i/o = 0x%x).\n", io[this_dev]); 435 printk(KERN_WARNING "lne390.c: No LNE390 card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index 84e291e24935..8f40368cf2e9 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -180,12 +180,7 @@ struct net_device * __init ne_probe(int unit)
180 err = do_ne_probe(dev); 180 err = do_ne_probe(dev);
181 if (err) 181 if (err)
182 goto out; 182 goto out;
183 err = register_netdev(dev);
184 if (err)
185 goto out1;
186 return dev; 183 return dev;
187out1:
188 cleanup_card(dev);
189out: 184out:
190 free_netdev(dev); 185 free_netdev(dev);
191 return ERR_PTR(err); 186 return ERR_PTR(err);
@@ -325,8 +320,13 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
325 dev->poll_controller = ei_poll; 320 dev->poll_controller = ei_poll;
326#endif 321#endif
327 NS8390_init(dev, 0); 322 NS8390_init(dev, 0);
328 return 0;
329 323
324 ret = register_netdev(dev);
325 if (ret)
326 goto out_irq;
327 return 0;
328out_irq:
329 free_irq(dev->irq, dev);
330err_out: 330err_out:
331 release_region(ioaddr, NE_IO_EXTENT); 331 release_region(ioaddr, NE_IO_EXTENT);
332 return ret; 332 return ret;
@@ -633,11 +633,8 @@ int init_module(void)
633 err = init_reg_offset(dev, dev->base_addr); 633 err = init_reg_offset(dev, dev->base_addr);
634 if (!err) { 634 if (!err) {
635 if (do_ne_probe(dev) == 0) { 635 if (do_ne_probe(dev) == 0) {
636 if (register_netdev(dev) == 0) { 636 dev_ne[found++] = dev;
637 dev_ne[found++] = dev; 637 continue;
638 continue;
639 }
640 cleanup_card(dev);
641 } 638 }
642 } 639 }
643 free_netdev(dev); 640 free_netdev(dev);
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index 496433902ade..6c57096aa2e1 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -229,12 +229,7 @@ struct net_device * __init ne_probe(int unit)
229 err = do_ne_probe(dev); 229 err = do_ne_probe(dev);
230 if (err) 230 if (err)
231 goto out; 231 goto out;
232 err = register_netdev(dev);
233 if (err)
234 goto out1;
235 return dev; 232 return dev;
236out1:
237 cleanup_card(dev);
238out: 233out:
239 free_netdev(dev); 234 free_netdev(dev);
240 return ERR_PTR(err); 235 return ERR_PTR(err);
@@ -534,8 +529,14 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
534 dev->poll_controller = ei_poll; 529 dev->poll_controller = ei_poll;
535#endif 530#endif
536 NS8390_init(dev, 0); 531 NS8390_init(dev, 0);
532
533 ret = register_netdev(dev);
534 if (ret)
535 goto out_irq;
537 return 0; 536 return 0;
538 537
538out_irq:
539 free_irq(dev->irq, dev);
539err_out: 540err_out:
540 release_region(ioaddr, NE_IO_EXTENT); 541 release_region(ioaddr, NE_IO_EXTENT);
541 return ret; 542 return ret;
@@ -826,11 +827,8 @@ int init_module(void)
826 dev->mem_end = bad[this_dev]; 827 dev->mem_end = bad[this_dev];
827 dev->base_addr = io[this_dev]; 828 dev->base_addr = io[this_dev];
828 if (do_ne_probe(dev) == 0) { 829 if (do_ne_probe(dev) == 0) {
829 if (register_netdev(dev) == 0) { 830 dev_ne[found++] = dev;
830 dev_ne[found++] = dev; 831 continue;
831 continue;
832 }
833 cleanup_card(dev);
834 } 832 }
835 free_netdev(dev); 833 free_netdev(dev);
836 if (found) 834 if (found)
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c
index 6ebef27dbfae..6d62ada85de6 100644
--- a/drivers/net/ne2.c
+++ b/drivers/net/ne2.c
@@ -301,12 +301,7 @@ struct net_device * __init ne2_probe(int unit)
301 err = do_ne2_probe(dev); 301 err = do_ne2_probe(dev);
302 if (err) 302 if (err)
303 goto out; 303 goto out;
304 err = register_netdev(dev);
305 if (err)
306 goto out1;
307 return dev; 304 return dev;
308out1:
309 cleanup_card(dev);
310out: 305out:
311 free_netdev(dev); 306 free_netdev(dev);
312 return ERR_PTR(err); 307 return ERR_PTR(err);
@@ -517,7 +512,14 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
517 dev->poll_controller = ei_poll; 512 dev->poll_controller = ei_poll;
518#endif 513#endif
519 NS8390_init(dev, 0); 514 NS8390_init(dev, 0);
515
516 retval = register_netdev(dev);
517 if (retval)
518 goto out1;
520 return 0; 519 return 0;
520out1:
521 mca_set_adapter_procfn( ei_status.priv, NULL, NULL);
522 free_irq(dev->irq, dev);
521out: 523out:
522 release_region(base_addr, NE_IO_EXTENT); 524 release_region(base_addr, NE_IO_EXTENT);
523 return retval; 525 return retval;
@@ -798,11 +800,8 @@ int init_module(void)
798 dev->mem_end = bad[this_dev]; 800 dev->mem_end = bad[this_dev];
799 dev->base_addr = io[this_dev]; 801 dev->base_addr = io[this_dev];
800 if (do_ne2_probe(dev) == 0) { 802 if (do_ne2_probe(dev) == 0) {
801 if (register_netdev(dev) == 0) { 803 dev_ne[found++] = dev;
802 dev_ne[found++] = dev; 804 continue;
803 continue;
804 }
805 cleanup_card(dev);
806 } 805 }
807 free_netdev(dev); 806 free_netdev(dev);
808 break; 807 break;
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index b564c677c6d2..6d9dae60a697 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -194,12 +194,7 @@ struct net_device * __init ultra_probe(int unit)
194 err = do_ultra_probe(dev); 194 err = do_ultra_probe(dev);
195 if (err) 195 if (err)
196 goto out; 196 goto out;
197 err = register_netdev(dev);
198 if (err)
199 goto out1;
200 return dev; 197 return dev;
201out1:
202 cleanup_card(dev);
203out: 198out:
204 free_netdev(dev); 199 free_netdev(dev);
205 return ERR_PTR(err); 200 return ERR_PTR(err);
@@ -325,6 +320,9 @@ static int __init ultra_probe1(struct net_device *dev, int ioaddr)
325#endif 320#endif
326 NS8390_init(dev, 0); 321 NS8390_init(dev, 0);
327 322
323 retval = register_netdev(dev);
324 if (retval)
325 goto out;
328 return 0; 326 return 0;
329out: 327out:
330 release_region(ioaddr, ULTRA_IO_EXTENT); 328 release_region(ioaddr, ULTRA_IO_EXTENT);
@@ -583,11 +581,8 @@ init_module(void)
583 dev->irq = irq[this_dev]; 581 dev->irq = irq[this_dev];
584 dev->base_addr = io[this_dev]; 582 dev->base_addr = io[this_dev];
585 if (do_ultra_probe(dev) == 0) { 583 if (do_ultra_probe(dev) == 0) {
586 if (register_netdev(dev) == 0) { 584 dev_ultra[found++] = dev;
587 dev_ultra[found++] = dev; 585 continue;
588 continue;
589 }
590 cleanup_card(dev);
591 } 586 }
592 free_netdev(dev); 587 free_netdev(dev);
593 printk(KERN_WARNING "smc-ultra.c: No SMC Ultra card found (i/o = 0x%x).\n", io[this_dev]); 588 printk(KERN_WARNING "smc-ultra.c: No SMC Ultra card found (i/o = 0x%x).\n", io[this_dev]);
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index 1f05d9bd05e4..b03feae459fc 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -149,12 +149,7 @@ struct net_device * __init wd_probe(int unit)
149 err = do_wd_probe(dev); 149 err = do_wd_probe(dev);
150 if (err) 150 if (err)
151 goto out; 151 goto out;
152 err = register_netdev(dev);
153 if (err)
154 goto out1;
155 return dev; 152 return dev;
156out1:
157 cleanup_card(dev);
158out: 153out:
159 free_netdev(dev); 154 free_netdev(dev);
160 return ERR_PTR(err); 155 return ERR_PTR(err);
@@ -164,6 +159,7 @@ out:
164static int __init wd_probe1(struct net_device *dev, int ioaddr) 159static int __init wd_probe1(struct net_device *dev, int ioaddr)
165{ 160{
166 int i; 161 int i;
162 int err;
167 int checksum = 0; 163 int checksum = 0;
168 int ancient = 0; /* An old card without config registers. */ 164 int ancient = 0; /* An old card without config registers. */
169 int word16 = 0; /* 0 = 8 bit, 1 = 16 bit */ 165 int word16 = 0; /* 0 = 8 bit, 1 = 16 bit */
@@ -356,7 +352,10 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr)
356 outb(inb(ioaddr+4)|0x80, ioaddr+4); 352 outb(inb(ioaddr+4)|0x80, ioaddr+4);
357#endif 353#endif
358 354
359 return 0; 355 err = register_netdev(dev);
356 if (err)
357 free_irq(dev->irq, dev);
358 return err;
360} 359}
361 360
362static int 361static int
@@ -527,11 +526,8 @@ init_module(void)
527 dev->mem_start = mem[this_dev]; 526 dev->mem_start = mem[this_dev];
528 dev->mem_end = mem_end[this_dev]; 527 dev->mem_end = mem_end[this_dev];
529 if (do_wd_probe(dev) == 0) { 528 if (do_wd_probe(dev) == 0) {
530 if (register_netdev(dev) == 0) { 529 dev_wd[found++] = dev;
531 dev_wd[found++] = dev; 530 continue;
532 continue;
533 }
534 cleanup_card(dev);
535 } 531 }
536 free_netdev(dev); 532 free_netdev(dev);
537 printk(KERN_WARNING "wd.c: No wd80x3 card found (i/o = 0x%x).\n", io[this_dev]); 533 printk(KERN_WARNING "wd.c: No wd80x3 card found (i/o = 0x%x).\n", io[this_dev]);