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

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Feb 23 12:58:52 UTC 2018


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

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


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

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: newchange
Gerrit-Change-Id: I79548b25aae647ce993a9d83c771d22b08cb1c74
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>


More information about the gerrit-log mailing list