[U-Boot] [PATCH 095/172] ddr: altera: Internal mem_calibrate() cleanup part 5

Marek Vasut marex at denx.de
Mon Jul 27 22:50:58 CEST 2015


This is kind of microseries-within-series indent cleanup.
Rework the code for the the middle-loop of the mega-loop
this time and deal with the group_failed variable. Instead
of checking if the group failed in the previous calibration
part, just jump to the end of the loop if calibration did
fail and increment the counter. This shaves away one more
level of indent while making the code slightly more readable.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex at denx.de>
---
 drivers/ddr/altera/sequencer.c | 98 +++++++++++++++++++++++-------------------
 1 file changed, 53 insertions(+), 45 deletions(-)

diff --git a/drivers/ddr/altera/sequencer.c b/drivers/ddr/altera/sequencer.c
index 5e3fec3..6cc11b9 100644
--- a/drivers/ddr/altera/sequencer.c
+++ b/drivers/ddr/altera/sequencer.c
@@ -3326,7 +3326,8 @@ static uint32_t mem_calibrate(void)
 		for (write_group = 0, write_test_bgn = 0; write_group
 			< RW_MGR_MEM_IF_WRITE_DQS_WIDTH; write_group++,
 			write_test_bgn += RW_MGR_MEM_DQ_PER_WRITE_DQS) {
-			/* Initialized the group failure */
+
+			/* Initialize the group failure */
 			group_failed = 0;
 
 			current_run = run_groups & ((1 <<
@@ -3343,7 +3344,7 @@ static uint32_t mem_calibrate(void)
 
 			for (read_group = write_group * rwdqs_ratio,
 			     read_test_bgn = 0;
-			     read_group < (write_group + 1) * rwdqs_ratio && group_failed == 0;
+			     read_group < (write_group + 1) * rwdqs_ratio;
 			     read_group++,
 			     read_test_bgn += RW_MGR_MEM_DQ_PER_READ_DQS) {
 				if (STATIC_CALIB_STEPS & CALIB_SKIP_VFIFO)
@@ -3354,62 +3355,69 @@ static uint32_t mem_calibrate(void)
 							       read_test_bgn))
 					continue;
 
-				group_failed = 1;
 				if (!(gbl->phy_debug_mode_flags & PHY_DEBUG_SWEEP_ALL_GROUPS))
 					return 0;
+
+				/* The group failed, we're done. */
+				goto grp_failed;
 			}
 
 			/* Calibrate the output side */
-			if (group_failed == 0) {
-				for (rank_bgn = 0, sr = 0;
-				     rank_bgn < RW_MGR_MEM_NUMBER_OF_RANKS;
-				     rank_bgn += NUM_RANKS_PER_SHADOW_REG, sr++) {
-					if (STATIC_CALIB_STEPS & CALIB_SKIP_WRITES)
-						continue;
+			for (rank_bgn = 0, sr = 0;
+			     rank_bgn < RW_MGR_MEM_NUMBER_OF_RANKS;
+			     rank_bgn += NUM_RANKS_PER_SHADOW_REG, sr++) {
+				if (STATIC_CALIB_STEPS & CALIB_SKIP_WRITES)
+					continue;
 
-					/* Not needed in quick mode! */
-					if (STATIC_CALIB_STEPS & CALIB_SKIP_DELAY_SWEEPS)
-						continue;
+				/* Not needed in quick mode! */
+				if (STATIC_CALIB_STEPS & CALIB_SKIP_DELAY_SWEEPS)
+					continue;
 
-					/*
-					 * Determine if this set of ranks
-					 * should be skipped entirely.
-					 */
-					if (param->skip_shadow_regs[sr])
-						continue;
+				/*
+				 * Determine if this set of ranks
+				 * should be skipped entirely.
+				 */
+				if (param->skip_shadow_regs[sr])
+					continue;
 
-					/* Calibrate WRITEs */
-					if (rw_mgr_mem_calibrate_writes(rank_bgn,
-							write_group, write_test_bgn))
-						continue;
+				/* Calibrate WRITEs */
+				if (rw_mgr_mem_calibrate_writes(rank_bgn,
+						write_group, write_test_bgn))
+					continue;
 
-					group_failed = 1;
-					if (!(gbl->phy_debug_mode_flags & PHY_DEBUG_SWEEP_ALL_GROUPS))
-						return 0;
-				}
+				group_failed = 1;
+				if (!(gbl->phy_debug_mode_flags & PHY_DEBUG_SWEEP_ALL_GROUPS))
+					return 0;
 			}
 
-			if (group_failed == 0) {
-				for (read_group = write_group * rwdqs_ratio,
-				     read_test_bgn = 0;
-				     read_group < (write_group + 1) * rwdqs_ratio && group_failed == 0;
-				     read_group++,
-				     read_test_bgn += RW_MGR_MEM_DQ_PER_READ_DQS) {
-					if (STATIC_CALIB_STEPS & CALIB_SKIP_WRITES)
-						continue;
-
-					if (rw_mgr_mem_calibrate_vfifo_end(read_group,
-									read_test_bgn))
-						continue;
-
-					group_failed = 1;
-					if (!(gbl->phy_debug_mode_flags & PHY_DEBUG_SWEEP_ALL_GROUPS))
-						return 0;
-				}
+			/* Some group failed, we're done. */
+			if (group_failed)
+				goto grp_failed;
+
+			for (read_group = write_group * rwdqs_ratio,
+			     read_test_bgn = 0;
+			     read_group < (write_group + 1) * rwdqs_ratio;
+			     read_group++,
+			     read_test_bgn += RW_MGR_MEM_DQ_PER_READ_DQS) {
+				if (STATIC_CALIB_STEPS & CALIB_SKIP_WRITES)
+					continue;
+
+				if (rw_mgr_mem_calibrate_vfifo_end(read_group,
+								read_test_bgn))
+					continue;
+
+				if (!(gbl->phy_debug_mode_flags & PHY_DEBUG_SWEEP_ALL_GROUPS))
+					return 0;
+
+				/* The group failed, we're done. */
+				goto grp_failed;
 			}
 
-			if (group_failed != 0)
-				failing_groups++;
+			/* No group failed, continue as usual. */
+			continue;
+
+grp_failed:		/* A group failed, increment the counter. */
+			failing_groups++;
 		}
 
 		/*
-- 
2.1.4



More information about the U-Boot mailing list