net/e1000/base: fix minor issues and improve code style
authorGuinan Sun <guinanx.sun@intel.com>
Mon, 6 Jul 2020 08:12:03 +0000 (08:12 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Jul 2020 21:38:27 +0000 (23:38 +0200)
Fix typo in piece of code of NVM access for SPT.
And cleans up the remaining instances in the shared code
where it was not adhering to the Linux code standard.
Wrong description was found in the mentioned file, so fix them.
Remove shadowing variable declarations.

Relating to operands in bitwise operations having different sizes.
Unreachable code since *clock_in_i2c_* always return success.
Don't return unused s32 and don't check for constants.

Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Sasha Neftin <sasha.neftin@intel.com>
Signed-off-by: Vitaly Lifshits <vitaly.lifshits@intel.com>
Signed-off-by: Robert Konklewski <robertx.konklewski@intel.com>
Signed-off-by: Doug Dziggel <douglas.a.dziggel@intel.com>
Signed-off-by: Todd Fujinaka <todd.fujinaka@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
drivers/net/e1000/base/e1000_80003es2lan.c
drivers/net/e1000/base/e1000_82575.c
drivers/net/e1000/base/e1000_i210.c
drivers/net/e1000/base/e1000_ich8lan.c
drivers/net/e1000/base/e1000_nvm.c
drivers/net/e1000/base/e1000_phy.c

index bcfda9415b61d49973a049a23884707d804fd23e..b795491c03be02f3838097acf4178907dd20ef9a 100644 (file)
@@ -1210,7 +1210,6 @@ STATIC s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
 /**
  *  e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
  *  @hw: pointer to the HW structure
- *  @duplex: current duplex setting
  *
  *  Configure the KMRN interface by applying last minute quirks for
  *  10/100 operation.
index 750f1cf018717da816f1308a312c29e032edf5fb..410f2db417705814c2b94c64a1317cd86d572751 100644 (file)
@@ -75,10 +75,10 @@ STATIC void e1000_clear_vfta_i350(struct e1000_hw *hw);
 
 STATIC void e1000_i2c_start(struct e1000_hw *hw);
 STATIC void e1000_i2c_stop(struct e1000_hw *hw);
-STATIC s32 e1000_clock_in_i2c_byte(struct e1000_hw *hw, u8 *data);
+STATIC void e1000_clock_in_i2c_byte(struct e1000_hw *hw, u8 *data);
 STATIC s32 e1000_clock_out_i2c_byte(struct e1000_hw *hw, u8 data);
 STATIC s32 e1000_get_i2c_ack(struct e1000_hw *hw);
-STATIC s32 e1000_clock_in_i2c_bit(struct e1000_hw *hw, bool *data);
+STATIC void e1000_clock_in_i2c_bit(struct e1000_hw *hw, bool *data);
 STATIC s32 e1000_clock_out_i2c_bit(struct e1000_hw *hw, bool data);
 STATIC void e1000_raise_i2c_clk(struct e1000_hw *hw, u32 *i2cctl);
 STATIC void e1000_lower_i2c_clk(struct e1000_hw *hw, u32 *i2cctl);
@@ -1084,7 +1084,7 @@ STATIC void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
                ; /* Empty */
 
        swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
-       swfw_sync &= ~mask;
+       swfw_sync &= (u32)~mask;
        E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
 
        e1000_put_hw_semaphore_generic(hw);
@@ -3300,9 +3300,7 @@ s32 e1000_read_i2c_byte_generic(struct e1000_hw *hw, u8 byte_offset,
                if (status != E1000_SUCCESS)
                        goto fail;
 
-               status = e1000_clock_in_i2c_byte(hw, data);
-               if (status != E1000_SUCCESS)
-                       goto fail;
+               e1000_clock_in_i2c_byte(hw, data);
 
                status = e1000_clock_out_i2c_bit(hw, nack);
                if (status != E1000_SUCCESS)
@@ -3466,7 +3464,7 @@ STATIC void e1000_i2c_stop(struct e1000_hw *hw)
  *
  *  Clocks in one byte data via I2C data/clock
  **/
-STATIC s32 e1000_clock_in_i2c_byte(struct e1000_hw *hw, u8 *data)
+STATIC void e1000_clock_in_i2c_byte(struct e1000_hw *hw, u8 *data)
 {
        s32 i;
        bool bit = 0;
@@ -3478,8 +3476,6 @@ STATIC s32 e1000_clock_in_i2c_byte(struct e1000_hw *hw, u8 *data)
                e1000_clock_in_i2c_bit(hw, &bit);
                *data |= bit << i;
        }
-
-       return E1000_SUCCESS;
 }
 
 /**
@@ -3568,7 +3564,7 @@ STATIC s32 e1000_get_i2c_ack(struct e1000_hw *hw)
  *
  *  Clocks in one bit via I2C data/clock
  **/
-STATIC s32 e1000_clock_in_i2c_bit(struct e1000_hw *hw, bool *data)
+STATIC void e1000_clock_in_i2c_bit(struct e1000_hw *hw, bool *data)
 {
        u32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS);
 
@@ -3586,8 +3582,6 @@ STATIC s32 e1000_clock_in_i2c_bit(struct e1000_hw *hw, bool *data)
 
        /* Minimum low period of clock is 4.7 us */
        usec_delay(E1000_I2C_T_LOW);
-
-       return E1000_SUCCESS;
 }
 
 /**
index 5c2fe8a3ebe51d1093f75213ac544b6c1efc2bbf..a6d8e3b3482d750797a656be17c5757ef788a502 100644 (file)
@@ -117,7 +117,7 @@ void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
                ; /* Empty */
 
        swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
-       swfw_sync &= ~mask;
+       swfw_sync &= (u32)~mask;
        E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
 
        e1000_put_hw_semaphore_generic(hw);
@@ -310,7 +310,7 @@ STATIC s32 e1000_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words,
        }
 
        for (i = 0; i < words; i++) {
-               eewr = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
+               eewr = ((offset + i) << E1000_NVM_RW_ADDR_SHIFT) |
                        (data[i] << E1000_NVM_RW_REG_DATA) |
                        E1000_NVM_RW_REG_START;
 
@@ -397,9 +397,9 @@ STATIC s32 e1000_read_invm_i210(struct e1000_hw *hw, u16 offset,
        switch (offset) {
        case NVM_MAC_ADDR:
                ret_val = e1000_read_invm_word_i210(hw, (u8)offset, &data[0]);
-               ret_val |= e1000_read_invm_word_i210(hw, (u8)offset+1,
+               ret_val |= e1000_read_invm_word_i210(hw, (u8)offset + 1,
                                                     &data[1]);
-               ret_val |= e1000_read_invm_word_i210(hw, (u8)offset+2,
+               ret_val |= e1000_read_invm_word_i210(hw, (u8)offset + 2,
                                                     &data[2]);
                if (ret_val != E1000_SUCCESS)
                        DEBUGOUT("MAC Addr not found in iNVM\n");
@@ -776,8 +776,6 @@ void e1000_init_function_pointers_i210(struct e1000_hw *hw)
 {
        e1000_init_function_pointers_82575(hw);
        hw->nvm.ops.init_params = e1000_init_nvm_params_i210;
-
-       return;
 }
 
 /**
index 5241cf698f59e6699aa4761f3800e59a684e49ad..823dda5f5f32ab557083bfe1b0a26e9816cd1033 100644 (file)
@@ -822,7 +822,7 @@ STATIC s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
 /**
  *  __e1000_access_emi_reg_locked - Read/write EMI register
  *  @hw: pointer to the HW structure
- *  @addr: EMI address to program
+ *  @address: EMI address to program
  *  @data: pointer to value to read/write from/to the EMI address
  *  @read: boolean flag to indicate read or write
  *
@@ -1546,8 +1546,6 @@ STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
 
 
                if (hw->mac.type >= e1000_pch_lpt) {
-                       u16 phy_reg;
-
                        hw->phy.ops.read_reg_locked(hw, I217_PLL_CLOCK_GATE_REG,
                                                    &phy_reg);
                        phy_reg &= ~I217_PLL_CLOCK_GATE_MASK;
@@ -2401,7 +2399,7 @@ release:
 /**
  *  e1000_configure_k1_ich8lan - Configure K1 power state
  *  @hw: pointer to the HW structure
- *  @enable: K1 state to configure
+ *  @k1_enable: K1 state to configure
  *
  *  Configure the K1 power state based on the provided parameter.
  *  Assumes semaphore already acquired.
@@ -2549,6 +2547,7 @@ STATIC s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
 /**
  *  e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
  *  done after every PHY reset.
+ *  @hw: pointer to the HW structure
  **/
 STATIC s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
 {
@@ -2875,6 +2874,7 @@ s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
 /**
  *  e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
  *  done after every PHY reset.
+ *  @hw: pointer to the HW structure
  **/
 STATIC s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
 {
@@ -3479,8 +3479,9 @@ STATIC s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
 
        for (i = 0; i < words; i += 2) {
                if (words - i == 1) {
-                       if (dev_spec->shadow_ram[offset+i].modified) {
-                               data[i] = dev_spec->shadow_ram[offset+i].value;
+                       if (dev_spec->shadow_ram[offset + i].modified) {
+                               data[i] =
+                                   dev_spec->shadow_ram[offset + i].value;
                        } else {
                                offset_to_read = act_offset + i -
                                                 ((act_offset + i) % 2);
@@ -3497,8 +3498,8 @@ STATIC s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
                        }
                } else {
                        offset_to_read = act_offset + i;
-                       if (!(dev_spec->shadow_ram[offset+i].modified) ||
-                           !(dev_spec->shadow_ram[offset+i+1].modified)) {
+                       if (!(dev_spec->shadow_ram[offset + i].modified) ||
+                           !(dev_spec->shadow_ram[offset + i + 1].modified)) {
                                ret_val =
                                   e1000_read_flash_dword_ich8lan(hw,
                                                                 offset_to_read,
@@ -3506,15 +3507,16 @@ STATIC s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
                                if (ret_val)
                                        break;
                        }
-                       if (dev_spec->shadow_ram[offset+i].modified)
-                               data[i] = dev_spec->shadow_ram[offset+i].value;
+                       if (dev_spec->shadow_ram[offset + i].modified)
+                               data[i] =
+                                   dev_spec->shadow_ram[offset + i].value;
                        else
-                               data[i] = (u16) (dword & 0xFFFF);
-                       if (dev_spec->shadow_ram[offset+i].modified)
-                               data[i+1] =
-                                  dev_spec->shadow_ram[offset+i+1].value;
+                               data[i] = (u16)(dword & 0xFFFF);
+                       if (dev_spec->shadow_ram[offset + i + 1].modified)
+                               data[i + 1] =
+                                  dev_spec->shadow_ram[offset + i + 1].value;
                        else
-                               data[i+1] = (u16) (dword >> 16 & 0xFFFF);
+                               data[i + 1] = (u16)(dword >> 16 & 0xFFFF);
                }
        }
 
@@ -3568,8 +3570,8 @@ STATIC s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
 
        ret_val = E1000_SUCCESS;
        for (i = 0; i < words; i++) {
-               if (dev_spec->shadow_ram[offset+i].modified) {
-                       data[i] = dev_spec->shadow_ram[offset+i].value;
+               if (dev_spec->shadow_ram[offset + i].modified) {
+                       data[i] = dev_spec->shadow_ram[offset + i].value;
                } else {
                        ret_val = e1000_read_flash_word_ich8lan(hw,
                                                                act_offset + i,
@@ -3974,8 +3976,8 @@ STATIC s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
        nvm->ops.acquire(hw);
 
        for (i = 0; i < words; i++) {
-               dev_spec->shadow_ram[offset+i].modified = true;
-               dev_spec->shadow_ram[offset+i].value = data[i];
+               dev_spec->shadow_ram[offset + i].modified = true;
+               dev_spec->shadow_ram[offset + i].value = data[i];
        }
 
        nvm->ops.release(hw);
index 19a7f77ad04fe00523a0fababfce82c05ff262ab..ca87ec122a3482efa45d2b6b514062920f4bc6f5 100644 (file)
@@ -551,7 +551,7 @@ s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
        }
 
        for (i = 0; i < words; i++) {
-               eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
+               eerd = ((offset + i) << E1000_NVM_RW_ADDR_SHIFT) +
                       E1000_NVM_RW_REG_START;
 
                E1000_WRITE_REG(hw, E1000_EERD, eerd);
index c506d23441c2f9057536e048c6473e48797092b1..4995578f4e2d5375bc272f87157b514e53cba78d 100644 (file)
@@ -597,7 +597,7 @@ s32 e1000_write_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 data)
                                 * lane and update whole word
                                 */
                                data_local = i2ccmd & 0xFF00;
-                               data_local |= data;
+                               data_local |= (u32)data;
                                i2ccmd = ((offset <<
                                        E1000_I2CCMD_REG_ADDR_SHIFT) |
                                        E1000_I2CCMD_OPCODE_WRITE | data_local);
@@ -3071,6 +3071,7 @@ s32 e1000_determine_phy_address(struct e1000_hw *hw)
 /**
  *  e1000_get_phy_addr_for_bm_page - Retrieve PHY page address
  *  @page: page to access
+ *  @reg: register to access
  *
  *  Returns the phy address for the page requested.
  **/
@@ -3508,6 +3509,7 @@ void e1000_power_down_phy_copper(struct e1000_hw *hw)
  *  @offset: register offset to be read
  *  @data: pointer to the read data
  *  @locked: semaphore has already been acquired or not
+ *  @page_set: BM_WUC_PAGE already set and access enabled
  *
  *  Acquires semaphore, if necessary, then reads the PHY register at offset
  *  and stores the retrieved information in data.  Release any acquired
@@ -3618,6 +3620,7 @@ s32 e1000_read_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 *data)
  *  @offset: register offset to write to
  *  @data: data to write at register offset
  *  @locked: semaphore has already been acquired or not
+ *  @page_set: BM_WUC_PAGE already set and access enabled
  *
  *  Acquires semaphore, if necessary, then writes the data to PHY register
  *  at the offset.  Release any acquired semaphores before exiting.