aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2008-07-11 18:17:28 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-22 19:39:03 -0400
commitc7be73bc9bfc8a650fe646f484dea5bad3cf92d5 (patch)
treeeda274bf195f4df6ede9d67913165e9176dc717e /drivers/net/e1000
parentb11840204f36f9a1e3027033227e17d167e04377 (diff)
e1000: Move assignments in tests before test
Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/e1000')
-rw-r--r--drivers/net/e1000/e1000_ethtool.c49
-rw-r--r--drivers/net/e1000/e1000_main.c41
2 files changed, 56 insertions, 34 deletions
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index f9ac9a87ffab..6a3893acfe04 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -483,10 +483,12 @@ static int e1000_get_eeprom(struct net_device *netdev,
483 last_word - first_word + 1, 483 last_word - first_word + 1,
484 eeprom_buff); 484 eeprom_buff);
485 else { 485 else {
486 for (i = 0; i < last_word - first_word + 1; i++) 486 for (i = 0; i < last_word - first_word + 1; i++) {
487 if ((ret_val = e1000_read_eeprom(hw, first_word + i, 1, 487 ret_val = e1000_read_eeprom(hw, first_word + i, 1,
488 &eeprom_buff[i]))) 488 &eeprom_buff[i]);
489 if (ret_val)
489 break; 490 break;
491 }
490 } 492 }
491 493
492 /* Device's eeprom is always little-endian, word addressable */ 494 /* Device's eeprom is always little-endian, word addressable */
@@ -669,9 +671,11 @@ static int e1000_set_ringparam(struct net_device *netdev,
669 671
670 if (netif_running(adapter->netdev)) { 672 if (netif_running(adapter->netdev)) {
671 /* Try to get new resources before deleting old */ 673 /* Try to get new resources before deleting old */
672 if ((err = e1000_setup_all_rx_resources(adapter))) 674 err = e1000_setup_all_rx_resources(adapter);
675 if (err)
673 goto err_setup_rx; 676 goto err_setup_rx;
674 if ((err = e1000_setup_all_tx_resources(adapter))) 677 err = e1000_setup_all_tx_resources(adapter);
678 if (err)
675 goto err_setup_tx; 679 goto err_setup_tx;
676 680
677 /* save the new, restore the old in order to free it, 681 /* save the new, restore the old in order to free it,
@@ -685,7 +689,8 @@ static int e1000_set_ringparam(struct net_device *netdev,
685 kfree(rx_old); 689 kfree(rx_old);
686 adapter->rx_ring = rxdr; 690 adapter->rx_ring = rxdr;
687 adapter->tx_ring = txdr; 691 adapter->tx_ring = txdr;
688 if ((err = e1000_up(adapter))) 692 err = e1000_up(adapter);
693 if (err)
689 goto err_setup; 694 goto err_setup;
690 } 695 }
691 696
@@ -1057,17 +1062,17 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1057 if (!txdr->count) 1062 if (!txdr->count)
1058 txdr->count = E1000_DEFAULT_TXD; 1063 txdr->count = E1000_DEFAULT_TXD;
1059 1064
1060 if (!(txdr->buffer_info = kcalloc(txdr->count, 1065 txdr->buffer_info = kcalloc(txdr->count, sizeof(struct e1000_buffer),
1061 sizeof(struct e1000_buffer), 1066 GFP_KERNEL);
1062 GFP_KERNEL))) { 1067 if (!txdr->buffer_info) {
1063 ret_val = 1; 1068 ret_val = 1;
1064 goto err_nomem; 1069 goto err_nomem;
1065 } 1070 }
1066 1071
1067 txdr->size = txdr->count * sizeof(struct e1000_tx_desc); 1072 txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
1068 txdr->size = ALIGN(txdr->size, 4096); 1073 txdr->size = ALIGN(txdr->size, 4096);
1069 if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, 1074 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
1070 &txdr->dma))) { 1075 if (!txdr->desc) {
1071 ret_val = 2; 1076 ret_val = 2;
1072 goto err_nomem; 1077 goto err_nomem;
1073 } 1078 }
@@ -1088,7 +1093,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1088 struct sk_buff *skb; 1093 struct sk_buff *skb;
1089 unsigned int size = 1024; 1094 unsigned int size = 1024;
1090 1095
1091 if (!(skb = alloc_skb(size, GFP_KERNEL))) { 1096 skb = alloc_skb(size, GFP_KERNEL);
1097 if (!skb) {
1092 ret_val = 3; 1098 ret_val = 3;
1093 goto err_nomem; 1099 goto err_nomem;
1094 } 1100 }
@@ -1111,15 +1117,16 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1111 if (!rxdr->count) 1117 if (!rxdr->count)
1112 rxdr->count = E1000_DEFAULT_RXD; 1118 rxdr->count = E1000_DEFAULT_RXD;
1113 1119
1114 if (!(rxdr->buffer_info = kcalloc(rxdr->count, 1120 rxdr->buffer_info = kcalloc(rxdr->count, sizeof(struct e1000_buffer),
1115 sizeof(struct e1000_buffer), 1121 GFP_KERNEL);
1116 GFP_KERNEL))) { 1122 if (!rxdr->buffer_info) {
1117 ret_val = 4; 1123 ret_val = 4;
1118 goto err_nomem; 1124 goto err_nomem;
1119 } 1125 }
1120 1126
1121 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc); 1127 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
1122 if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) { 1128 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
1129 if (!rxdr->desc) {
1123 ret_val = 5; 1130 ret_val = 5;
1124 goto err_nomem; 1131 goto err_nomem;
1125 } 1132 }
@@ -1142,8 +1149,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1142 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i); 1149 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
1143 struct sk_buff *skb; 1150 struct sk_buff *skb;
1144 1151
1145 if (!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, 1152 skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, GFP_KERNEL);
1146 GFP_KERNEL))) { 1153 if (!skb) {
1147 ret_val = 6; 1154 ret_val = 6;
1148 goto err_nomem; 1155 goto err_nomem;
1149 } 1156 }
@@ -1564,9 +1571,11 @@ static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data)
1564 goto out; 1571 goto out;
1565 } 1572 }
1566 1573
1567 if ((*data = e1000_setup_desc_rings(adapter))) 1574 *data = e1000_setup_desc_rings(adapter);
1575 if (*data)
1568 goto out; 1576 goto out;
1569 if ((*data = e1000_setup_loopback_test(adapter))) 1577 *data = e1000_setup_loopback_test(adapter);
1578 if (*data)
1570 goto err_loopback; 1579 goto err_loopback;
1571 *data = e1000_run_loopback_test(adapter); 1580 *data = e1000_run_loopback_test(adapter);
1572 e1000_loopback_cleanup(adapter); 1581 e1000_loopback_cleanup(adapter);
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index cb44fded47ed..0de2006e8b97 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -898,22 +898,28 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
898 u16 eeprom_apme_mask = E1000_EEPROM_APME; 898 u16 eeprom_apme_mask = E1000_EEPROM_APME;
899 DECLARE_MAC_BUF(mac); 899 DECLARE_MAC_BUF(mac);
900 900
901 if ((err = pci_enable_device(pdev))) 901 err = pci_enable_device(pdev);
902 if (err)
902 return err; 903 return err;
903 904
904 if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) && 905 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
905 !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) { 906 !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
906 pci_using_dac = 1; 907 pci_using_dac = 1;
907 } else { 908 } else {
908 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) && 909 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
909 (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) { 910 if (err) {
910 E1000_ERR("No usable DMA configuration, aborting\n"); 911 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
911 goto err_dma; 912 if (err) {
913 E1000_ERR("No usable DMA configuration, "
914 "aborting\n");
915 goto err_dma;
916 }
912 } 917 }
913 pci_using_dac = 0; 918 pci_using_dac = 0;
914 } 919 }
915 920
916 if ((err = pci_request_regions(pdev, e1000_driver_name))) 921 err = pci_request_regions(pdev, e1000_driver_name);
922 if (err)
917 goto err_pci_reg; 923 goto err_pci_reg;
918 924
919 pci_set_master(pdev); 925 pci_set_master(pdev);
@@ -975,7 +981,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
975 981
976 /* setup the private structure */ 982 /* setup the private structure */
977 983
978 if ((err = e1000_sw_init(adapter))) 984 err = e1000_sw_init(adapter);
985 if (err)
979 goto err_sw_init; 986 goto err_sw_init;
980 987
981 err = -EIO; 988 err = -EIO;
@@ -1182,7 +1189,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1182 netif_stop_queue(netdev); 1189 netif_stop_queue(netdev);
1183 1190
1184 strcpy(netdev->name, "eth%d"); 1191 strcpy(netdev->name, "eth%d");
1185 if ((err = register_netdev(netdev))) 1192 err = register_netdev(netdev);
1193 if (err)
1186 goto err_register; 1194 goto err_register;
1187 1195
1188 DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n"); 1196 DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
@@ -4400,7 +4408,8 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
4400 } 4408 }
4401 4409
4402 for (j = 0; j < adapter->rx_ps_pages; j++) { 4410 for (j = 0; j < adapter->rx_ps_pages; j++) {
4403 if (!(length= le16_to_cpu(rx_desc->wb.upper.length[j]))) 4411 length = le16_to_cpu(rx_desc->wb.upper.length[j]);
4412 if (!length)
4404 break; 4413 break;
4405 pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j], 4414 pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
4406 PAGE_SIZE, PCI_DMA_FROMDEVICE); 4415 PAGE_SIZE, PCI_DMA_FROMDEVICE);
@@ -5153,7 +5162,8 @@ static int e1000_resume(struct pci_dev *pdev)
5153 5162
5154 pci_set_power_state(pdev, PCI_D0); 5163 pci_set_power_state(pdev, PCI_D0);
5155 pci_restore_state(pdev); 5164 pci_restore_state(pdev);
5156 if ((err = pci_enable_device(pdev))) { 5165 err = pci_enable_device(pdev);
5166 if (err) {
5157 printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n"); 5167 printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n");
5158 return err; 5168 return err;
5159 } 5169 }
@@ -5162,8 +5172,11 @@ static int e1000_resume(struct pci_dev *pdev)
5162 pci_enable_wake(pdev, PCI_D3hot, 0); 5172 pci_enable_wake(pdev, PCI_D3hot, 0);
5163 pci_enable_wake(pdev, PCI_D3cold, 0); 5173 pci_enable_wake(pdev, PCI_D3cold, 0);
5164 5174
5165 if (netif_running(netdev) && (err = e1000_request_irq(adapter))) 5175 if (netif_running(netdev)) {
5166 return err; 5176 err = e1000_request_irq(adapter);
5177 if (err)
5178 return err;
5179 }
5167 5180
5168 e1000_power_up_phy(adapter); 5181 e1000_power_up_phy(adapter);
5169 e1000_reset(adapter); 5182 e1000_reset(adapter);