Introduce init() APIs for PDCH and TRX objects
This will make it easier to keep object specific initializations in
expected place.
Change-Id: Idf1dbdf8bc0b1e16d86eeeffb1193fdf3a57d6ef
diff --git a/src/bts.cpp b/src/bts.cpp
index 55d45b8..1d3f690 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -271,18 +271,8 @@
INIT_LLIST_HEAD(&bts->dl_tbfs);
/* initialize back pointers */
- for (size_t trx_no = 0; trx_no < ARRAY_SIZE(bts->trx); ++trx_no) {
- struct gprs_rlcmac_trx *trx = &bts->trx[trx_no];
- trx->trx_no = trx_no;
- trx->bts = bts;
-
- for (size_t ts_no = 0; ts_no < ARRAY_SIZE(trx->pdch); ++ts_no) {
- struct gprs_rlcmac_pdch *pdch = &trx->pdch[ts_no];
- pdch->init_ptcch_msg();
- pdch->ts_no = ts_no;
- pdch->trx = trx;
- }
- }
+ for (size_t trx_no = 0; trx_no < ARRAY_SIZE(bts->trx); ++trx_no)
+ bts_trx_init(&bts->trx[trx_no], bts, trx_no);
/* The static allocator might have already registered the counter group.
If this happens and we still called explicitly (in tests/ for example)
@@ -1161,6 +1151,15 @@
}
}
+void bts_trx_init(struct gprs_rlcmac_trx *trx, struct gprs_rlcmac_bts *bts, uint8_t trx_no)
+{
+ trx->trx_no = trx_no;
+ trx->bts = bts;
+
+ for (size_t ts_no = 0; ts_no < ARRAY_SIZE(trx->pdch); ts_no++)
+ pdch_init(&trx->pdch[ts_no], trx, ts_no);
+}
+
void bts_trx_reserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_direction dir,
uint8_t slots)
{