Change in osmo-bts[master]: [VAMOS] conf_lchans_as_pchan(): improve readability

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

fixeria gerrit-no-reply at lists.osmocom.org
Sun Jun 6 01:09:25 UTC 2021


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/24485 )

Change subject: [VAMOS] conf_lchans_as_pchan(): improve readability
......................................................................

[VAMOS] conf_lchans_as_pchan(): improve readability

Change-Id: I1c5a033e89d9ca5fb01ebe9ffb521fd67d159bee
---
M src/common/oml.c
1 file changed, 21 insertions(+), 33 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved



diff --git a/src/common/oml.c b/src/common/oml.c
index cf83903..aba8847 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -813,62 +813,50 @@
 	return conf_lchans_as_pchan(ts, pchan);
 }
 
+static inline void lchans_type_set(struct gsm_bts_trx_ts *ts,
+				   enum gsm_chan_t lchan_type,
+				   unsigned int num_lchans)
+{
+	unsigned int i;
+
+	for (i = 0; i < num_lchans; i++)
+		ts->lchan[i].type = lchan_type;
+}
+
 int conf_lchans_as_pchan(struct gsm_bts_trx_ts *ts,
 			 enum gsm_phys_chan_config pchan)
 {
-	struct gsm_lchan *lchan;
-	unsigned int i;
-
 	switch (pchan) {
 	case GSM_PCHAN_CCCH_SDCCH4_CBCH:
-		/* fallthrough */
 	case GSM_PCHAN_CCCH_SDCCH4:
-		for (i = 0; i < 4; i++) {
-			lchan = &ts->lchan[i];
-			if (pchan == GSM_PCHAN_CCCH_SDCCH4_CBCH
-			    && i == 2) {
-				lchan->type = GSM_LCHAN_CBCH;
-			} else {
-				lchan->type = GSM_LCHAN_SDCCH;
-			}
-		}
+		lchans_type_set(ts, GSM_LCHAN_SDCCH, 4);
+		if (pchan == GSM_PCHAN_CCCH_SDCCH4_CBCH)
+			ts->lchan[2].type = GSM_LCHAN_CBCH;
 		/* fallthrough */
 	case GSM_PCHAN_CCCH:
-		lchan = &ts->lchan[CCCH_LCHAN];
-		lchan->type = GSM_LCHAN_CCCH;
+		ts->lchan[CCCH_LCHAN].type = GSM_LCHAN_CBCH;
 		break;
 	case GSM_PCHAN_TCH_F:
-		lchan = &ts->lchan[0];
-		lchan->type = GSM_LCHAN_TCH_F;
+		lchans_type_set(ts, GSM_LCHAN_TCH_F, 1);
 		break;
 	case GSM_PCHAN_TCH_H:
-		for (i = 0; i < 2; i++) {
-			lchan = &ts->lchan[i];
-			lchan->type = GSM_LCHAN_TCH_H;
-		}
+		lchans_type_set(ts, GSM_LCHAN_TCH_H, 2);
 		break;
 	case GSM_PCHAN_SDCCH8_SACCH8C_CBCH:
-		/* fallthrough */
 	case GSM_PCHAN_SDCCH8_SACCH8C:
-		for (i = 0; i < 8; i++) {
-			lchan = &ts->lchan[i];
-			if (pchan == GSM_PCHAN_SDCCH8_SACCH8C_CBCH
-			    && i == 2) {
-				lchan->type = GSM_LCHAN_CBCH;
-			} else {
-				lchan->type = GSM_LCHAN_SDCCH;
-			}
-		}
+		lchans_type_set(ts, GSM_LCHAN_SDCCH, 8);
+		if (pchan == GSM_PCHAN_SDCCH8_SACCH8C_CBCH)
+			ts->lchan[2].type = GSM_LCHAN_CBCH;
 		break;
 	case GSM_PCHAN_PDCH:
-		lchan = &ts->lchan[0];
-		lchan->type = GSM_LCHAN_PDTCH;
+		lchans_type_set(ts, GSM_LCHAN_PDTCH, 1);
 		break;
 	default:
 		LOGP(DOML, LOGL_ERROR, "Unknown/unhandled PCHAN type: %u %s\n",
 		     ts->pchan, gsm_pchan_name(ts->pchan));
 		return -NM_NACK_PARAM_RANGE;
 	}
+
 	return 0;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/24485
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I1c5a033e89d9ca5fb01ebe9ffb521fd67d159bee
Gerrit-Change-Number: 24485
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-CC: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210606/29e059e1/attachment.htm>


More information about the gerrit-log mailing list