ddr: altera: Clean up sdr_*_phase() part 4

Get rid of found_{begin,end} variables. Instead of breaking out
through all of the loops, just return when the begin/end of the
window is found and be done with it. Also clean up the trailing
conditional expression, which is now much easier.

Signed-off-by: Marek Vasut <marex@denx.de>
This commit is contained in:
Marek Vasut 2015-07-19 05:01:12 +02:00
parent 36edef3c98
commit 38ed692238
1 changed files with 10 additions and 31 deletions

View File

@ -1337,7 +1337,6 @@ static int sdr_working_phase(uint32_t grp,
uint32_t *v, uint32_t *d, uint32_t *p, uint32_t *v, uint32_t *d, uint32_t *p,
uint32_t *i, uint32_t *max_working_cnt) uint32_t *i, uint32_t *max_working_cnt)
{ {
uint32_t found_begin = 0;
uint32_t tmp_delay = 0; uint32_t tmp_delay = 0;
uint32_t test_status; uint32_t test_status;
u32 bit_chk; u32 bit_chk;
@ -1358,31 +1357,20 @@ static int sdr_working_phase(uint32_t grp,
if (test_status) { if (test_status) {
*max_working_cnt = 1; *max_working_cnt = 1;
found_begin = 1; return 1;
break;
} }
} }
if (found_begin)
break;
if (*p > IO_DQS_EN_PHASE_MAX) if (*p > IO_DQS_EN_PHASE_MAX)
/* fiddle with FIFO */ /* fiddle with FIFO */
rw_mgr_incr_vfifo(grp, v); rw_mgr_incr_vfifo(grp, v);
} }
if (found_begin)
break;
} }
if (*i >= VFIFO_SIZE) { /* Cannot find working solution */
/* cannot find working solution */ debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: no vfifo/\
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: no vfifo/\ ptap/dtap\n", __func__, __LINE__);
ptap/dtap\n", __func__, __LINE__); return 0;
return 0;
} else {
return 1;
}
} }
static void sdr_backup_phase(uint32_t grp, static void sdr_backup_phase(uint32_t grp,
@ -1438,7 +1426,6 @@ static int sdr_nonworking_phase(uint32_t grp,
uint32_t *p, uint32_t *i, uint32_t *max_working_cnt, uint32_t *p, uint32_t *i, uint32_t *max_working_cnt,
uint32_t *work_end) uint32_t *work_end)
{ {
uint32_t found_end = 0;
u32 bit_chk; u32 bit_chk;
(*p)++; (*p)++;
@ -1456,16 +1443,12 @@ static int sdr_nonworking_phase(uint32_t grp,
if (!rw_mgr_mem_calibrate_read_test_all_ranks if (!rw_mgr_mem_calibrate_read_test_all_ranks
(grp, 1, PASS_ONE_BIT, &bit_chk, 0)) { (grp, 1, PASS_ONE_BIT, &bit_chk, 0)) {
found_end = 1; return 1;
break;
} else { } else {
(*max_working_cnt)++; (*max_working_cnt)++;
} }
} }
if (found_end)
break;
if (*p > IO_DQS_EN_PHASE_MAX) { if (*p > IO_DQS_EN_PHASE_MAX) {
/* fiddle with FIFO */ /* fiddle with FIFO */
rw_mgr_incr_vfifo(grp, v); rw_mgr_incr_vfifo(grp, v);
@ -1473,14 +1456,10 @@ static int sdr_nonworking_phase(uint32_t grp,
} }
} }
if (*i >= VFIFO_SIZE + 1) { /* Cannot see edge of failing read. */
/* cannot see edge of failing read */ debug_cond(DLEVEL == 2, "%s:%d sdr_nonworking_phase: end:\
debug_cond(DLEVEL == 2, "%s:%d sdr_nonworking_phase: end:\ failed\n", __func__, __LINE__);
failed\n", __func__, __LINE__); return 0;
return 0;
} else {
return 1;
}
} }
/** /**