bts: Remove global state and the usage of the gprs_rlcmac_bts

Global state makes mocking/writing tests more difficult. Continue
by removing direct usage of the bts and adding it as pointer to
the function calls (showing the true dependencies of the functions)
This commit is contained in:
Holger Hans Peter Freyther 2013-10-16 21:47:45 +02:00
parent 45396a99d9
commit 173a240a7e
4 changed files with 6 additions and 7 deletions

View File

@ -188,10 +188,10 @@ int tfi_find_free(struct gprs_rlcmac_bts *bts, enum gprs_rlcmac_tbf_direction di
LLIST_HEAD(gprs_rlcmac_sbas);
int sba_alloc(uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta)
int sba_alloc(struct gprs_rlcmac_bts *bts,
uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta)
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
struct gprs_rlcmac_pdch *pdch;
struct gprs_rlcmac_sba *sba;
uint8_t trx, ts;

View File

@ -146,7 +146,7 @@ int gprs_rlcmac_rssi_rep(struct gprs_rlcmac_tbf *tbf);
int gprs_rlcmac_dl_bw(struct gprs_rlcmac_tbf *tbf, uint16_t octets);
int sba_alloc(uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta);
int sba_alloc(struct gprs_rlcmac_bts *bts, uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta);
struct gprs_rlcmac_sba *sba_find(uint8_t trx, uint8_t ts, uint32_t fn);

View File

@ -1060,7 +1060,7 @@ int gprs_rlcmac_rcv_rach(uint8_t ra, uint32_t Fn, int16_t qta)
if (qta > 252)
qta = 252;
if (sb) {
rc = sba_alloc(&trx, &ts, &sb_fn, qta >> 2);
rc = sba_alloc(bts, &trx, &ts, &sb_fn, qta >> 2);
if (rc < 0)
return rc;
LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] RACH qbit-ta=%d "

View File

@ -243,12 +243,11 @@ struct gprs_rlcmac_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts,
static void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf)
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
struct gprs_rlcmac_pdch *pdch;
int ts;
if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
bts->trx[tbf->trx_no].ul_tbf[tbf->tfi] = NULL;
tbf->trx->ul_tbf[tbf->tfi] = NULL;
for (ts = 0; ts < 8; ts++) {
pdch = tbf->pdch[ts];
if (pdch)
@ -256,7 +255,7 @@ static void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf)
tbf->pdch[ts] = NULL;
}
} else {
bts->trx[tbf->trx_no].dl_tbf[tbf->tfi] = NULL;
tbf->trx->dl_tbf[tbf->tfi] = NULL;
for (ts = 0; ts < 8; ts++) {
pdch = tbf->pdch[ts];
if (pdch)