[PATCH] openbsc[master]: gsm_ts2chan_nr(): use constants instead of magic numbers

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Jul 25 15:57:03 UTC 2016


Review at  https://gerrit.osmocom.org/588

gsm_ts2chan_nr(): use constants instead of magic numbers

Change-Id: I14dceab6ac9f0d4ad852259eae643f567d0982f2
---
M openbsc/src/libcommon/gsm_data_shared.c
1 file changed, 7 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/88/588/1

diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index 2fc5690..e84fa7b 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -554,35 +554,32 @@
 /* See Table 10.5.25 of GSM04.08 */
 uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr)
 {
-	uint8_t cbits, chan_nr;
+	uint8_t chan_nr;
 
 	switch (ts->pchan) {
 	case GSM_PCHAN_TCH_F:
 	case GSM_PCHAN_PDCH:
 	case GSM_PCHAN_TCH_F_PDCH:
-		cbits = 0x01;
+		chan_nr = RSL_CHAN_Bm_ACCHs;
 		break;
 	case GSM_PCHAN_TCH_H:
-		cbits = 0x02;
-		cbits += lchan_nr;
+		chan_nr = RSL_CHAN_Lm_ACCHs + (RSL_CHAN_NR_1 * lchan_nr);
 		break;
 	case GSM_PCHAN_CCCH_SDCCH4:
 	case GSM_PCHAN_CCCH_SDCCH4_CBCH:
-		cbits = 0x04;
-		cbits += lchan_nr;
+		chan_nr = RSL_CHAN_SDCCH4_ACCH + (RSL_CHAN_NR_1 * lchan_nr);
 		break;
 	case GSM_PCHAN_SDCCH8_SACCH8C:
 	case GSM_PCHAN_SDCCH8_SACCH8C_CBCH:
-		cbits = 0x08;
-		cbits += lchan_nr;
+		chan_nr = RSL_CHAN_SDCCH8_ACCH + (RSL_CHAN_NR_1 * lchan_nr);
 		break;
 	default:
 	case GSM_PCHAN_CCCH:
-		cbits = 0x10;
+		chan_nr = RSL_CHAN_BCCH;
 		break;
 	}
 
-	chan_nr = (cbits << 3) | (ts->nr & 0x7);
+	chan_nr = (chan_nr & RSL_CHAN_NR_MASK) | (ts->nr & ~RSL_CHAN_NR_MASK);
 
 	return chan_nr;
 }

-- 
To view, visit https://gerrit.osmocom.org/588
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I14dceab6ac9f0d4ad852259eae643f567d0982f2
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list