]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ddr: altera: Internal mem_calibrate() cleanup part 5
authorMarek Vasut <marex@denx.de>
Fri, 17 Jul 2015 00:50:56 +0000 (02:50 +0200)
committerMarek Vasut <marex@denx.de>
Sat, 8 Aug 2015 12:14:16 +0000 (14:14 +0200)
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@denx.de>
drivers/ddr/altera/sequencer.c

index 5e3fec3e998632a15c4cbe0d0acf7448958e4347..6cc11b9b19c5de5e92c3cd493d989ad76df26c7d 100644 (file)
@@ -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++;
                }
 
                /*