Commit 5015e53a authored by Bruce Allan's avatar Bruce Allan Committed by Jeff Kirsher

e1000e: cleanup goto statements to exit points without common work

Per ./Documentation/CodingStyle, goto statements are acceptable for the
centralized exiting of functions when there are multiple exit points which
share common work such as cleanup.  When no common work is required for
multiple exit points, the function should just return at these exit points
instead of doing an unnecessary jump to a centralized return.  This patch
cleans up the inappropriate use of goto statements, and removes unnecessary
variables (or move to a smaller scope) where possible as a result of the
cleanups.
Signed-off-by: default avatarBruce Allan <bruce.w.allan@intel.com>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 2a31b37a
...@@ -714,22 +714,19 @@ static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw) ...@@ -714,22 +714,19 @@ static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data); ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
if (ret_val) if (ret_val)
goto out; return ret_val;
index = phy_data & GG82563_DSPD_CABLE_LENGTH; index = phy_data & GG82563_DSPD_CABLE_LENGTH;
if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5) { if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5)
ret_val = -E1000_ERR_PHY; return -E1000_ERR_PHY;
goto out;
}
phy->min_cable_length = e1000_gg82563_cable_length_table[index]; phy->min_cable_length = e1000_gg82563_cable_length_table[index];
phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5]; phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
out: return 0;
return ret_val;
} }
/** /**
...@@ -1348,12 +1345,9 @@ static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw) ...@@ -1348,12 +1345,9 @@ static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
*/ */
ret_val = e1000_check_alt_mac_addr_generic(hw); ret_val = e1000_check_alt_mac_addr_generic(hw);
if (ret_val) if (ret_val)
goto out; return ret_val;
ret_val = e1000_read_mac_addr_generic(hw);
out: return e1000_read_mac_addr_generic(hw);
return ret_val;
} }
/** /**
......
...@@ -564,7 +564,6 @@ static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw) ...@@ -564,7 +564,6 @@ static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw) static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
{ {
u32 extcnf_ctrl; u32 extcnf_ctrl;
s32 ret_val = 0;
s32 i = 0; s32 i = 0;
extcnf_ctrl = er32(EXTCNF_CTRL); extcnf_ctrl = er32(EXTCNF_CTRL);
...@@ -586,12 +585,10 @@ static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw) ...@@ -586,12 +585,10 @@ static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
/* Release semaphores */ /* Release semaphores */
e1000_put_hw_semaphore_82573(hw); e1000_put_hw_semaphore_82573(hw);
e_dbg("Driver can't access the PHY\n"); e_dbg("Driver can't access the PHY\n");
ret_val = -E1000_ERR_PHY; return -E1000_ERR_PHY;
goto out;
} }
out: return 0;
return ret_val;
} }
/** /**
...@@ -1409,7 +1406,6 @@ bool e1000_check_phy_82574(struct e1000_hw *hw) ...@@ -1409,7 +1406,6 @@ bool e1000_check_phy_82574(struct e1000_hw *hw)
{ {
u16 status_1kbt = 0; u16 status_1kbt = 0;
u16 receive_errors = 0; u16 receive_errors = 0;
bool phy_hung = false;
s32 ret_val = 0; s32 ret_val = 0;
/* /*
...@@ -1417,19 +1413,18 @@ bool e1000_check_phy_82574(struct e1000_hw *hw) ...@@ -1417,19 +1413,18 @@ bool e1000_check_phy_82574(struct e1000_hw *hw)
* read the Base1000T status register If both are max then PHY is hung. * read the Base1000T status register If both are max then PHY is hung.
*/ */
ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors); ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors);
if (ret_val) if (ret_val)
goto out; return false;
if (receive_errors == E1000_RECEIVE_ERROR_MAX) { if (receive_errors == E1000_RECEIVE_ERROR_MAX) {
ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt); ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt);
if (ret_val) if (ret_val)
goto out; return false;
if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) == if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) ==
E1000_IDLE_ERROR_COUNT_MASK) E1000_IDLE_ERROR_COUNT_MASK)
phy_hung = true; return true;
} }
out:
return phy_hung; return false;
} }
/** /**
...@@ -1831,9 +1826,9 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw) ...@@ -1831,9 +1826,9 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
**/ **/
static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw) static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
{ {
s32 ret_val = 0;
if (hw->mac.type == e1000_82571) { if (hw->mac.type == e1000_82571) {
s32 ret_val = 0;
/* /*
* If there's an alternate MAC address place it in RAR0 * If there's an alternate MAC address place it in RAR0
* so that it will override the Si installed default perm * so that it will override the Si installed default perm
...@@ -1841,13 +1836,10 @@ static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw) ...@@ -1841,13 +1836,10 @@ static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
*/ */
ret_val = e1000_check_alt_mac_addr_generic(hw); ret_val = e1000_check_alt_mac_addr_generic(hw);
if (ret_val) if (ret_val)
goto out; return ret_val;
} }
ret_val = e1000_read_mac_addr_generic(hw); return e1000_read_mac_addr_generic(hw);
out:
return ret_val;
} }
/** /**
......
This diff is collapsed.
...@@ -172,23 +172,23 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) ...@@ -172,23 +172,23 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
ret_val = e1000_read_nvm(hw, NVM_COMPAT, 1, &nvm_data); ret_val = e1000_read_nvm(hw, NVM_COMPAT, 1, &nvm_data);
if (ret_val) if (ret_val)
goto out; return ret_val;
/* not supported on 82573 */ /* not supported on 82573 */
if (hw->mac.type == e1000_82573) if (hw->mac.type == e1000_82573)
goto out; return 0;
ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1,
&nvm_alt_mac_addr_offset); &nvm_alt_mac_addr_offset);
if (ret_val) { if (ret_val) {
e_dbg("NVM Read Error\n"); e_dbg("NVM Read Error\n");
goto out; return ret_val;
} }
if ((nvm_alt_mac_addr_offset == 0xFFFF) || if ((nvm_alt_mac_addr_offset == 0xFFFF) ||
(nvm_alt_mac_addr_offset == 0x0000)) (nvm_alt_mac_addr_offset == 0x0000))
/* There is no Alternate MAC Address */ /* There is no Alternate MAC Address */
goto out; return 0;
if (hw->bus.func == E1000_FUNC_1) if (hw->bus.func == E1000_FUNC_1)
nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN1; nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN1;
...@@ -197,7 +197,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) ...@@ -197,7 +197,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data); ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data);
if (ret_val) { if (ret_val) {
e_dbg("NVM Read Error\n"); e_dbg("NVM Read Error\n");
goto out; return ret_val;
} }
alt_mac_addr[i] = (u8)(nvm_data & 0xFF); alt_mac_addr[i] = (u8)(nvm_data & 0xFF);
...@@ -207,7 +207,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) ...@@ -207,7 +207,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
/* if multicast bit is set, the alternate address will not be used */ /* if multicast bit is set, the alternate address will not be used */
if (is_multicast_ether_addr(alt_mac_addr)) { if (is_multicast_ether_addr(alt_mac_addr)) {
e_dbg("Ignoring Alternate Mac Address with MC bit set\n"); e_dbg("Ignoring Alternate Mac Address with MC bit set\n");
goto out; return 0;
} }
/* /*
...@@ -217,8 +217,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) ...@@ -217,8 +217,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
*/ */
e1000e_rar_set(hw, alt_mac_addr, 0); e1000e_rar_set(hw, alt_mac_addr, 0);
out: return 0;
return ret_val;
} }
/** /**
......
...@@ -140,7 +140,7 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) ...@@ -140,7 +140,7 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw)
/* No manageability, no filtering */ /* No manageability, no filtering */
if (!e1000e_check_mng_mode(hw)) { if (!e1000e_check_mng_mode(hw)) {
hw->mac.tx_pkt_filtering = false; hw->mac.tx_pkt_filtering = false;
goto out; return hw->mac.tx_pkt_filtering;
} }
/* /*
...@@ -150,7 +150,7 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) ...@@ -150,7 +150,7 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw)
ret_val = e1000_mng_enable_host_if(hw); ret_val = e1000_mng_enable_host_if(hw);
if (ret_val) { if (ret_val) {
hw->mac.tx_pkt_filtering = false; hw->mac.tx_pkt_filtering = false;
goto out; return hw->mac.tx_pkt_filtering;
} }
/* Read in the header. Length and offset are in dwords. */ /* Read in the header. Length and offset are in dwords. */
...@@ -170,16 +170,13 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) ...@@ -170,16 +170,13 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw)
*/ */
if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) { if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) {
hw->mac.tx_pkt_filtering = true; hw->mac.tx_pkt_filtering = true;
goto out; return hw->mac.tx_pkt_filtering;
} }
/* Cookie area is valid, make the final check for filtering. */ /* Cookie area is valid, make the final check for filtering. */
if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING)) { if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING))
hw->mac.tx_pkt_filtering = false; hw->mac.tx_pkt_filtering = false;
goto out;
}
out:
return hw->mac.tx_pkt_filtering; return hw->mac.tx_pkt_filtering;
} }
...@@ -336,12 +333,11 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) ...@@ -336,12 +333,11 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
{ {
u32 manc; u32 manc;
u32 fwsm, factps; u32 fwsm, factps;
bool ret_val = false;
manc = er32(MANC); manc = er32(MANC);
if (!(manc & E1000_MANC_RCV_TCO_EN)) if (!(manc & E1000_MANC_RCV_TCO_EN))
goto out; return false;
if (hw->mac.has_fwsm) { if (hw->mac.has_fwsm) {
fwsm = er32(FWSM); fwsm = er32(FWSM);
...@@ -349,10 +345,8 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) ...@@ -349,10 +345,8 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
if (!(factps & E1000_FACTPS_MNGCG) && if (!(factps & E1000_FACTPS_MNGCG) &&
((fwsm & E1000_FWSM_MODE_MASK) == ((fwsm & E1000_FWSM_MODE_MASK) ==
(e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) { (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT)))
ret_val = true; return true;
goto out;
}
} else if ((hw->mac.type == e1000_82574) || } else if ((hw->mac.type == e1000_82574) ||
(hw->mac.type == e1000_82583)) { (hw->mac.type == e1000_82583)) {
u16 data; u16 data;
...@@ -362,16 +356,12 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) ...@@ -362,16 +356,12 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
if (!(factps & E1000_FACTPS_MNGCG) && if (!(factps & E1000_FACTPS_MNGCG) &&
((data & E1000_NVM_INIT_CTRL2_MNGM) == ((data & E1000_NVM_INIT_CTRL2_MNGM) ==
(e1000_mng_mode_pt << 13))) { (e1000_mng_mode_pt << 13)))
ret_val = true; return true;
goto out;
}
} else if ((manc & E1000_MANC_SMBUS_EN) && } else if ((manc & E1000_MANC_SMBUS_EN) &&
!(manc & E1000_MANC_ASF_EN)) { !(manc & E1000_MANC_ASF_EN)) {
ret_val = true; return true;
goto out;
} }
out: return false;
return ret_val;
} }
...@@ -1985,7 +1985,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter) ...@@ -1985,7 +1985,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
e1000_intr_msix_rx, 0, adapter->rx_ring->name, e1000_intr_msix_rx, 0, adapter->rx_ring->name,
netdev); netdev);
if (err) if (err)
goto out; return err;
adapter->rx_ring->itr_register = adapter->hw.hw_addr + adapter->rx_ring->itr_register = adapter->hw.hw_addr +
E1000_EITR_82574(vector); E1000_EITR_82574(vector);
adapter->rx_ring->itr_val = adapter->itr; adapter->rx_ring->itr_val = adapter->itr;
...@@ -2001,7 +2001,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter) ...@@ -2001,7 +2001,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
e1000_intr_msix_tx, 0, adapter->tx_ring->name, e1000_intr_msix_tx, 0, adapter->tx_ring->name,
netdev); netdev);
if (err) if (err)
goto out; return err;
adapter->tx_ring->itr_register = adapter->hw.hw_addr + adapter->tx_ring->itr_register = adapter->hw.hw_addr +
E1000_EITR_82574(vector); E1000_EITR_82574(vector);
adapter->tx_ring->itr_val = adapter->itr; adapter->tx_ring->itr_val = adapter->itr;
...@@ -2010,12 +2010,11 @@ static int e1000_request_msix(struct e1000_adapter *adapter) ...@@ -2010,12 +2010,11 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
err = request_irq(adapter->msix_entries[vector].vector, err = request_irq(adapter->msix_entries[vector].vector,
e1000_msix_other, 0, netdev->name, netdev); e1000_msix_other, 0, netdev->name, netdev);
if (err) if (err)
goto out; return err;
e1000_configure_msix(adapter); e1000_configure_msix(adapter);
return 0; return 0;
out:
return err;
} }
/** /**
...@@ -2367,7 +2366,7 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter, ...@@ -2367,7 +2366,7 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
unsigned int retval = itr_setting; unsigned int retval = itr_setting;
if (packets == 0) if (packets == 0)
goto update_itr_done; return itr_setting;
switch (itr_setting) { switch (itr_setting) {
case lowest_latency: case lowest_latency:
...@@ -2402,7 +2401,6 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter, ...@@ -2402,7 +2401,6 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
break; break;
} }
update_itr_done:
return retval; return retval;
} }
......
...@@ -446,20 +446,19 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, ...@@ -446,20 +446,19 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
if (pba_num == NULL) { if (pba_num == NULL) {
e_dbg("PBA string buffer was null\n"); e_dbg("PBA string buffer was null\n");
ret_val = E1000_ERR_INVALID_ARGUMENT; return -E1000_ERR_INVALID_ARGUMENT;
goto out;
} }
ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
if (ret_val) { if (ret_val) {
e_dbg("NVM Read Error\n"); e_dbg("NVM Read Error\n");
goto out; return ret_val;
} }
ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr); ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr);
if (ret_val) { if (ret_val) {
e_dbg("NVM Read Error\n"); e_dbg("NVM Read Error\n");
goto out; return ret_val;
} }
/* /*
...@@ -499,25 +498,23 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, ...@@ -499,25 +498,23 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
pba_num[offset] += 'A' - 0xA; pba_num[offset] += 'A' - 0xA;
} }
goto out; return 0;
} }
ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length); ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length);
if (ret_val) { if (ret_val) {
e_dbg("NVM Read Error\n"); e_dbg("NVM Read Error\n");
goto out; return ret_val;
} }
if (length == 0xFFFF || length == 0) { if (length == 0xFFFF || length == 0) {
e_dbg("NVM PBA number section invalid length\n"); e_dbg("NVM PBA number section invalid length\n");
ret_val = E1000_ERR_NVM_PBA_SECTION; return -E1000_ERR_NVM_PBA_SECTION;
goto out;
} }
/* check if pba_num buffer is big enough */ /* check if pba_num buffer is big enough */
if (pba_num_size < (((u32)length * 2) - 1)) { if (pba_num_size < (((u32)length * 2) - 1)) {
e_dbg("PBA string buffer too small\n"); e_dbg("PBA string buffer too small\n");
ret_val = E1000_ERR_NO_SPACE; return -E1000_ERR_NO_SPACE;
goto out;
} }
/* trim pba length from start of string */ /* trim pba length from start of string */
...@@ -528,15 +525,14 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, ...@@ -528,15 +525,14 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data); ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data);
if (ret_val) { if (ret_val) {
e_dbg("NVM Read Error\n"); e_dbg("NVM Read Error\n");
goto out; return ret_val;
} }
pba_num[offset * 2] = (u8)(nvm_data >> 8); pba_num[offset * 2] = (u8)(nvm_data >> 8);
pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF); pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF);
} }
pba_num[offset * 2] = '\0'; pba_num[offset * 2] = '\0';
out: return 0;
return ret_val;
} }
/** /**
......
This diff is collapsed.
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