aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ni52.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ni52.c')
-rw-r--r--drivers/net/ni52.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index fa611f6a8563..e0d1947c997a 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -320,7 +320,10 @@ static int check586(struct net_device *dev, unsigned size)
320 struct priv *p = dev->priv; 320 struct priv *p = dev->priv;
321 int i; 321 int i;
322 322
323 p->mapped = (char __iomem *)isa_bus_to_virt(dev->mem_start); 323 p->mapped = ioremap(dev->mem_start, size);
324 if (!p->mapped)
325 return 0;
326
324 p->base = p->mapped + size - 0x01000000; 327 p->base = p->mapped + size - 0x01000000;
325 p->memtop = p->mapped + size; 328 p->memtop = p->mapped + size;
326 p->scp = (struct scp_struct __iomem *)(p->base + SCP_DEFAULT_ADDRESS); 329 p->scp = (struct scp_struct __iomem *)(p->base + SCP_DEFAULT_ADDRESS);
@@ -330,16 +333,19 @@ static int check586(struct net_device *dev, unsigned size)
330 for (i = 0; i < sizeof(struct scp_struct); i++) 333 for (i = 0; i < sizeof(struct scp_struct); i++)
331 /* memory was writeable? */ 334 /* memory was writeable? */
332 if (readb((char __iomem *)p->scp + i)) 335 if (readb((char __iomem *)p->scp + i))
333 return 0; 336 goto Enodev;
334 writeb(SYSBUSVAL, &p->scp->sysbus); /* 1 = 8Bit-Bus, 0 = 16 Bit */ 337 writeb(SYSBUSVAL, &p->scp->sysbus); /* 1 = 8Bit-Bus, 0 = 16 Bit */
335 if (readb(&p->scp->sysbus) != SYSBUSVAL) 338 if (readb(&p->scp->sysbus) != SYSBUSVAL)
336 return 0; 339 goto Enodev;
337 340
338 if (!check_iscp(dev, p->mapped)) 341 if (!check_iscp(dev, p->mapped))
339 return 0; 342 goto Enodev;
340 if (!check_iscp(dev, p->iscp)) 343 if (!check_iscp(dev, p->iscp))
341 return 0; 344 goto Enodev;
342 return 1; 345 return 1;
346Enodev:
347 iounmap(p->mapped);
348 return 0;
343} 349}
344 350
345/****************************************************************** 351/******************************************************************
@@ -386,12 +392,15 @@ struct net_device * __init ni52_probe(int unit)
386{ 392{
387 struct net_device *dev = alloc_etherdev(sizeof(struct priv)); 393 struct net_device *dev = alloc_etherdev(sizeof(struct priv));
388 static int ports[] = {0x300, 0x280, 0x360 , 0x320 , 0x340, 0}; 394 static int ports[] = {0x300, 0x280, 0x360 , 0x320 , 0x340, 0};
395 struct priv *p;
389 int *port; 396 int *port;
390 int err = 0; 397 int err = 0;
391 398
392 if (!dev) 399 if (!dev)
393 return ERR_PTR(-ENOMEM); 400 return ERR_PTR(-ENOMEM);
394 401
402 p = dev->priv;
403
395 if (unit >= 0) { 404 if (unit >= 0) {
396 sprintf(dev->name, "eth%d", unit); 405 sprintf(dev->name, "eth%d", unit);
397 netdev_boot_setup_check(dev); 406 netdev_boot_setup_check(dev);
@@ -426,6 +435,7 @@ got_it:
426 goto out1; 435 goto out1;
427 return dev; 436 return dev;
428out1: 437out1:
438 iounmap(p->mapped);
429 release_region(dev->base_addr, NI52_TOTAL_SIZE); 439 release_region(dev->base_addr, NI52_TOTAL_SIZE);
430out: 440out:
431 free_netdev(dev); 441 free_netdev(dev);
@@ -542,6 +552,7 @@ static int __init ni52_probe1(struct net_device *dev, int ioaddr)
542 if (!dev->irq) { 552 if (!dev->irq) {
543 printk("?autoirq, Failed to detect IRQ line!\n"); 553 printk("?autoirq, Failed to detect IRQ line!\n");
544 retval = -EAGAIN; 554 retval = -EAGAIN;
555 iounmap(priv->mapped);
545 goto out; 556 goto out;
546 } 557 }
547 printk("IRQ %d (autodetected).\n", dev->irq); 558 printk("IRQ %d (autodetected).\n", dev->irq);
@@ -1325,7 +1336,9 @@ int __init init_module(void)
1325 1336
1326void __exit cleanup_module(void) 1337void __exit cleanup_module(void)
1327{ 1338{
1339 struct priv *p = dev_ni52->priv;
1328 unregister_netdev(dev_ni52); 1340 unregister_netdev(dev_ni52);
1341 iounmap(p->mapped);
1329 release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE); 1342 release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE);
1330 free_netdev(dev_ni52); 1343 free_netdev(dev_ni52);
1331} 1344}