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
diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c
index 066dc72..d2b0204 100644
--- a/tests/timer/timer_test.c
+++ b/tests/timer/timer_test.c
@@ -39,10 +39,7 @@
 static void secondary_timer_fired(void *data);
 
 static unsigned int main_timer_step = 0;
-static struct osmo_timer_list main_timer = {
-	.cb = main_timer_fired,
-	.data = &main_timer_step,
-};
+static struct osmo_timer_list main_timer;
 
 static LLIST_HEAD(timer_test_list);
 
@@ -92,8 +89,7 @@
 			return;
 		}
 		osmo_gettimeofday(&v->start, NULL);
-		v->timer.cb = secondary_timer_fired;
-		v->timer.data = v;
+		osmo_timer_setup(&v->timer, secondary_timer_fired, v);
 		unsigned int seconds = (i & 0x7) + 1;
 		v->stop.tv_sec = v->start.tv_sec + seconds;
 		v->stop.tv_usec = v->start.tv_usec;
@@ -195,6 +191,7 @@
 	       " %d steps of %d msecs each\n",
 	       timer_nsteps, steps, TIME_BETWEEN_TIMER_CHECKS / 1000);
 
+	osmo_timer_setup(&main_timer, main_timer_fired, &main_timer_step);
 	osmo_timer_schedule(&main_timer, 1, 0);
 
 #ifdef HAVE_SYS_SELECT_H