Change in osmo-bsc[master]: rsl_lchan_lookup(): turn cbits if-cascade into a switch()

neels gerrit-no-reply at lists.osmocom.org
Thu Jun 10 15:21:28 UTC 2021


neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/24428 )

Change subject: rsl_lchan_lookup(): turn cbits if-cascade into a switch()
......................................................................

rsl_lchan_lookup(): turn cbits if-cascade into a switch()

There is some odd repetition of macros with all possible subslot
indexes, but now we are using the defined macros instead of magic
numbers, making it easier to see that it is correct.

Also this allows trivially adding VAMOS cbits cases to the existing
switch() in a subsequent patch.

Change-Id: I4c6ce2f4ca999c19a58909b9adb849a3b8b6ffc8
---
M src/osmo-bsc/bts_trx.c
1 file changed, 28 insertions(+), 7 deletions(-)

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



diff --git a/src/osmo-bsc/bts_trx.c b/src/osmo-bsc/bts_trx.c
index 1f3cb0a..8d47ba5 100644
--- a/src/osmo-bsc/bts_trx.c
+++ b/src/osmo-bsc/bts_trx.c
@@ -156,28 +156,49 @@
 	if (rc)
 		*rc = -EINVAL;
 
-	if (cbits == 0x01) {
+	switch (cbits) {
+	case ABIS_RSL_CHAN_NR_CBITS_Bm_ACCHs:
 		lch_idx = 0;	/* TCH/F */
 		ok = ts_is_capable_of_pchan(ts, GSM_PCHAN_TCH_F)
 			|| ts->pchan_on_init == GSM_PCHAN_PDCH; /* PDCH? really? */
-	} else if ((cbits & 0x1e) == 0x02) {
+		break;
+	case ABIS_RSL_CHAN_NR_CBITS_Lm_ACCHs(0):
+	case ABIS_RSL_CHAN_NR_CBITS_Lm_ACCHs(1):
 		lch_idx = cbits & 0x1;	/* TCH/H */
 		ok = ts_is_capable_of_pchan(ts, GSM_PCHAN_TCH_H);
-	} else if ((cbits & 0x1c) == 0x04) {
+		break;
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH4_ACCH(0):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH4_ACCH(1):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH4_ACCH(2):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH4_ACCH(3):
 		lch_idx = cbits & 0x3;	/* SDCCH/4 */
 		ok = ts_is_capable_of_pchan(ts, GSM_PCHAN_CCCH_SDCCH4);
-	} else if ((cbits & 0x18) == 0x08) {
+		break;
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(0):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(1):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(2):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(3):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(4):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(5):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(6):
+	case ABIS_RSL_CHAN_NR_CBITS_SDCCH8_ACCH(7):
 		lch_idx = cbits & 0x7;	/* SDCCH/8 */
 		ok = ts_is_capable_of_pchan(ts, GSM_PCHAN_SDCCH8_SACCH8C);
-	} else if (cbits == 0x10 || cbits == 0x11 || cbits == 0x12) {
+		break;
+	case ABIS_RSL_CHAN_NR_CBITS_BCCH:
+	case ABIS_RSL_CHAN_NR_CBITS_RACH:
+	case ABIS_RSL_CHAN_NR_CBITS_PCH_AGCH:
 		lch_idx = 0; /* CCCH? */
 		ok = ts_is_capable_of_pchan(ts, GSM_PCHAN_CCCH);
 		/* FIXME: we should not return first sdcch4 !!! */
-	} else if ((chan_nr & RSL_CHAN_NR_MASK) == RSL_CHAN_OSMO_PDCH) {
+		break;
+	case ABIS_RSL_CHAN_NR_CBITS_OSMO_PDCH:
 		lch_idx = 0;
 		ok = (ts->pchan_on_init == GSM_PCHAN_TCH_F_TCH_H_PDCH);
-	} else
+		break;
+	default:
 		return NULL;
+	}
 
 	if (rc && ok)
 		*rc = 0;

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I4c6ce2f4ca999c19a58909b9adb849a3b8b6ffc8
Gerrit-Change-Number: 24428
Gerrit-PatchSet: 16
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210610/e7130cc0/attachment.htm>


More information about the gerrit-log mailing list