alloc: Factor out the routine to find an enabled PDCH
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index ee3ec79..29078d0 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -97,6 +97,23 @@
 	return -1;
 }
 
+static int find_enabled_pdch(struct gprs_rlcmac_trx *trx, const uint8_t start_ts)
+{
+	int ts;
+	for (ts = start_ts; ts < 8; ts++) {
+		struct gprs_rlcmac_pdch *pdch;
+
+		pdch = &trx->pdch[ts];
+		if (!pdch->enable) {
+			LOGP(DRLCMAC, LOGL_DEBUG, "- Skipping TS %d, because "
+				"not enabled\n", ts);
+			continue;
+		}
+		return ts;
+	}
+
+	return 8;
+}
 
 static void assign_uplink_tbf_usf(
 				struct gprs_rlcmac_pdch *pdch,
@@ -135,18 +152,11 @@
 	LOGP(DRLCMAC, LOGL_DEBUG, "Slot Allocation (Algorithm A) for class "
 		"%d\n", tbf->ms_class);
 
-	for (ts = 0; ts < 8; ts++) {
-		pdch = &tbf->trx->pdch[ts];
-		if (!pdch->enable) {
-			LOGP(DRLCMAC, LOGL_DEBUG, "- Skipping TS %d, because "
-				"not enabled\n", ts);
-			continue;
-		}
-		break;
-	}
+	ts = find_enabled_pdch(tbf->trx, 0);
 	if (ts == 8)
 		return -EINVAL;
 
+	pdch = &tbf->trx->pdch[ts];
 	tbf->tsc = pdch->tsc;
 	if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
 		/* if USF available */