* Removed unused bool variable.
* Eliminated mid-function returns, used gotos instead
Signed-off-by: Mark Einon <mark.einon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
struct et131x_adapter *adapter;
struct et131x_adapter *adapter;
- /* Setup the fundamental net_device and private adapter structure
- * elements */
- SET_NETDEV_DEV(netdev, &pdev->dev);
-
/* Allocate private adapter struct and copy in relevant information */
adapter = netdev_priv(netdev);
adapter->pdev = pci_dev_get(pdev);
/* Allocate private adapter struct and copy in relevant information */
adapter = netdev_priv(netdev);
adapter->pdev = pci_dev_get(pdev);
static int __devinit et131x_pci_setup(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
static int __devinit et131x_pci_setup(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct net_device *netdev;
struct et131x_adapter *adapter;
/* Enable the device via the PCI subsystem */
struct net_device *netdev;
struct et131x_adapter *adapter;
/* Enable the device via the PCI subsystem */
- if (pci_enable_device(pdev) != 0) {
- dev_err(&pdev->dev,
- "pci_enable_device() failed\n");
- return -EIO;
+ result = pci_enable_device(pdev);
+ if (result) {
+ dev_err(&pdev->dev, "pci_enable_device() failed\n");
+ goto err_out;
}
/* Perform some basic PCI checks */
if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
}
/* Perform some basic PCI checks */
if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
- dev_err(&pdev->dev,
- "Can't find PCI device's base address\n");
+ dev_err(&pdev->dev, "Can't find PCI device's base address\n");
goto err_disable;
}
if (pci_request_regions(pdev, DRIVER_NAME)) {
goto err_disable;
}
if (pci_request_regions(pdev, DRIVER_NAME)) {
- dev_err(&pdev->dev,
- "Can't get PCI resources\n");
+ dev_err(&pdev->dev, "Can't get PCI resources\n");
- /* Enable PCI bus mastering */
pci_set_master(pdev);
/* Query PCI for Power Mgmt Capabilities
pci_set_master(pdev);
/* Query PCI for Power Mgmt Capabilities
* needed?
*/
pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
* needed?
*/
pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
dev_err(&pdev->dev,
"Cannot find Power Management capabilities\n");
result = -EIO;
dev_err(&pdev->dev,
"Cannot find Power Management capabilities\n");
result = -EIO;
/* Check the DMA addressing support of this device */
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
/* Check the DMA addressing support of this device */
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
- pci_using_dac = true;
-
result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
- "Unable to obtain 64 bit DMA for consistent allocations\n");
+ "Unable to obtain 64 bit DMA for consistent allocations\n");
goto err_release_res;
}
} else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
goto err_release_res;
}
} else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
+ result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (result) {
+ dev_err(&pdev->dev,
+ "Unable to obtain 32 bit DMA for consistent allocations\n");
+ goto err_release_res;
+ }
- dev_err(&pdev->dev,
- "No usable DMA addressing method\n");
+ dev_err(&pdev->dev, "No usable DMA addressing method\n");
result = -EIO;
goto err_release_res;
}
/* Allocate netdev and private adapter structs */
netdev = et131x_device_alloc();
result = -EIO;
goto err_release_res;
}
/* Allocate netdev and private adapter structs */
netdev = et131x_device_alloc();
dev_err(&pdev->dev, "Couldn't alloc netdev struct\n");
result = -ENOMEM;
goto err_release_res;
}
dev_err(&pdev->dev, "Couldn't alloc netdev struct\n");
result = -ENOMEM;
goto err_release_res;
}
+
+ SET_NETDEV_DEV(netdev, &pdev->dev);
+
adapter = et131x_adapter_init(netdev, pdev);
/* Initialise the PCI setup for the device */
et131x_pci_init(adapter, pdev);
/* Map the bus-relative registers to system virtual memory */
adapter->regs = pci_ioremap_bar(pdev, 0);
adapter = et131x_adapter_init(netdev, pdev);
/* Initialise the PCI setup for the device */
et131x_pci_init(adapter, pdev);
/* Map the bus-relative registers to system virtual memory */
adapter->regs = pci_ioremap_bar(pdev, 0);
- if (adapter->regs == NULL) {
dev_err(&pdev->dev, "Cannot map device registers\n");
result = -ENOMEM;
goto err_free_dev;
dev_err(&pdev->dev, "Cannot map device registers\n");
result = -ENOMEM;
goto err_free_dev;
/* Allocate DMA memory */
result = et131x_adapter_memory_alloc(adapter);
/* Allocate DMA memory */
result = et131x_adapter_memory_alloc(adapter);
dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n");
goto err_iounmap;
}
dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n");
goto err_iounmap;
}
/* Init send data structures */
et131x_init_send(adapter);
/* Init send data structures */
et131x_init_send(adapter);
- /*
- * Set up the task structure for the ISR's deferred handler
- */
+ /* Set up the task structure for the ISR's deferred handler */
INIT_WORK(&adapter->task, et131x_isr_handler);
/* Copy address into the net_device struct */
INIT_WORK(&adapter->task, et131x_isr_handler);
/* Copy address into the net_device struct */
/* Initialize link state */
netif_carrier_off(adapter->netdev);
/* Initialize link state */
netif_carrier_off(adapter->netdev);
- /* Initialize variable for counting how long we do not have
- link status */
+ /* Init variable for counting how long we do not have link status */
adapter->boot_coma = 0;
/* We can enable interrupts now
adapter->boot_coma = 0;
/* We can enable interrupts now
*/
pci_set_drvdata(pdev, netdev);
pci_save_state(adapter->pdev);
*/
pci_set_drvdata(pdev, netdev);
pci_save_state(adapter->pdev);
return result;
err_mem_free:
return result;
err_mem_free:
pci_release_regions(pdev);
err_disable:
pci_disable_device(pdev);
pci_release_regions(pdev);
err_disable:
pci_disable_device(pdev);
/* Alloc net_device and adapter structs */
netdev = alloc_etherdev(sizeof(struct et131x_adapter));
/* Alloc net_device and adapter structs */
netdev = alloc_etherdev(sizeof(struct et131x_adapter));
printk(KERN_ERR "et131x: Alloc of net_device struct failed\n");
return NULL;
}
printk(KERN_ERR "et131x: Alloc of net_device struct failed\n");
return NULL;
}