diff options
author | Pablo Neira Ayuso <pablo@gnumonks.org> | 2017-05-08 18:00:28 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@gnumonks.org> | 2017-05-09 12:10:51 +0200 |
commit | 44f423f11717367639a12e6b533e293cccf6f6ba (patch) | |
tree | b4d0605d4102925742b8fbab838b85dd18055e09 /src/gsm | |
parent | c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7 (diff) |
timer: add osmo_timer_setup()
Add a new function timer function to set up the timer, similar to what
we have in the Linux kernel. This patch also converts existing opencoded
timer setup in the libosmocore tree as initial client of this new
function.
This patch implicitly removes function callback passed by reference that
defeat compile time type validation.
Compile-tested only, but I ran make check that reports success when
testing timer infrastructure.
Change-Id: I2fa49972ecaab3748b25168b26d92034e9145666
Diffstat (limited to 'src/gsm')
-rw-r--r-- | src/gsm/gsm0411_smc.c | 3 | ||||
-rw-r--r-- | src/gsm/gsm0411_smr.c | 3 | ||||
-rw-r--r-- | src/gsm/lapd_core.c | 6 |
3 files changed, 4 insertions, 8 deletions
diff --git a/src/gsm/gsm0411_smc.c b/src/gsm/gsm0411_smc.c index c44423d4..4c083659 100644 --- a/src/gsm/gsm0411_smc.c +++ b/src/gsm/gsm0411_smc.c @@ -184,8 +184,7 @@ static int gsm411_mmsms_send_msg(struct gsm411_smc_inst *inst) /* 5.2.3.1.2: enter MO-wait for CP-ACK */ /* 5.2.3.2.3: enter MT-wait for CP-ACK */ new_cp_state(inst, GSM411_CPS_WAIT_CP_ACK); - inst->cp_timer.data = inst; - inst->cp_timer.cb = cp_timer_expired; + osmo_timer_setup(&inst->cp_timer, cp_timer_expired, inst); /* 5.3.2.1: Set Timer TC1A */ osmo_timer_schedule(&inst->cp_timer, inst->cp_tc1, 0); /* clone cp_msg */ diff --git a/src/gsm/gsm0411_smr.c b/src/gsm/gsm0411_smr.c index a1ee9804..6d7fb8b5 100644 --- a/src/gsm/gsm0411_smr.c +++ b/src/gsm/gsm0411_smr.c @@ -77,8 +77,7 @@ void gsm411_smr_init(struct gsm411_smr_inst *inst, uint64_t id, int network, inst->rp_state = GSM411_RPS_IDLE; inst->rl_recv = rl_recv; inst->mn_send = mn_send; - inst->rp_timer.data = inst; - inst->rp_timer.cb = rp_timer_expired; + osmo_timer_setup(&inst->rp_timer, rp_timer_expired, inst); LOGP(DLSMS, LOGL_INFO, SMR_LOG_STR "instance created for %s.\n", diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index e0bbcabf..c81b2a05 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -267,12 +267,10 @@ void lapd_dl_init(struct lapd_datalink *dl, uint8_t k, uint8_t v_range, dl->n200 = 3; dl->t200_sec = 1; dl->t200_usec = 0; - dl->t200.data = dl; - dl->t200.cb = &lapd_t200_cb; + osmo_timer_setup(&dl->t200, lapd_t200_cb, dl); dl->t203_sec = 10; dl->t203_usec = 0; - dl->t203.data = dl; - dl->t203.cb = &lapd_t203_cb; + osmo_timer_setup(&dl->t203, lapd_t203_cb, dl); dl->maxf = maxf; if (k > v_range - 1) k = v_range - 1; |