Commit 0ea9bcb1 authored by Jeff Garzik's avatar Jeff Garzik

[netdrvr tlan] cleanup

* use pci_{request,release}_regions for PCI devices
* use alloc_etherdev (fixes race)
* propagate error returns from pci_xxx function errors
parent fea45e9c
...@@ -424,7 +424,7 @@ static void __devexit tlan_remove_one( struct pci_dev *pdev) ...@@ -424,7 +424,7 @@ static void __devexit tlan_remove_one( struct pci_dev *pdev)
pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage, priv->dmaStorageDMA ); pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage, priv->dmaStorageDMA );
} }
release_region( dev->base_addr, 0x10 ); pci_release_regions(pdev);
kfree( dev ); kfree( dev );
...@@ -510,15 +510,25 @@ static int __devinit TLan_probe1(struct pci_dev *pdev, ...@@ -510,15 +510,25 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
TLanPrivateInfo *priv; TLanPrivateInfo *priv;
u8 pci_rev; u8 pci_rev;
u16 device_id; u16 device_id;
int reg; int reg, rc = -ENODEV;
if (pdev && pci_enable_device(pdev)) if (pdev) {
return -EIO; rc = pci_enable_device(pdev);
if (rc)
return rc;
rc = pci_request_regions(pdev, TLanSignature);
if (rc) {
printk(KERN_ERR "TLAN: Could not reserve IO regions\n");
goto err_out;
}
}
dev = init_etherdev(NULL, sizeof(TLanPrivateInfo)); dev = alloc_etherdev(sizeof(TLanPrivateInfo));
if (dev == NULL) { if (dev == NULL) {
printk(KERN_ERR "TLAN: Could not allocate memory for device.\n"); printk(KERN_ERR "TLAN: Could not allocate memory for device.\n");
return -ENOMEM; rc = -ENOMEM;
goto err_out_regions;
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
...@@ -533,12 +543,10 @@ static int __devinit TLan_probe1(struct pci_dev *pdev, ...@@ -533,12 +543,10 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
priv->adapter = &board_info[ent->driver_data]; priv->adapter = &board_info[ent->driver_data];
if(pci_set_dma_mask(pdev, 0xFFFFFFFF)) rc = pci_set_dma_mask(pdev, 0xFFFFFFFF);
{ if (rc) {
printk(KERN_ERR "TLAN: No suitable PCI mapping available.\n"); printk(KERN_ERR "TLAN: No suitable PCI mapping available.\n");
unregister_netdev(dev); goto err_out_free_dev;
kfree(dev);
return -ENODEV;
} }
pci_read_config_byte ( pdev, PCI_REVISION_ID, &pci_rev); pci_read_config_byte ( pdev, PCI_REVISION_ID, &pci_rev);
...@@ -553,9 +561,8 @@ static int __devinit TLan_probe1(struct pci_dev *pdev, ...@@ -553,9 +561,8 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
} }
if (!pci_io_base) { if (!pci_io_base) {
printk(KERN_ERR "TLAN: No IO mappings available\n"); printk(KERN_ERR "TLAN: No IO mappings available\n");
unregister_netdev(dev); rc = -EIO;
kfree(dev); goto err_out_free_dev;
return -ENODEV;
} }
dev->base_addr = pci_io_base; dev->base_addr = pci_io_base;
...@@ -605,12 +612,18 @@ static int __devinit TLan_probe1(struct pci_dev *pdev, ...@@ -605,12 +612,18 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
if (TLan_Init(dev)) { rc = TLan_Init(dev);
if (rc) {
printk(KERN_ERR "TLAN: Could not set up device.\n");
goto err_out_free_dev;
}
rc = register_netdev(dev);
if (rc) {
printk(KERN_ERR "TLAN: Could not register device.\n"); printk(KERN_ERR "TLAN: Could not register device.\n");
unregister_netdev(dev); goto err_out_uninit;
kfree(dev); }
return -EAGAIN;
} else {
TLanDevicesInstalled++; TLanDevicesInstalled++;
boards_found++; boards_found++;
...@@ -631,8 +644,19 @@ static int __devinit TLan_probe1(struct pci_dev *pdev, ...@@ -631,8 +644,19 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
priv->adapter->deviceLabel, priv->adapter->deviceLabel,
priv->adapterRev); priv->adapterRev);
return 0; return 0;
}
err_out_uninit:
pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage,
priv->dmaStorageDMA );
err_out_free_dev:
kfree(dev);
err_out_regions:
if (pdev)
pci_release_regions(pdev);
err_out:
if (pdev)
pci_disable_device(pdev);
return rc;
} }
...@@ -798,15 +822,6 @@ static int TLan_Init( struct net_device *dev ) ...@@ -798,15 +822,6 @@ static int TLan_Init( struct net_device *dev )
priv = dev->priv; priv = dev->priv;
if (!priv->is_eisa) /* EISA devices have already requested IO */
if (!request_region( dev->base_addr, 0x10, TLanSignature )) {
printk(KERN_ERR "TLAN: %s: IO port region 0x%lx size 0x%x in use.\n",
dev->name,
dev->base_addr,
0x10 );
return -EIO;
}
if ( bbuf ) { if ( bbuf ) {
dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS ) dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
* ( sizeof(TLanList) + TLAN_MAX_FRAME_SIZE ); * ( sizeof(TLanList) + TLAN_MAX_FRAME_SIZE );
...@@ -820,7 +835,6 @@ static int TLan_Init( struct net_device *dev ) ...@@ -820,7 +835,6 @@ static int TLan_Init( struct net_device *dev )
if ( priv->dmaStorage == NULL ) { if ( priv->dmaStorage == NULL ) {
printk(KERN_ERR "TLAN: Could not allocate lists and buffers for %s.\n", printk(KERN_ERR "TLAN: Could not allocate lists and buffers for %s.\n",
dev->name ); dev->name );
release_region( dev->base_addr, 0x10 );
return -ENOMEM; return -ENOMEM;
} }
memset( priv->dmaStorage, 0, dma_size ); memset( priv->dmaStorage, 0, dma_size );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment