diff options
author | Harald Welte <laforge@gnumonks.org> | 2014-01-19 17:18:21 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2014-01-19 17:32:59 +0100 |
commit | 1fe241294960e91057d215ff8260f1047e8a7cd0 (patch) | |
tree | 906625aedc0476a93f992f062cb13b2cc64552e6 /openbsc | |
parent | 903aaea6689cc08c0e33fb05659c808a5e5f754f (diff) |
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.
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/include/openbsc/gsm_data_shared.h | 7 | ||||
-rw-r--r-- | openbsc/src/libbsc/abis_nm.c | 5 | ||||
-rw-r--r-- | openbsc/src/libbsc/bsc_vty.c | 3 | ||||
-rw-r--r-- | openbsc/src/libbsc/gsm_04_08_utils.c | 10 |
4 files changed, 11 insertions, 14 deletions
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h index 6eafed8c1..2b405a007 100644 --- a/openbsc/include/openbsc/gsm_data_shared.h +++ b/openbsc/include/openbsc/gsm_data_shared.h @@ -769,6 +769,13 @@ uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); int gsm_parse_reg(void *ctx, regex_t *reg, char **str, int argc, const char **argv) __attribute__ ((warn_unused_result)); +static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts) +{ + if (ts->tsc != -1) + return ts->tsc; + else + return ts->trx->bts->tsc; +} #endif diff --git a/openbsc/src/libbsc/abis_nm.c b/openbsc/src/libbsc/abis_nm.c index 717f56d8d..f491a0c20 100644 --- a/openbsc/src/libbsc/abis_nm.c +++ b/openbsc/src/libbsc/abis_nm.c @@ -1678,10 +1678,7 @@ int abis_nm_set_channel_attr(struct gsm_bts_trx_ts *ts, uint8_t chan_comb) } } } - if (ts->tsc == -1) - msgb_tv_put(msg, NM_ATT_TSC, bts->tsc); /* training sequence */ - else - msgb_tv_put(msg, NM_ATT_TSC, ts->tsc); /* training sequence */ + msgb_tv_put(msg, NM_ATT_TSC, gsm_ts_tsc(ts)); /* training sequence */ if (bts->type == GSM_BTS_TYPE_BS11) msgb_tlv_put(msg, 0x59, 1, &zero); diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index b906c2ee3..00307649a 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -795,8 +795,7 @@ static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts) { vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s, TSC %u", ts->trx->bts->nr, ts->trx->nr, ts->nr, - gsm_pchan_name(ts->pchan), - ts->tsc == -1 ? ts->trx->bts->tsc : ts->tsc); + gsm_pchan_name(ts->pchan), gsm_ts_tsc(ts)); if (ts->pchan == GSM_PCHAN_TCH_F_PDCH) vty_out(vty, " (%s mode)", ts->flags & TS_F_PDCH_MODE ? "PDCH" : "TCH/F"); diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 735997ef1..fe6f2ab71 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -341,21 +341,15 @@ void gsm48_lchan2chan_desc(struct gsm48_chan_desc *cd, 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; |