[MERGED] 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
Tue Oct 18 09:20:33 UTC 2016


Max has submitted this change and it was merged.

Change subject: Replace magic number with define
......................................................................


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(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 f3e620e..59866a2 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -947,7 +947,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 690a81d..c4f3d7e 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -727,7 +727,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 634c236..689ba70 100644
--- a/src/osmo-bts-litecell15/oml.c
+++ b/src/osmo-bts-litecell15/oml.c
@@ -287,8 +287,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 74853bf..db416ba 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 c1f1e0b..ed02c74 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -286,8 +286,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: merged
Gerrit-Change-Id: Ic5d742c292d638f119c6b4672120c1950adeb7f0
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list