[MERGED] osmo-bts[master]: scheduler.c: Factor out find_sched_mframe_idx() function

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Feb 23 14:27:37 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: scheduler.c: Factor out find_sched_mframe_idx() function
......................................................................


scheduler.c: Factor out find_sched_mframe_idx() function

Let's split the look-up of the multiframe scheduler from the asignment
to a given l1ts in trx_sched_set_pchan.

Related: OS#2978
Change-Id: I79548b25aae647ce993a9d83c771d22b08cb1c74
---
M src/common/scheduler.c
1 file changed, 24 insertions(+), 17 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index efd7666..41b5d7a 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -1327,6 +1327,19 @@
  * scheduler functions
  */
 
+static int find_sched_mframe_idx(enum gsm_phys_chan_config pchan, uint8_t tn)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(trx_sched_multiframes); i++) {
+		if (trx_sched_multiframes[i].pchan == pchan
+		 && (trx_sched_multiframes[i].slotmask & (1 << tn))) {
+			return i;
+		}
+	}
+	return -1;
+}
+
 /* set multiframe scheduler to given pchan */
 int trx_sched_set_pchan(struct l1sched_trx *l1t, uint8_t tn,
 	enum gsm_phys_chan_config pchan)
@@ -1334,24 +1347,18 @@
 	struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(trx_sched_multiframes); i++) {
-		if (trx_sched_multiframes[i].pchan == pchan
-		 && (trx_sched_multiframes[i].slotmask & (1 << tn))) {
-			l1ts->mf_index = i;
-			l1ts->mf_period = trx_sched_multiframes[i].period;
-			l1ts->mf_frames = trx_sched_multiframes[i].frames;
-			LOGP(DL1C, LOGL_NOTICE, "Configuring multiframe with "
-				"%s trx=%d ts=%d\n",
-				trx_sched_multiframes[i].name,
-				l1t->trx->nr, tn);
-			return 0;
-		}
+	i = find_sched_mframe_idx(pchan, tn);
+	if (i < 0) {
+		LOGP(DL1C, LOGL_NOTICE, "Failed to configure multiframe "
+			"trx=%d ts=%d\n", l1t->trx->nr, tn);
+		return -ENOTSUP;
 	}
-
-	LOGP(DL1C, LOGL_NOTICE, "Failed to configure multiframe "
-		"trx=%d ts=%d\n", l1t->trx->nr, tn);
-
-	return -ENOTSUP;
+	l1ts->mf_index = i;
+	l1ts->mf_period = trx_sched_multiframes[i].period;
+	l1ts->mf_frames = trx_sched_multiframes[i].frames;
+	LOGP(DL1C, LOGL_NOTICE, "Configuring multiframe with %s trx=%d ts=%d\n",
+		trx_sched_multiframes[i].name, l1t->trx->nr, tn);
+	return 0;
 }
 
 /* setting all logical channels given attributes to active/inactive */

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I79548b25aae647ce993a9d83c771d22b08cb1c74
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list