git: dc11ba4eb3fe - main - ixgbe: move increments after evaluations

Kevin Bowling kbowling at FreeBSD.org
Tue Sep 7 04:46:18 UTC 2021


The branch main has been updated by kbowling (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=dc11ba4eb3fe5cce615f361de83e85e07005ca24

commit dc11ba4eb3fe5cce615f361de83e85e07005ca24
Author:     Guinan Sun <guinanx.sun at intel.com>
AuthorDate: 2020-07-09 08:00:35 +0000
Commit:     Kevin Bowling <kbowling at FreeBSD.org>
CommitDate: 2021-09-07 04:17:18 +0000

    ixgbe: move increments after evaluations
    
    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 at intel.com>
    Signed-off-by: Guinan Sun <guinanx.sun at intel.com>
    Reviewed-by: Wei Zhao <wei.zhao1 at intel.com>
    
    Approved by:    imp
    Obtained from:  DPDK (390445ec30b4c52a3d2887c3d2a202d9cf37ea8e)
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D31621
---
 sys/dev/ixgbe/ixgbe_phy.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/sys/dev/ixgbe/ixgbe_phy.c b/sys/dev/ixgbe/ixgbe_phy.c
index 236d6685f8a9..c1cbc282c790 100644
--- a/sys/dev/ixgbe/ixgbe_phy.c
+++ b/sys/dev/ixgbe/ixgbe_phy.c
@@ -169,12 +169,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;
 }
@@ -234,12 +234,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;
 }
@@ -2066,13 +2066,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;
 }
@@ -2170,12 +2169,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);


More information about the dev-commits-src-main mailing list