TSC: Add new gsm_ts_tsc() function to resolve TSC of TS
We don't want every caller to check for ts->tsc == -1 and then
using ts->trx->bts->tsc instead. Rather, introduce a new inline
function to retrieve the correct value.
diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c
index 735997e..fe6f2ab 100644
--- a/openbsc/src/libbsc/gsm_04_08_utils.c
+++ b/openbsc/src/libbsc/gsm_04_08_utils.c
@@ -341,21 +341,15 @@
const struct gsm_lchan *lchan)
{
uint16_t arfcn = lchan->ts->trx->arfcn & 0x3ff;
- uint8_t tsc;
-
- if (lchan->ts->tsc == -1)
- tsc = lchan->ts->trx->bts->tsc;
- else
- tsc = lchan->ts->tsc;
cd->chan_nr = gsm_lchan2chan_nr(lchan);
if (!lchan->ts->hopping.enabled) {
- cd->h0.tsc = tsc;
+ cd->h0.tsc = gsm_ts_tsc(lchan->ts);
cd->h0.h = 0;
cd->h0.arfcn_high = arfcn >> 8;
cd->h0.arfcn_low = arfcn & 0xff;
} else {
- cd->h1.tsc = tsc;
+ cd->h1.tsc = gsm_ts_tsc(lchan->ts);
cd->h1.h = 1;
cd->h1.maio_high = lchan->ts->hopping.maio >> 2;
cd->h1.maio_low = lchan->ts->hopping.maio & 0x03;