aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2009-09-05 13:43:07 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-07 04:53:01 -0400
commitdb4cfd8a6149e778befb2ff6e6f91cdc6394cbe6 (patch)
treedd1faddbbce164b86e58a7cde54bfbd7b3f528bd /drivers/net/netxen
parent6ec1c69a8f6492fd25722f4762721921da074c12 (diff)
netxen: handle firmware load errors
Unwind allocations and release file firmware when when firmware load fails. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c3
-rw-r--r--drivers/net/netxen/netxen_nic_init.c1
-rw-r--r--drivers/net/netxen/netxen_nic_main.c20
3 files changed, 20 insertions, 4 deletions
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index db510cee8094..d0ac8fabd423 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -566,6 +566,9 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
566 566
567 i = 0; 567 i = 0;
568 568
569 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
570 return -EIO;
571
569 tx_ring = adapter->tx_ring; 572 tx_ring = adapter->tx_ring;
570 __netif_tx_lock_bh(tx_ring->txq); 573 __netif_tx_lock_bh(tx_ring->txq);
571 574
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 04e36f2b1a93..534994dc167f 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -905,6 +905,7 @@ netxen_release_firmware(struct netxen_adapter *adapter)
905{ 905{
906 if (adapter->fw) 906 if (adapter->fw)
907 release_firmware(adapter->fw); 907 release_firmware(adapter->fw);
908 adapter->fw = NULL;
908} 909}
909 910
910int netxen_init_dummy_dma(struct netxen_adapter *adapter) 911int netxen_init_dummy_dma(struct netxen_adapter *adapter)
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 41b29671fc9a..47aede622035 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -757,7 +757,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
757 757
758 err = netxen_need_fw_reset(adapter); 758 err = netxen_need_fw_reset(adapter);
759 if (err < 0) 759 if (err < 0)
760 return err; 760 goto err_out;
761 if (err == 0) 761 if (err == 0)
762 goto wait_init; 762 goto wait_init;
763 763
@@ -771,7 +771,9 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
771 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 771 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
772 netxen_set_port_mode(adapter); 772 netxen_set_port_mode(adapter);
773 773
774 netxen_load_firmware(adapter); 774 err = netxen_load_firmware(adapter);
775 if (err)
776 goto err_out;
775 777
776 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 778 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
777 779
@@ -785,7 +787,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
785 787
786 err = netxen_init_dummy_dma(adapter); 788 err = netxen_init_dummy_dma(adapter);
787 if (err) 789 if (err)
788 return err; 790 goto err_out;
789 791
790 /* 792 /*
791 * Tell the hardware our version number. 793 * Tell the hardware our version number.
@@ -800,7 +802,7 @@ wait_init:
800 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 802 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
801 if (err) { 803 if (err) {
802 netxen_free_dummy_dma(adapter); 804 netxen_free_dummy_dma(adapter);
803 return err; 805 goto err_out;
804 } 806 }
805 807
806 nx_update_dma_mask(adapter); 808 nx_update_dma_mask(adapter);
@@ -808,6 +810,10 @@ wait_init:
808 netxen_nic_get_firmware_info(adapter); 810 netxen_nic_get_firmware_info(adapter);
809 811
810 return 0; 812 return 0;
813
814err_out:
815 netxen_release_firmware(adapter);
816 return err;
811} 817}
812 818
813static int 819static int
@@ -876,6 +882,9 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
876{ 882{
877 int err; 883 int err;
878 884
885 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
886 return -EIO;
887
879 err = adapter->init_port(adapter, adapter->physical_port); 888 err = adapter->init_port(adapter, adapter->physical_port);
880 if (err) { 889 if (err) {
881 printk(KERN_ERR "%s: Failed to initialize port %d\n", 890 printk(KERN_ERR "%s: Failed to initialize port %d\n",
@@ -914,6 +923,9 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
914static void 923static void
915netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) 924netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
916{ 925{
926 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
927 return;
928
917 spin_lock(&adapter->tx_clean_lock); 929 spin_lock(&adapter->tx_clean_lock);
918 netif_carrier_off(netdev); 930 netif_carrier_off(netdev);
919 netif_tx_disable(netdev); 931 netif_tx_disable(netdev);