e1000: more error checks
[dpdk.git] / lib / librte_pmd_e1000 / e1000 / e1000_ich8lan.c
index f27af88..db26a5c 100644 (file)
@@ -31,8 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
 
 ***************************************************************************/
 
-/*
- * 82562G 10/100 Network Connection
+/* 82562G 10/100 Network Connection
  * 82562G-2 10/100 Network Connection
  * 82562GT 10/100 Network Connection
  * 82562GT-2 10/100 Network Connection
@@ -63,10 +62,6 @@ POSSIBILITY OF SUCH DAMAGE.
 
 #include "e1000_api.h"
 
-STATIC s32  e1000_init_phy_params_ich8lan(struct e1000_hw *hw);
-STATIC s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw);
-STATIC s32  e1000_init_nvm_params_ich8lan(struct e1000_hw *hw);
-STATIC s32  e1000_init_mac_params_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_swflag_ich8lan(struct e1000_hw *hw);
 STATIC void e1000_release_swflag_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_nvm_ich8lan(struct e1000_hw *hw);
@@ -107,8 +102,6 @@ STATIC s32  e1000_led_on_pchlan(struct e1000_hw *hw);
 STATIC s32  e1000_led_off_pchlan(struct e1000_hw *hw);
 STATIC void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
-static s32  e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout);
-static s32  e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw);
 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
 static s32  e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_read_flash_byte_ich8lan(struct e1000_hw *hw,
@@ -119,15 +112,9 @@ STATIC s32  e1000_read_flash_word_ich8lan(struct e1000_hw *hw,
                                          u32 offset, u16 *data);
 static s32  e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
                                                 u32 offset, u8 byte);
-STATIC s32  e1000_write_flash_byte_ich8lan(struct e1000_hw *hw,
-                                          u32 offset, u8 data);
-static s32  e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
-                                          u8 size, u16 data);
 STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
 STATIC void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
 static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw);
-STATIC void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
-STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw);
 STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
 STATIC s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
 STATIC void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
@@ -330,7 +317,7 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
 STATIC s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
 
        DEBUGFUNC("e1000_init_phy_params_pchlan");
 
@@ -371,8 +358,8 @@ STATIC s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
                                break;
                        /* fall-through */
                case e1000_pch2lan:
-                       /*
-                        * In case the PHY needs to be in mdio slow mode,
+               case e1000_pch_lpt:
+                       /* In case the PHY needs to be in mdio slow mode,
                         * set slow mode and try to get the PHY id again.
                         */
                        ret_val = e1000_set_mdio_slow_mode_hv(hw);
@@ -440,8 +427,7 @@ STATIC s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
        phy->ops.power_up       = e1000_power_up_phy_copper;
        phy->ops.power_down     = e1000_power_down_phy_copper_ich8lan;
 
-       /*
-        * We may need to do this twice - once for IGP and if that fails,
+       /* We may need to do this twice - once for IGP and if that fails,
         * we'll set BM func pointers and try again
         */
        ret_val = e1000_determine_phy_address(hw);
@@ -528,8 +514,7 @@ STATIC s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
 
        gfpreg = E1000_READ_FLASH_REG(hw, ICH_FLASH_GFPREG);
 
-       /*
-        * sector_X_addr is a "sector"-aligned address (4096 bytes)
+       /* sector_X_addr is a "sector"-aligned address (4096 bytes)
         * Add 1 to sector_end_addr since this sector is included in
         * the overall size.
         */
@@ -539,12 +524,11 @@ STATIC s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
        /* flash_base_addr is byte-aligned */
        nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
 
-       /*
-        * find total size of the NVM, then cut in half since the total
+       /* find total size of the NVM, then cut in half since the total
         * size represents two separate NVM banks.
         */
-       nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
-                               << FLASH_SECTOR_ADDR_SHIFT;
+       nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
+                               << FLASH_SECTOR_ADDR_SHIFT);
        nvm->flash_bank_size /= 2;
        /* Adjust to word count */
        nvm->flash_bank_size /= sizeof(u16);
@@ -690,7 +674,7 @@ STATIC s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
 STATIC s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
                                         u16 *data, bool read)
 {
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
 
        DEBUGFUNC("__e1000_access_emi_reg_locked");
 
@@ -843,8 +827,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
 
        DEBUGFUNC("e1000_check_for_copper_link_ich8lan");
 
-       /*
-        * We only want to go out to the PHY registers to see if Auto-Neg
+       /* We only want to go out to the PHY registers to see if Auto-Neg
         * has completed and/or if our link status has changed.  The
         * get_link_status flag is set upon receiving a Link Status
         * Change or Rx Sequence Error interrupt.
@@ -888,8 +871,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
                                return ret_val;
                }
 
-               /*
-                * Workaround for PCHx parts in half-duplex:
+               /* Workaround for PCHx parts in half-duplex:
                 * Set the number of preambles removed from the packet
                 * when it is passed from the PHY to the MAC to prevent
                 * the MAC from misinterpreting the packet type.
@@ -907,8 +889,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
                break;
        }
 
-       /*
-        * Check if there was DownShift, must be checked
+       /* Check if there was DownShift, must be checked
         * immediately after link-up
         */
        e1000_check_downshift_generic(hw);
@@ -918,22 +899,19 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
        if (ret_val)
                return ret_val;
 
-       /*
-        * If we are forcing speed/duplex, then we simply return since
+       /* If we are forcing speed/duplex, then we simply return since
         * we have already determined whether we have link or not.
         */
        if (!mac->autoneg)
                return -E1000_ERR_CONFIG;
 
-       /*
-        * Auto-Neg is enabled.  Auto Speed Detection takes care
+       /* Auto-Neg is enabled.  Auto Speed Detection takes care
         * of MAC speed/duplex configuration.  So we only need to
         * configure Collision Distance in the MAC.
         */
        mac->ops.config_collision_dist(hw);
 
-       /*
-        * Configure Flow Control now that Auto-Neg has completed.
+       /* Configure Flow Control now that Auto-Neg has completed.
         * First, we need to restore the desired flow control
         * settings because we may have had to re-autoneg with a
         * different link partner.
@@ -1106,9 +1084,9 @@ STATIC bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
 
        fwsm = E1000_READ_REG(hw, E1000_FWSM);
 
-       return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
-              ((fwsm & E1000_FWSM_MODE_MASK) ==
-               (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
+       return ((fwsm & E1000_ICH_FWSM_FW_VALID) &&
+               ((fwsm & E1000_FWSM_MODE_MASK) ==
+                (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT)));
 }
 
 /**
@@ -1148,8 +1126,7 @@ STATIC void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
 
        DEBUGFUNC("e1000_rar_set_pch2lan");
 
-       /*
-        * HW expects these in little endian so we reverse the byte order
+       /* HW expects these in little endian so we reverse the byte order
         * from network order (big endian) to little endian
         */
        rar_low = ((u32) addr[0] |
@@ -1230,7 +1207,7 @@ STATIC s32 e1000_write_smbus_addr(struct e1000_hw *hw)
        u32 strap = E1000_READ_REG(hw, E1000_STRAP);
        u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
                E1000_STRAP_SMT_FREQ_SHIFT;
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
 
        strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
 
@@ -1274,8 +1251,7 @@ STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
 
        DEBUGFUNC("e1000_sw_lcd_config_ich8lan");
 
-       /*
-        * Initialize the PHY from the NVM on ICH platforms.  This
+       /* Initialize the PHY from the NVM on ICH platforms.  This
         * is needed due to an issue where the NVM configuration is
         * not properly autoloaded after power transitions.
         * Therefore, after each PHY reset, we will load the
@@ -1308,8 +1284,7 @@ STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
        if (!(data & sw_cfg_mask))
                goto release;
 
-       /*
-        * Make sure HW does not configure LCD from PHY
+       /* Make sure HW does not configure LCD from PHY
         * extended configuration before SW configuration
         */
        data = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
@@ -1329,8 +1304,7 @@ STATIC s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
        if (((hw->mac.type == e1000_pchlan) &&
             !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
            (hw->mac.type > e1000_pchlan)) {
-               /*
-                * HW configures the SMBus address and LEDs when the
+               /* HW configures the SMBus address and LEDs when the
                 * OEM and LCD Write Enable bits are set in the NVM.
                 * When both NVM bits are cleared, SW will configure
                 * them instead.
@@ -1416,9 +1390,9 @@ STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
                        if (ret_val)
                                goto release;
 
-                       status_reg &= BM_CS_STATUS_LINK_UP |
-                                     BM_CS_STATUS_RESOLVED |
-                                     BM_CS_STATUS_SPEED_MASK;
+                       status_reg &= (BM_CS_STATUS_LINK_UP |
+                                      BM_CS_STATUS_RESOLVED |
+                                      BM_CS_STATUS_SPEED_MASK);
 
                        if (status_reg == (BM_CS_STATUS_LINK_UP |
                                           BM_CS_STATUS_RESOLVED |
@@ -1432,9 +1406,9 @@ STATIC s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
                        if (ret_val)
                                goto release;
 
-                       status_reg &= HV_M_STATUS_LINK_UP |
-                                     HV_M_STATUS_AUTONEG_COMPLETE |
-                                     HV_M_STATUS_SPEED_MASK;
+                       status_reg &= (HV_M_STATUS_LINK_UP |
+                                      HV_M_STATUS_AUTONEG_COMPLETE |
+                                      HV_M_STATUS_SPEED_MASK);
 
                        if (status_reg == (HV_M_STATUS_LINK_UP |
                                           HV_M_STATUS_AUTONEG_COMPLETE |
@@ -1476,7 +1450,7 @@ release:
  **/
 s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
 {
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
        u32 ctrl_reg = 0;
        u32 ctrl_ext = 0;
        u32 reg = 0;
@@ -1649,8 +1623,7 @@ STATIC s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
        }
 
        if (hw->phy.type == e1000_phy_82578) {
-               /*
-                * Return registers to default by doing a soft reset then
+               /* Return registers to default by doing a soft reset then
                 * writing 0x3140 to the control register.
                 */
                if (hw->phy.revision < 2) {
@@ -1671,8 +1644,7 @@ STATIC s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
        if (ret_val)
                return ret_val;
 
-       /*
-        * Configure the K1 Si workaround during phy reset assuming there is
+       /* Configure the K1 Si workaround during phy reset assuming there is
         * link so that it disables K1 if link is in 1Gbps.
         */
        ret_val = e1000_k1_gig_workaround_hv(hw, true);
@@ -1784,8 +1756,7 @@ s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
                return ret_val;
 
        if (enable) {
-               /*
-                * Write Rx addresses (rar_entry_count for RAL/H, +4 for
+               /* Write Rx addresses (rar_entry_count for RAL/H, and
                 * SHRAL/H) and initial CRC values to the MAC
                 */
                for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
@@ -2072,8 +2043,7 @@ STATIC void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
                usec_delay(100);
        } while ((!data) && --loop);
 
-       /*
-        * If basic configuration is incomplete before the above loop
+       /* If basic configuration is incomplete before the above loop
         * count reaches 0, loading the configuration from NVM will
         * leave the PHY in a bad state possibly resulting in no link.
         */
@@ -2194,7 +2164,7 @@ STATIC s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
  **/
 STATIC s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
 {
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
        u16 oem_reg;
 
        DEBUGFUNC("e1000_set_lplu_state_pchlan");
@@ -2248,8 +2218,7 @@ STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
                if (phy->type != e1000_phy_igp_3)
                        return E1000_SUCCESS;
 
-               /*
-                * Call gig speed drop workaround on LPLU before accessing
+               /* Call gig speed drop workaround on LPLU before accessing
                 * any PHY registers
                 */
                if (hw->mac.type == e1000_ich8lan)
@@ -2272,8 +2241,7 @@ STATIC s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
                if (phy->type != e1000_phy_igp_3)
                        return E1000_SUCCESS;
 
-               /*
-                * LPLU and SmartSpeed are mutually exclusive.  LPLU is used
+               /* LPLU and SmartSpeed are mutually exclusive.  LPLU is used
                 * during Dx states where the power conservation is most
                 * important.  During driver activity we should enable
                 * SmartSpeed, so performance is maintained.
@@ -2341,8 +2309,7 @@ STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
                if (phy->type != e1000_phy_igp_3)
                        return E1000_SUCCESS;
 
-               /*
-                * LPLU and SmartSpeed are mutually exclusive.  LPLU is used
+               /* LPLU and SmartSpeed are mutually exclusive.  LPLU is used
                 * during Dx states where the power conservation is most
                 * important.  During driver activity we should enable
                 * SmartSpeed, so performance is maintained.
@@ -2383,8 +2350,7 @@ STATIC s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
                if (phy->type != e1000_phy_igp_3)
                        return E1000_SUCCESS;
 
-               /*
-                * Call gig speed drop workaround on LPLU before accessing
+               /* Call gig speed drop workaround on LPLU before accessing
                 * any PHY registers
                 */
                if (hw->mac.type == e1000_ich8lan)
@@ -2562,8 +2528,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
 
        E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
 
-       /*
-        * Either we should have a hardware SPI cycle in progress
+       /* Either we should have a hardware SPI cycle in progress
         * bit to check against, in order to start a new cycle or
         * FDONE bit should be changed in the hardware so that it
         * is 1 after hardware reset, which can then be used as an
@@ -2572,8 +2537,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
         */
 
        if (!hsfsts.hsf_status.flcinprog) {
-               /*
-                * There is no cycle running at present,
+               /* There is no cycle running at present,
                 * so we can start a cycle.
                 * Begin by setting Flash Cycle Done.
                 */
@@ -2583,8 +2547,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
        } else {
                s32 i;
 
-               /*
-                * Otherwise poll for sometime so the current
+               /* Otherwise poll for sometime so the current
                 * cycle has a chance to end before giving up.
                 */
                for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
@@ -2597,8 +2560,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
                        usec_delay(1);
                }
                if (ret_val == E1000_SUCCESS) {
-                       /*
-                        * Successful in waiting for previous cycle to timeout,
+                       /* Successful in waiting for previous cycle to timeout,
                         * now set the Flash Cycle Done.
                         */
                        hsfsts.hsf_status.flcdone = 1;
@@ -2713,11 +2675,11 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
 
        DEBUGFUNC("e1000_read_flash_data_ich8lan");
 
-       if (size < 1  || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
+       if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
                return -E1000_ERR_NVM;
 
-       flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
-                           hw->nvm.flash_base_addr;
+       flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
+                            hw->nvm.flash_base_addr);
 
        do {
                usec_delay(1);
@@ -2734,11 +2696,11 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
 
                E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr);
 
-               ret_val = e1000_flash_cycle_ich8lan(hw,
-                                               ICH_FLASH_READ_COMMAND_TIMEOUT);
+               ret_val =
+                   e1000_flash_cycle_ich8lan(hw,
+                                             ICH_FLASH_READ_COMMAND_TIMEOUT);
 
-               /*
-                * Check if FCERR is set to 1, if set to 1, clear it
+               /* Check if FCERR is set to 1, if set to 1, clear it
                 * and try the whole sequence a few more times, else
                 * read in (shift in) the Flash Data0, the order is
                 * least significant byte first msb to lsb
@@ -2751,8 +2713,7 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
                                *data = (u16)(flash_data & 0x0000FFFF);
                        break;
                } else {
-                       /*
-                        * If we've gotten here, then things are probably
+                       /* If we've gotten here, then things are probably
                         * completely hosed, but if the error condition is
                         * detected, it won't hurt to give it another try...
                         * ICH_FLASH_CYCLE_REPEAT_COUNT times.
@@ -2838,8 +2799,7 @@ STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
 
        nvm->ops.acquire(hw);
 
-       /*
-        * We're writing to the opposite bank so if we're on bank 1,
+       /* We're writing to the opposite bank so if we're on bank 1,
         * write to bank 0 etc.  We also need to erase the segment that
         * is going to be written
         */
@@ -2864,8 +2824,7 @@ STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
        }
 
        for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
-               /*
-                * Determine whether to write the value stored
+               /* Determine whether to write the value stored
                 * in the other NVM bank or a modified value stored
                 * in the shadow RAM
                 */
@@ -2879,8 +2838,7 @@ STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
                                break;
                }
 
-               /*
-                * If the word is 0x13, then make sure the signature bits
+               /* If the word is 0x13, then make sure the signature bits
                 * (15:14) are 11b until the commit has completed.
                 * This will allow us to write 10b which indicates the
                 * signature is valid.  We want to do this after the write
@@ -2909,8 +2867,7 @@ STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
                        break;
        }
 
-       /*
-        * Don't bother writing the segment valid bits if sector
+       /* Don't bother writing the segment valid bits if sector
         * programming failed.
         */
        if (ret_val) {
@@ -2918,8 +2875,7 @@ STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
                goto release;
        }
 
-       /*
-        * Finally validate the new segment by setting bit 15:14
+       /* Finally validate the new segment by setting bit 15:14
         * to 10b in word 0x13 , this can be done without an
         * erase as well since these bits are 11 to start with
         * and we need to change bit 14 to 0b
@@ -2936,8 +2892,7 @@ STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
        if (ret_val)
                goto release;
 
-       /*
-        * And invalidate the previously valid segment by setting
+       /* And invalidate the previously valid segment by setting
         * its signature word (0x13) high_byte to 0b. This can be
         * done without an erase because flash erase sets all bits
         * to 1's. We can write 1's to 0's without an erase
@@ -2956,8 +2911,7 @@ STATIC s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
 release:
        nvm->ops.release(hw);
 
-       /*
-        * Reload the EEPROM, or else modifications will not appear
+       /* Reload the EEPROM, or else modifications will not appear
         * until after the next adapter reset.
         */
        if (!ret_val) {
@@ -2989,8 +2943,7 @@ STATIC s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
 
        DEBUGFUNC("e1000_validate_nvm_checksum_ich8lan");
 
-       /*
-        * Read NVM and check Invalid Image CSUM bit.  If this bit is 0,
+       /* Read NVM and check Invalid Image CSUM bit.  If this bit is 0,
         * the checksum needs to be fixed.  This bit is an indication that
         * the NVM was prepared by OEM software and did not calculate
         * the checksum...a likely scenario.
@@ -3044,8 +2997,8 @@ static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
            offset > ICH_FLASH_LINEAR_ADDR_MASK)
                return -E1000_ERR_NVM;
 
-       flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
-                           hw->nvm.flash_base_addr;
+       flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
+                            hw->nvm.flash_base_addr);
 
        do {
                usec_delay(1);
@@ -3069,17 +3022,16 @@ static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
 
                E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
 
-               /*
-                * check if FCERR is set to 1 , if set to 1, clear it
+               /* check if FCERR is set to 1 , if set to 1, clear it
                 * and try the whole sequence a few more times else done
                 */
-               ret_val = e1000_flash_cycle_ich8lan(hw,
-                                              ICH_FLASH_WRITE_COMMAND_TIMEOUT);
+               ret_val =
+                   e1000_flash_cycle_ich8lan(hw,
+                                             ICH_FLASH_WRITE_COMMAND_TIMEOUT);
                if (ret_val == E1000_SUCCESS)
                        break;
 
-               /*
-                * If we're here, then things are most likely
+               /* If we're here, then things are most likely
                 * completely hosed, but if the error condition
                 * is detected, it won't hurt to give it another
                 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
@@ -3173,8 +3125,7 @@ STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
 
        hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
 
-       /*
-        * Determine HW Sector size: Read BERASE bits of hw flash status
+       /* Determine HW Sector size: Read BERASE bits of hw flash status
         * register
         * 00: The Hw sector is 256 bytes, hence we need to erase 16
         *     consecutive sectors.  The start index for the nth Hw sector
@@ -3212,15 +3163,16 @@ STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
        flash_linear_addr = hw->nvm.flash_base_addr;
        flash_linear_addr += (bank) ? flash_bank_size : 0;
 
-       for (j = 0; j < iteration ; j++) {
+       for (j = 0; j < iteration; j++) {
                do {
+                       u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
+
                        /* Steps */
                        ret_val = e1000_flash_cycle_init_ich8lan(hw);
                        if (ret_val)
                                return ret_val;
 
-                       /*
-                        * Write a value 11 (block Erase) in Flash
+                       /* Write a value 11 (block Erase) in Flash
                         * Cycle field in hw flash control
                         */
                        hsflctl.regval = E1000_READ_FLASH_REG16(hw,
@@ -3229,8 +3181,7 @@ STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
                        E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL,
                                                hsflctl.regval);
 
-                       /*
-                        * Write the last 24 bits of an index within the
+                       /* Write the last 24 bits of an index within the
                         * block into Flash Linear address field in Flash
                         * Address.
                         */
@@ -3238,13 +3189,11 @@ STATIC s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
                        E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR,
                                              flash_linear_addr);
 
-                       ret_val = e1000_flash_cycle_ich8lan(hw,
-                                              ICH_FLASH_ERASE_COMMAND_TIMEOUT);
+                       ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
                        if (ret_val == E1000_SUCCESS)
                                break;
 
-                       /*
-                        * Check if FCERR is set to 1.  If 1,
+                       /* Check if FCERR is set to 1.  If 1,
                         * clear it and try the whole sequence
                         * a few more times else Done
                         */
@@ -3378,8 +3327,7 @@ STATIC s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
 
        ret_val = e1000_get_bus_info_pcie_generic(hw);
 
-       /*
-        * ICH devices are "PCI Express"-ish.  They have
+       /* ICH devices are "PCI Express"-ish.  They have
         * a configuration space, but do not contain
         * PCI Express Capability registers, so bus width
         * must be hardcoded.
@@ -3406,8 +3354,7 @@ STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
 
        DEBUGFUNC("e1000_reset_hw_ich8lan");
 
-       /*
-        * Prevent the PCI-E bus from sticking if there is no TLP connection
+       /* Prevent the PCI-E bus from sticking if there is no TLP connection
         * on the last TLP read/write transaction when MAC is reset.
         */
        ret_val = e1000_disable_pcie_master_generic(hw);
@@ -3417,8 +3364,7 @@ STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
        DEBUGOUT("Masking off all interrupts\n");
        E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
 
-       /*
-        * Disable the Transmit and Receive units.  Then delay to allow
+       /* Disable the Transmit and Receive units.  Then delay to allow
         * any pending transactions to complete before we hit the MAC
         * with the global reset.
         */
@@ -3451,15 +3397,13 @@ STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
        ctrl = E1000_READ_REG(hw, E1000_CTRL);
 
        if (!hw->phy.ops.check_reset_block(hw)) {
-               /*
-                * Full-chip reset requires MAC and PHY reset at the same
+               /* Full-chip reset requires MAC and PHY reset at the same
                 * time to make sure the interface between MAC and the
                 * external PHY is reset.
                 */
                ctrl |= E1000_CTRL_PHY_RST;
 
-               /*
-                * Gate automatic PHY configuration by hardware on
+               /* Gate automatic PHY configuration by hardware on
                 * non-managed 82579
                 */
                if ((hw->mac.type == e1000_pch2lan) &&
@@ -3493,8 +3437,7 @@ STATIC s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
                        return ret_val;
        }
 
-       /*
-        * For PCH, this write will make sure that any noise
+       /* For PCH, this write will make sure that any noise
         * will be detected as a CRC error and be dropped rather than show up
         * as a bad packet to the DMA engine.
         */
@@ -3536,9 +3479,9 @@ STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
 
        /* Initialize identification LED */
        ret_val = mac->ops.id_led_init(hw);
+       /* An error is not fatal and we should not stop init due to this */
        if (ret_val)
                DEBUGOUT("Error initializing identification LED\n");
-               /* This is not fatal and we should not stop init due to this */
 
        /* Setup the receive address. */
        e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
@@ -3548,8 +3491,7 @@ STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
        for (i = 0; i < mac->mta_reg_count; i++)
                E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
 
-       /*
-        * The 82578 Rx buffer will stall if wakeup is enabled in host and
+       /* The 82578 Rx buffer will stall if wakeup is enabled in host and
         * the ME.  Disable wakeup by clearing the host wakeup bit.
         * Reset the phy after disabling host wakeup to reset the Rx buffer.
         */
@@ -3567,20 +3509,19 @@ STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
 
        /* Set the transmit descriptor write-back policy for both queues */
        txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
-       txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
-                E1000_TXDCTL_FULL_TX_DESC_WB;
-       txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
-                E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
+       txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
+                 E1000_TXDCTL_FULL_TX_DESC_WB);
+       txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
+                 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
        E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
        txdctl = E1000_READ_REG(hw, E1000_TXDCTL(1));
-       txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
-                E1000_TXDCTL_FULL_TX_DESC_WB;
-       txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
-                E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
+       txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
+                 E1000_TXDCTL_FULL_TX_DESC_WB);
+       txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
+                 E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
        E1000_WRITE_REG(hw, E1000_TXDCTL(1), txdctl);
 
-       /*
-        * ICH8 has opposite polarity of no_snoop bits.
+       /* ICH8 has opposite polarity of no_snoop bits.
         * By default, we should use snoop behavior.
         */
        if (mac->type == e1000_ich8lan)
@@ -3593,8 +3534,7 @@ STATIC s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
        ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
        E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
 
-       /*
-        * Clear all of the statistics registers (clear on read).  It is
+       /* Clear all of the statistics registers (clear on read).  It is
         * important that we do this after we have tried to establish link
         * because the symbol error count will increment wildly if there
         * is no link.
@@ -3658,14 +3598,13 @@ static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
                E1000_WRITE_REG(hw, E1000_STATUS, reg);
        }
 
-       /*
-        * work-around descriptor data corruption issue during nfs v2 udp
+       /* work-around descriptor data corruption issue during nfs v2 udp
         * traffic, just disable the nfs filtering capability
         */
        reg = E1000_READ_REG(hw, E1000_RFCTL);
        reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
-       /*
-        * Disable IPv6 extension header parsing because some malformed
+
+       /* Disable IPv6 extension header parsing because some malformed
         * IPv6 headers can hang the Rx.
         */
        if (hw->mac.type == e1000_ich8lan)
@@ -3694,16 +3633,14 @@ STATIC s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
        if (hw->phy.ops.check_reset_block(hw))
                return E1000_SUCCESS;
 
-       /*
-        * ICH parts do not have a word in the NVM to determine
+       /* ICH parts do not have a word in the NVM to determine
         * the default flow control setting, so we explicitly
         * set it to full.
         */
        if (hw->fc.requested_mode == e1000_fc_default)
                hw->fc.requested_mode = e1000_fc_full;
 
-       /*
-        * Save off the requested flow control mode for use later.  Depending
+       /* Save off the requested flow control mode for use later.  Depending
         * on the link partner's capabilities, we may or may not use this mode.
         */
        hw->fc.current_mode = hw->fc.requested_mode;
@@ -3754,8 +3691,7 @@ STATIC s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
        ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
        E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 
-       /*
-        * Set the mac to wait the maximum time between each iteration
+       /* Set the mac to wait the maximum time between each iteration
         * and increase the max iterations when polling the phy;
         * this fixes erroneous timeouts at 10Mbps.
         */
@@ -3884,8 +3820,7 @@ static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
        if (!dev_spec->kmrn_lock_loss_workaround_enabled)
                return E1000_SUCCESS;
 
-       /*
-        * Make sure link is up before proceeding.  If not just return.
+       /* Make sure link is up before proceeding.  If not just return.
         * Attempting this while link is negotiating fouled up link
         * stability
         */
@@ -3917,8 +3852,7 @@ static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
                     E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
        E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl);
 
-       /*
-        * Call gig speed drop workaround on Gig disable before accessing
+       /* Call gig speed drop workaround on Gig disable before accessing
         * any PHY registers
         */
        e1000_gig_downshift_workaround_ich8lan(hw);
@@ -3981,8 +3915,7 @@ void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
                        E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
                E1000_WRITE_REG(hw, E1000_PHY_CTRL, reg);
 
-               /*
-                * Call gig speed drop workaround on Gig disable before
+               /* Call gig speed drop workaround on Gig disable before
                 * accessing any PHY registers
                 */
                if (hw->mac.type == e1000_ich8lan)
@@ -4068,6 +4001,7 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
 
        phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL);
        phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
+
        if (hw->phy.type == e1000_phy_i217) {
                u16 phy_reg;
 
@@ -4085,8 +4019,7 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
                        if (ret_val)
                                goto release;
 
-                       /*
-                        * Disable LPLU if both link partners support 100BaseT
+                       /* Disable LPLU if both link partners support 100BaseT
                         * EEE and 100Full is advertised on both ends of the
                         * link.
                         */
@@ -4098,8 +4031,7 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
                                              E1000_PHY_CTRL_NOND0A_LPLU);
                }
 
-               /*
-                * For i217 Intel Rapid Start Technology support,
+               /* For i217 Intel Rapid Start Technology support,
                 * when the system is going into Sx and no manageability engine
                 * is present, the driver must configure proxy to reset only on
                 * power good.  LPI (Low Power Idle) state must also reset only
@@ -4108,7 +4040,6 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
                 */
                if (!(E1000_READ_REG(hw, E1000_FWSM) &
                        E1000_ICH_FWSM_FW_VALID)) {
-
                        /* Enable proxy to reset only on power good. */
                        hw->phy.ops.read_reg_locked(hw, I217_PROXY_CTRL,
                                                    &phy_reg);
@@ -4116,8 +4047,7 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
                        hw->phy.ops.write_reg_locked(hw, I217_PROXY_CTRL,
                                                     phy_reg);
 
-                       /*
-                        * Set bit enable LPI (EEE) to reset only on
+                       /* Set bit enable LPI (EEE) to reset only on
                         * power good.
                        */
                        hw->phy.ops.read_reg_locked(hw, I217_SxCTRL, &phy_reg);
@@ -4130,8 +4060,7 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
                        hw->phy.ops.write_reg_locked(hw, I217_MEMPWR, phy_reg);
                }
 
-               /*
-                * Enable MTA to reset for Intel Rapid Start Technology
+               /* Enable MTA to reset for Intel Rapid Start Technology
                 * Support
                 */
                hw->phy.ops.read_reg_locked(hw, I217_CGFREG, &phy_reg);
@@ -4189,8 +4118,7 @@ void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
                return;
        }
 
-       /*
-        * For i217 Intel Rapid Start Technology support when the system
+       /* For i217 Intel Rapid Start Technology support when the system
         * is transitioning from Sx and no manageability engine is present
         * configure SMBus to restore on reset, disable proxy, and enable
         * the reset on MTA (Multicast table array).
@@ -4206,8 +4134,7 @@ void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
 
                if (!(E1000_READ_REG(hw, E1000_FWSM) &
                    E1000_ICH_FWSM_FW_VALID)) {
-                       /*
-                        * Restore clear on SMB if no manageability engine
+                       /* Restore clear on SMB if no manageability engine
                         * is present
                         */
                        ret_val = hw->phy.ops.read_reg_locked(hw, I217_MEMPWR,
@@ -4329,8 +4256,7 @@ STATIC s32 e1000_led_on_pchlan(struct e1000_hw *hw)
 
        DEBUGFUNC("e1000_led_on_pchlan");
 
-       /*
-        * If no link, then turn LED on by setting the invert bit
+       /* If no link, then turn LED on by setting the invert bit
         * for each LED that's mode is "link_up" in ledctl_mode2.
         */
        if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
@@ -4362,8 +4288,7 @@ STATIC s32 e1000_led_off_pchlan(struct e1000_hw *hw)
 
        DEBUGFUNC("e1000_led_off_pchlan");
 
-       /*
-        * If no link, then turn LED off by clearing the invert bit
+       /* If no link, then turn LED off by clearing the invert bit
         * for each LED that's mode is "link_up" in ledctl_mode1.
         */
        if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
@@ -4410,8 +4335,7 @@ STATIC s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
        } else {
                ret_val = e1000_get_auto_rd_done_generic(hw);
                if (ret_val) {
-                       /*
-                        * When auto config read does not complete, do not
+                       /* When auto config read does not complete, do not
                         * return with an error. This can happen in situations
                         * where there is no eeprom and prevents getting link.
                         */