From 88d0431acc31dba7116b517d4a0bf57da22b34de Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 6 Jun 2016 17:27:41 +0200 Subject: [PATCH] ra: fixed srslte_ra_tbs_from_idx() --- srslte/lib/phch/ra.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/srslte/lib/phch/ra.c b/srslte/lib/phch/ra.c index 5fba532e6..4f373784e 100644 --- a/srslte/lib/phch/ra.c +++ b/srslte/lib/phch/ra.c @@ -592,14 +592,14 @@ int srslte_ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) { int srslte_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) { uint32_t idx; if (n_prb > 0 && n_prb <= SRSLTE_MAX_PRB) { - return SRSLTE_ERROR; - } - if (tbs < tbs_table[0][n_prb]) { - return SRSLTE_ERROR; - } - for (idx = 1; idx < 28; idx++) { - if (tbs_table[idx - 1][n_prb] <= tbs && tbs_table[idx][n_prb] >= tbs) { - return idx; + + if (tbs <= tbs_table[0][n_prb-1]) { + return 0; + } + for (idx = 0; idx < 27; idx++) { + if (tbs_table[idx][n_prb-1] <= tbs && tbs_table[idx+1][n_prb-1] >= tbs) { + return idx+1; + } } } return SRSLTE_ERROR;