[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
Thu Jul 28 15:53:12 UTC 2016


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

gsm_ts2chan_nr(): use constants instead of magic numbers

Change-Id: I0392d179f98842d75eee586161e0aa014337f9ab
---
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/25/625/1

diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index 8d99ea4..833d6ed 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -555,19 +555,18 @@
 uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan,
 			  uint8_t ts_nr, uint8_t lchan_nr)
 {
-	uint8_t cbits, chan_nr;
+	uint8_t chan_nr;
 
 	switch (pchan) {
 	case GSM_PCHAN_TCH_F:
 	case GSM_PCHAN_PDCH:
 	case GSM_PCHAN_TCH_F_PDCH:
 		OSMO_ASSERT(lchan_nr == 0);
-		cbits = 0x01;
+		chan_nr = RSL_CHAN_Bm_ACCHs;
 		break;
 	case GSM_PCHAN_TCH_H:
 		OSMO_ASSERT(lchan_nr < 2);
-		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:
@@ -581,23 +580,21 @@
 			break;
 		}
 		OSMO_ASSERT(lchan_nr < 4);
-		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:
 		OSMO_ASSERT(lchan_nr < 8);
-		cbits = 0x08;
-		cbits += lchan_nr;
+		chan_nr = RSL_CHAN_SDCCH8_ACCH + (RSL_CHAN_NR_1 * lchan_nr);
 		break;
 	default:
 	case GSM_PCHAN_CCCH:
 		OSMO_ASSERT(lchan_nr == 0);
-		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/625
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0392d179f98842d75eee586161e0aa014337f9ab
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: neels_test_account <neels at hofmeyr.de>



More information about the gerrit-log mailing list