Commit 75a750a5 authored by Scott Feldman's avatar Scott Feldman Committed by Stephen Hemminger

[e1000] better propagation of error codes

* Better propagation of error codes during probe/open paths.
  {Janice Girouard (janiceg@us.ibm.com)]
parent 5c2e1b8f
...@@ -250,6 +250,7 @@ int ...@@ -250,6 +250,7 @@ int
e1000_up(struct e1000_adapter *adapter) e1000_up(struct e1000_adapter *adapter)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
int err;
/* hardware has been reset, we need to reload some things */ /* hardware has been reset, we need to reload some things */
...@@ -262,9 +263,10 @@ e1000_up(struct e1000_adapter *adapter) ...@@ -262,9 +263,10 @@ e1000_up(struct e1000_adapter *adapter)
e1000_configure_rx(adapter); e1000_configure_rx(adapter);
e1000_alloc_rx_buffers(adapter); e1000_alloc_rx_buffers(adapter);
if(request_irq(netdev->irq, &e1000_intr, SA_SHIRQ | SA_SAMPLE_RANDOM, if((err = request_irq(netdev->irq, &e1000_intr,
netdev->name, netdev)) SA_SHIRQ | SA_SAMPLE_RANDOM,
return -1; netdev->name, netdev)))
return err;
mod_timer(&adapter->watchdog_timer, jiffies); mod_timer(&adapter->watchdog_timer, jiffies);
e1000_irq_enable(adapter); e1000_irq_enable(adapter);
...@@ -356,29 +358,32 @@ e1000_probe(struct pci_dev *pdev, ...@@ -356,29 +358,32 @@ e1000_probe(struct pci_dev *pdev,
int mmio_len; int mmio_len;
int pci_using_dac; int pci_using_dac;
int i; int i;
int err;
uint16_t eeprom_data; uint16_t eeprom_data;
if((i = pci_enable_device(pdev))) if((err = pci_enable_device(pdev)))
return i; return err;
if(!(i = pci_set_dma_mask(pdev, PCI_DMA_64BIT))) { if(!(err = pci_set_dma_mask(pdev, PCI_DMA_64BIT))) {
pci_using_dac = 1; pci_using_dac = 1;
} else { } else {
if((i = pci_set_dma_mask(pdev, PCI_DMA_32BIT))) { if((err = pci_set_dma_mask(pdev, PCI_DMA_32BIT))) {
E1000_ERR("No usable DMA configuration, aborting\n"); E1000_ERR("No usable DMA configuration, aborting\n");
return i; return err;
} }
pci_using_dac = 0; pci_using_dac = 0;
} }
if((i = pci_request_regions(pdev, e1000_driver_name))) if((err = pci_request_regions(pdev, e1000_driver_name)))
return i; return err;
pci_set_master(pdev); pci_set_master(pdev);
netdev = alloc_etherdev(sizeof(struct e1000_adapter)); netdev = alloc_etherdev(sizeof(struct e1000_adapter));
if(!netdev) if(!netdev) {
err = -ENOMEM;
goto err_alloc_etherdev; goto err_alloc_etherdev;
}
SET_MODULE_OWNER(netdev); SET_MODULE_OWNER(netdev);
SET_NETDEV_DEV(netdev, &pdev->dev); SET_NETDEV_DEV(netdev, &pdev->dev);
...@@ -393,8 +398,10 @@ e1000_probe(struct pci_dev *pdev, ...@@ -393,8 +398,10 @@ e1000_probe(struct pci_dev *pdev,
mmio_len = pci_resource_len(pdev, BAR_0); mmio_len = pci_resource_len(pdev, BAR_0);
adapter->hw.hw_addr = ioremap(mmio_start, mmio_len); adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
if(!adapter->hw.hw_addr) if(!adapter->hw.hw_addr) {
err = -EIO;
goto err_ioremap; goto err_ioremap;
}
for(i = BAR_1; i <= BAR_5; i++) { for(i = BAR_1; i <= BAR_5; i++) {
if(pci_resource_len(pdev, i) == 0) if(pci_resource_len(pdev, i) == 0)
...@@ -432,7 +439,7 @@ e1000_probe(struct pci_dev *pdev, ...@@ -432,7 +439,7 @@ e1000_probe(struct pci_dev *pdev,
/* setup the private structure */ /* setup the private structure */
if(e1000_sw_init(adapter)) if((err = e1000_sw_init(adapter)))
goto err_sw_init; goto err_sw_init;
if(adapter->hw.mac_type >= e1000_82543) { if(adapter->hw.mac_type >= e1000_82543) {
...@@ -463,6 +470,7 @@ e1000_probe(struct pci_dev *pdev, ...@@ -463,6 +470,7 @@ e1000_probe(struct pci_dev *pdev,
if(e1000_validate_eeprom_checksum(&adapter->hw) < 0) { if(e1000_validate_eeprom_checksum(&adapter->hw) < 0) {
printk(KERN_ERR "The EEPROM Checksum Is Not Valid\n"); printk(KERN_ERR "The EEPROM Checksum Is Not Valid\n");
err = -EIO;
goto err_eeprom; goto err_eeprom;
} }
...@@ -471,8 +479,10 @@ e1000_probe(struct pci_dev *pdev, ...@@ -471,8 +479,10 @@ e1000_probe(struct pci_dev *pdev,
e1000_read_mac_addr(&adapter->hw); e1000_read_mac_addr(&adapter->hw);
memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len); memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
if(!is_valid_ether_addr(netdev->dev_addr)) if(!is_valid_ether_addr(netdev->dev_addr)) {
err = -EIO;
goto err_eeprom; goto err_eeprom;
}
e1000_read_part_num(&adapter->hw, &(adapter->part_num)); e1000_read_part_num(&adapter->hw, &(adapter->part_num));
...@@ -545,7 +555,7 @@ e1000_probe(struct pci_dev *pdev, ...@@ -545,7 +555,7 @@ e1000_probe(struct pci_dev *pdev,
kfree(netdev); kfree(netdev);
err_alloc_etherdev: err_alloc_etherdev:
pci_release_regions(pdev); pci_release_regions(pdev);
return -ENOMEM; return err;
} }
/** /**
...@@ -620,7 +630,7 @@ e1000_sw_init(struct e1000_adapter *adapter) ...@@ -620,7 +630,7 @@ e1000_sw_init(struct e1000_adapter *adapter)
if (e1000_set_mac_type(hw)) { if (e1000_set_mac_type(hw)) {
E1000_ERR("Unknown MAC Type\n"); E1000_ERR("Unknown MAC Type\n");
return -1; return -EIO;
} }
/* initialize eeprom parameters */ /* initialize eeprom parameters */
...@@ -675,18 +685,19 @@ static int ...@@ -675,18 +685,19 @@ static int
e1000_open(struct net_device *netdev) e1000_open(struct net_device *netdev)
{ {
struct e1000_adapter *adapter = netdev->priv; struct e1000_adapter *adapter = netdev->priv;
int err;
/* allocate transmit descriptors */ /* allocate transmit descriptors */
if(e1000_setup_tx_resources(adapter)) if((err = e1000_setup_tx_resources(adapter)))
goto err_setup_tx; goto err_setup_tx;
/* allocate receive descriptors */ /* allocate receive descriptors */
if(e1000_setup_rx_resources(adapter)) if((err = e1000_setup_rx_resources(adapter)))
goto err_setup_rx; goto err_setup_rx;
if(e1000_up(adapter)) if((err = e1000_up(adapter)))
goto err_up; goto err_up;
return 0; return 0;
...@@ -698,7 +709,7 @@ e1000_open(struct net_device *netdev) ...@@ -698,7 +709,7 @@ e1000_open(struct net_device *netdev)
err_setup_tx: err_setup_tx:
e1000_reset(adapter); e1000_reset(adapter);
return -EBUSY; return err;
} }
/** /**
......
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