[PATCH] osmo-bts[master]: Replace magic number with define

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/.

Max gerrit-no-reply at lists.osmocom.org
Mon Oct 17 14:40:17 UTC 2016


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

Replace magic number with define

SDCCH occupy lchan 0..3 in combined configuration so for CCCH we've
always used lchan[4] - replace it with CCCH_LCHAN define and add
comment.

Change-Id: Ic5d742c292d638f119c6b4672120c1950adeb7f0
---
M include/osmo-bts/gsm_data.h
M src/common/l1sap.c
M src/common/oml.c
M src/osmo-bts-litecell15/oml.c
M src/osmo-bts-octphy/l1_oml.c
M src/osmo-bts-sysmo/oml.c
M src/osmo-bts-trx/l1_if.c
7 files changed, 18 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/98/1098/1

diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index f1c9601..a2bb641 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -8,6 +8,9 @@
 #include <osmo-bts/paging.h>
 #include <osmo-bts/tx_power.h>
 
+/* lchans 0..3 are SDCCH in combined channel configuration: */
+#define CCCH_LCHAN 4
+
 #define GSM_FR_BITS	260
 #define GSM_EFR_BITS	244
 
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 0b9930e..10660ee 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -945,7 +945,7 @@
 
 	DEBUGP(DL1P, "Rx PH-RA.ind");
 
-	lc = &trx->ts[0].lchan[4].lapdm_ch;
+	lc = &trx->ts[0].lchan[CCCH_LCHAN].lapdm_ch;
 
 	/* check for under/overflow / sign */
 	if (!check_acc_delay(rach_ind, btsb, &acc_delay)) {
diff --git a/src/common/oml.c b/src/common/oml.c
index 6c42f10..94e8cb6 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -741,7 +741,7 @@
 		}
 		/* fallthrough */
 	case GSM_PCHAN_CCCH:
-		lchan = &ts->lchan[4];
+		lchan = &ts->lchan[CCCH_LCHAN];
 		lchan->type = GSM_LCHAN_CCCH;
 		break;
 	case GSM_PCHAN_TCH_F:
diff --git a/src/osmo-bts-litecell15/oml.c b/src/osmo-bts-litecell15/oml.c
index 5a5d452..453f53a 100644
--- a/src/osmo-bts-litecell15/oml.c
+++ b/src/osmo-bts-litecell15/oml.c
@@ -285,8 +285,9 @@
 	    mo->obj_inst.ts_nr == 0) {
 		struct gsm_lchan *cbch = gsm_bts_get_cbch(mo->bts);
 		DEBUGP(DL1C, "====> trying to activate lchans of BCCH\n");
-		mo->bts->c0->ts[0].lchan[4].rel_act_kind = LCHAN_REL_ACT_OML;
-		lchan_activate(&mo->bts->c0->ts[0].lchan[4]);
+		mo->bts->c0->ts[0].lchan[CCCH_LCHAN].rel_act_kind =
+			LCHAN_REL_ACT_OML;
+		lchan_activate(&mo->bts->c0->ts[0].lchan[CCCH_LCHAN]);
 		if (cbch) {
 			cbch->rel_act_kind = LCHAN_REL_ACT_OML;
 			lchan_activate(cbch);
diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c
index e7626e8..de29345 100644
--- a/src/osmo-bts-octphy/l1_oml.c
+++ b/src/osmo-bts-octphy/l1_oml.c
@@ -183,8 +183,9 @@
 	if (mo->obj_class == NM_OC_CHANNEL && mo->obj_inst.trx_nr == 0 &&
 	    mo->obj_inst.ts_nr == 0) {
 		struct gsm_lchan *cbch = gsm_bts_get_cbch(mo->bts);
-		mo->bts->c0->ts[0].lchan[4].rel_act_kind = LCHAN_REL_ACT_OML;
-		lchan_activate(&mo->bts->c0->ts[0].lchan[4]);
+		mo->bts->c0->ts[0].lchan[CCCH_LCHAN].rel_act_kind =
+			LCHAN_REL_ACT_OML;
+		lchan_activate(&mo->bts->c0->ts[0].lchan[CCCH_LCHAN]);
 		if (cbch) {
 			cbch->rel_act_kind = LCHAN_REL_ACT_OML;
 			lchan_activate(cbch);
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index 7a07ad1..fd03e22 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -284,8 +284,9 @@
 	    mo->obj_inst.ts_nr == 0) {
 		struct gsm_lchan *cbch = gsm_bts_get_cbch(mo->bts);
 		DEBUGP(DL1C, "====> trying to activate lchans of BCCH\n");
-		mo->bts->c0->ts[0].lchan[4].rel_act_kind = LCHAN_REL_ACT_OML;
-		lchan_activate(&mo->bts->c0->ts[0].lchan[4]);
+		mo->bts->c0->ts[0].lchan[CCCH_LCHAN].rel_act_kind =
+			LCHAN_REL_ACT_OML;
+		lchan_activate(&mo->bts->c0->ts[0].lchan[CCCH_LCHAN]);
 		if (cbch) {
 			cbch->rel_act_kind = LCHAN_REL_ACT_OML;
 			lchan_activate(cbch);
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index b89a359..4465f3b 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -267,7 +267,7 @@
 	}
 
 	if (trx == trx->bts->c0)
-		lchan_init_lapdm(&trx->ts[0].lchan[4]);
+		lchan_init_lapdm(&trx->ts[0].lchan[CCCH_LCHAN]);
 
 	/* Set to Operational State: Enabled */
 	oml_mo_state_chg(&trx->mo, NM_OPSTATE_ENABLED, NM_AVSTATE_OK);
@@ -288,7 +288,7 @@
 
 	/* deactivate lchan for CCCH */
 	if (pchan == GSM_PCHAN_CCCH || pchan == GSM_PCHAN_CCCH_SDCCH4) {
-		lchan_set_state(&trx->ts[0].lchan[4], LCHAN_S_INACTIVE);
+		lchan_set_state(&trx->ts[0].lchan[CCCH_LCHAN], LCHAN_S_INACTIVE);
 	}
 
 	/* power off transceiver, if not already */
@@ -408,8 +408,8 @@
 
 	/* activate lchan for CCCH */
 	if (pchan == GSM_PCHAN_CCCH || pchan == GSM_PCHAN_CCCH_SDCCH4) {
-		ts->lchan[4].rel_act_kind = LCHAN_REL_ACT_OML;
-		lchan_set_state(&ts->lchan[4], LCHAN_S_ACTIVE);
+		ts->lchan[CCCH_LCHAN].rel_act_kind = LCHAN_REL_ACT_OML;
+		lchan_set_state(&ts->lchan[CCCH_LCHAN], LCHAN_S_ACTIVE);
 	}
 
 	slottype = transceiver_chan_types[pchan];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5d742c292d638f119c6b4672120c1950adeb7f0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list