net/ixgbe/base: move increments after evaluations
authorGuinan Sun <guinanx.sun@intel.com>
Thu, 9 Jul 2020 08:00:35 +0000 (08:00 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:53 +0000 (06:18 +0200)
The retry variable was being incremented before it was evaluated by the
subsequent conditional against the maximum retries to figure out which
message to print.  So we'll move the increment op to the end.

Signed-off-by: Jeb Cramer <jeb.j.cramer@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
drivers/net/ixgbe/base/ixgbe_phy.c

index 13f00ac..823cf16 100644 (file)
@@ -138,12 +138,12 @@ fail:
                ixgbe_i2c_bus_clear(hw);
                if (lock)
                        hw->mac.ops.release_swfw_sync(hw, swfw_mask);
-               retry++;
                if (retry < max_retry)
                        DEBUGOUT("I2C byte read combined error - Retrying.\n");
                else
                        DEBUGOUT("I2C byte read combined error.\n");
-       } while (retry < max_retry);
+               retry++;
+       } while (retry <= max_retry);
 
        return IXGBE_ERR_I2C;
 }
@@ -203,12 +203,12 @@ fail:
                ixgbe_i2c_bus_clear(hw);
                if (lock)
                        hw->mac.ops.release_swfw_sync(hw, swfw_mask);
-               retry++;
                if (retry < max_retry)
                        DEBUGOUT("I2C byte write combined error - Retrying.\n");
                else
                        DEBUGOUT("I2C byte write combined error.\n");
-       } while (retry < max_retry);
+               retry++;
+       } while (retry <= max_retry);
 
        return IXGBE_ERR_I2C;
 }
@@ -2057,13 +2057,12 @@ fail:
                        hw->mac.ops.release_swfw_sync(hw, swfw_mask);
                        msec_delay(100);
                }
-               retry++;
                if (retry < max_retry)
                        DEBUGOUT("I2C byte read error - Retrying.\n");
                else
                        DEBUGOUT("I2C byte read error.\n");
-
-       } while (retry < max_retry);
+               retry++;
+       } while (retry <= max_retry);
 
        return status;
 }
@@ -2161,12 +2160,12 @@ STATIC s32 ixgbe_write_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
 
 fail:
                ixgbe_i2c_bus_clear(hw);
-               retry++;
                if (retry < max_retry)
                        DEBUGOUT("I2C byte write error - Retrying.\n");
                else
                        DEBUGOUT("I2C byte write error.\n");
-       } while (retry < max_retry);
+               retry++;
+       } while (retry <= max_retry);
 
        if (lock)
                hw->mac.ops.release_swfw_sync(hw, swfw_mask);