diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2020-10-17 14:07:46 +0700 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2020-10-19 15:04:22 +0000 |
commit | 2e28b3859d9606ac950b3680122dc10bd8582f2f (patch) | |
tree | d911aa2fce29f04dddda7aa62f36c268c7d51fdb | |
parent | fc1976e1a0a4d1381a149156b83c6e38d3b0360b (diff) |
scheduler: reduce nesting in trx_sched_set_lchan()
Change-Id: I476dabb059325058a4327bb96430ce6ade199580
-rw-r--r-- | src/common/scheduler.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/src/common/scheduler.c b/src/common/scheduler.c index 9af67c84..3dc4db53 100644 --- a/src/common/scheduler.c +++ b/src/common/scheduler.c @@ -979,36 +979,38 @@ int trx_sched_set_lchan(struct l1sched_trx *l1t, uint8_t chan_nr, uint8_t link_i /* look for all matching chan_nr/link_id */ for (i = 0; i < _TRX_CHAN_MAX; i++) { - struct l1sched_chan_state *chan_state; - chan_state = &l1ts->chan_state[i]; - if (trx_chan_desc[i].chan_nr == (chan_nr & RSL_CHAN_NR_MASK) - && trx_chan_desc[i].link_id == link_id) { - rc = 0; - if (chan_state->active == active) - continue; - LOGP(DL1C, LOGL_NOTICE, "%s %s on trx=%d ts=%d\n", - (active) ? "Activating" : "Deactivating", - trx_chan_desc[i].name, l1t->trx->nr, tn); - /* free burst memory, to cleanly start with burst 0 */ - if (chan_state->dl_bursts) { - talloc_free(chan_state->dl_bursts); - chan_state->dl_bursts = NULL; - } - if (chan_state->ul_bursts) { - talloc_free(chan_state->ul_bursts); - chan_state->ul_bursts = NULL; - } + struct l1sched_chan_state *chan_state = &l1ts->chan_state[i]; - if (active) - memset(chan_state, 0, sizeof(*chan_state)); - else - chan_state->ho_rach_detect = 0; - chan_state->active = active; + if (trx_chan_desc[i].chan_nr != (chan_nr & RSL_CHAN_NR_MASK)) + continue; + if (trx_chan_desc[i].link_id != link_id) + continue; - if (active) { - chan_state->lchan = get_lchan_by_chan_nr(l1t->trx, chan_nr); - OSMO_ASSERT(chan_state->lchan != NULL); - } + rc = 0; + if (chan_state->active == active) + continue; + LOGP(DL1C, LOGL_NOTICE, "%s %s on trx=%d ts=%d\n", + (active) ? "Activating" : "Deactivating", + trx_chan_desc[i].name, l1t->trx->nr, tn); + /* free burst memory, to cleanly start with burst 0 */ + if (chan_state->dl_bursts) { + talloc_free(chan_state->dl_bursts); + chan_state->dl_bursts = NULL; + } + if (chan_state->ul_bursts) { + talloc_free(chan_state->ul_bursts); + chan_state->ul_bursts = NULL; + } + + if (active) + memset(chan_state, 0, sizeof(*chan_state)); + else + chan_state->ho_rach_detect = 0; + chan_state->active = active; + + if (active) { + chan_state->lchan = get_lchan_by_chan_nr(l1t->trx, chan_nr); + OSMO_ASSERT(chan_state->lchan != NULL); } } |