* rename the timer functions to avoid name collisions with libmisdn.
* the return value of bsc_update_timers() is required for applications to find out if a timer was fired
(Andreas Eversberg)

diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h
index 8ad127a..4da9e3a 100644
--- a/include/openbsc/gsm_data.h
+++ b/include/openbsc/gsm_data.h
@@ -39,7 +39,7 @@
 #define LCHAN_RELEASE_TIMEOUT 4, 0
 #define use_lchan(lchan) \
 	do {	lchan->use_count++; \
-		schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0);
+		bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0);
 
 #define put_lchan(lchan) \
 	do { lchan->use_count--; } while(0);
diff --git a/include/openbsc/timer.h b/include/openbsc/timer.h
index b3e809e..ae67a5a 100644
--- a/include/openbsc/timer.h
+++ b/include/openbsc/timer.h
@@ -55,17 +55,17 @@
 /**
  * timer management
  */
-void add_timer(struct timer_list *timer);
-void schedule_timer(struct timer_list *timer, int seconds, int microseconds);
-void del_timer(struct timer_list *timer);
-int timer_pending(struct timer_list *timer);
+void bsc_add_timer(struct timer_list *timer);
+void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds);
+void bsc_del_timer(struct timer_list *timer);
+int bsc_timer_pending(struct timer_list *timer);
 
 
 /**
  * internal timer list management
  */
-struct timeval *nearest_timer();
-void prepare_timers();
-void update_timers();
+struct timeval *bsc_nearest_timer();
+void bsc_prepare_timers();
+int bsc_update_timers();
 
 #endif
diff --git a/src/bs11_config.c b/src/bs11_config.c
index 25ff0e0..3da0c52 100644
--- a/src/bs11_config.c
+++ b/src/bs11_config.c
@@ -633,7 +633,7 @@
 		abis_nm_bs11_factory_logon(g_bts, 1);
 		break;
 	case STATE_LOGON_ACK:
-		schedule_timer(&status_timer, 5, 0);
+		bsc_schedule_timer(&status_timer, 5, 0);
 		break;
 	default:
 		break;
diff --git a/src/chan_alloc.c b/src/chan_alloc.c
index 7edde6e..fa07273 100644
--- a/src/chan_alloc.c
+++ b/src/chan_alloc.c
@@ -178,7 +178,7 @@
 		/* Configure the time and start it so it will be closed */
 		lchan->release_timer.cb = auto_release_channel;
 		lchan->release_timer.data = lchan;
-		schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT);
+		bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT);
 	}
 
 	return lchan;
@@ -199,7 +199,7 @@
 	}
 
 	/* stop the timer */
-	del_timer(&lchan->release_timer);
+	bsc_del_timer(&lchan->release_timer);
 
 	/* FIXME: ts_free() the timeslot, if we're the last logical
 	 * channel using it */
@@ -233,7 +233,7 @@
 	struct gsm_lchan *lchan = _lchan;
 
 	if (!lchan_auto_release(lchan))
-		schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT);
+		bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT);
 }
 
 struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr) {
diff --git a/src/gsm_04_08.c b/src/gsm_04_08.c
index fe1637e..e178d99 100644
--- a/src/gsm_04_08.c
+++ b/src/gsm_04_08.c
@@ -165,7 +165,7 @@
 	if (!lchan->loc_operation)
 		return;
 
-	del_timer(&lchan->loc_operation->updating_timer);
+	bsc_del_timer(&lchan->loc_operation->updating_timer);
 	free(lchan->loc_operation);
 	lchan->loc_operation = 0;
 	put_lchan(lchan);
@@ -527,7 +527,7 @@
 {
 	lchan->loc_operation->updating_timer.cb = loc_upd_rej_cb;
 	lchan->loc_operation->updating_timer.data = lchan;
-	schedule_timer(&lchan->loc_operation->updating_timer, 5, 0);
+	bsc_schedule_timer(&lchan->loc_operation->updating_timer, 5, 0);
 }
 
 static const char *lupd_name(u_int8_t type)
diff --git a/src/ipaccess-find.c b/src/ipaccess-find.c
index bada3b2..32f42e9 100644
--- a/src/ipaccess-find.c
+++ b/src/ipaccess-find.c
@@ -143,7 +143,7 @@
 
 	bfd->when |= BSC_FD_WRITE;
 
-	schedule_timer(&timer, 5, 0);
+	bsc_schedule_timer(&timer, 5, 0);
 }
 
 int main(int argc, char **argv)
@@ -165,7 +165,7 @@
 	timer.cb = timer_cb;
 	timer.data = &bfd;
 
-	schedule_timer(&timer, 5, 0);
+	bsc_schedule_timer(&timer, 5, 0);
 
 	printf("Trying to find ip.access BTS by broadcast UDP...\n");
 
diff --git a/src/paging.c b/src/paging.c
index 4de93c6..d777d66 100644
--- a/src/paging.c
+++ b/src/paging.c
@@ -78,7 +78,7 @@
 			paging_bts->last_request = NULL;
 	}
 
-	del_timer(&to_be_deleted->T3113);
+	bsc_del_timer(&to_be_deleted->T3113);
 	llist_del(&to_be_deleted->entry);
 	subscr_put(to_be_deleted->subscr);
 	free(to_be_deleted);
@@ -158,7 +158,7 @@
 	} while (paging_bts->available_slots > 0
 		    &&  initial_request != current_request);
 
-	schedule_timer(&paging_bts->work_timer, 1, 0);
+	bsc_schedule_timer(&paging_bts->work_timer, 1, 0);
 }
 
 static void paging_worker(void *data)
@@ -230,11 +230,11 @@
 	req->cbfn_param = data;
 	req->T3113.cb = paging_T3113_expired;
 	req->T3113.data = req;
-	schedule_timer(&req->T3113, T3113_VALUE);
+	bsc_schedule_timer(&req->T3113, T3113_VALUE);
 	llist_add_tail(&req->entry, &bts_entry->pending_requests);
 
-	if (!timer_pending(&bts_entry->work_timer))
-		schedule_timer(&bts_entry->work_timer, 1, 0);
+	if (!bsc_timer_pending(&bts_entry->work_timer))
+		bsc_schedule_timer(&bts_entry->work_timer, 1, 0);
 }
 
 /* we consciously ignore the type of the request here */
diff --git a/src/select.c b/src/select.c
index 925f339..157e235 100644
--- a/src/select.c
+++ b/src/select.c
@@ -75,13 +75,13 @@
 			FD_SET(ufd->fd, &exceptset);
 	}
 
-	prepare_timers();
-	i = select(maxfd+1, &readset, &writeset, &exceptset, nearest_timer());
+	bsc_prepare_timers();
+	i = select(maxfd+1, &readset, &writeset, &exceptset, bsc_nearest_timer());
 	if (i < 0)
 		return i;
 
 	/* fire timers */
-	update_timers();
+	bsc_update_timers();
 
 	/* call registered callback functions */
 	llist_for_each_entry_safe(ufd, tmp, &bsc_fds, list) {
diff --git a/src/timer.c b/src/timer.c
index 3ec085b..a942ffd 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -31,7 +31,7 @@
 #define TIME_SMALLER(left, right) \
         (left.tv_sec*MICRO_SECONDS+left.tv_usec) <= (right.tv_sec*MICRO_SECONDS+right.tv_usec)
 
-void add_timer(struct timer_list *timer)
+void bsc_add_timer(struct timer_list *timer)
 {
 	struct timer_list *list_timer;
 
@@ -47,7 +47,7 @@
 	llist_add(&timer->entry, &timer_list);
 }
 
-void schedule_timer(struct timer_list *timer, int seconds, int microseconds)
+void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds)
 {
 	struct timeval current_time;
 
@@ -56,10 +56,10 @@
 	currentTime += seconds * MICRO_SECONDS + microseconds;
 	timer->timeout.tv_sec = currentTime / MICRO_SECONDS;
 	timer->timeout.tv_usec = currentTime % MICRO_SECONDS;
-	add_timer(timer);
+	bsc_add_timer(timer);
 }
 
-void del_timer(struct timer_list *timer)
+void bsc_del_timer(struct timer_list *timer)
 {
 	if (timer->in_list) {
 		timer->active = 0;
@@ -68,7 +68,7 @@
 	}
 }
 
-int timer_pending(struct timer_list *timer)
+int bsc_timer_pending(struct timer_list *timer)
 {
 	return timer->active;
 }
@@ -79,7 +79,7 @@
  * If the nearest timer timed out return NULL and then we will
  * dispatch everything after the select
  */
-struct timeval *nearest_timer()
+struct timeval *bsc_nearest_timer()
 {
 	struct timeval current_time;
 
@@ -106,7 +106,7 @@
 /*
  * Find the nearest time and update s_nearest_time
  */
-void prepare_timers()
+void bsc_prepare_timers()
 {
 	struct timer_list *timer, *nearest_timer = NULL;
 	llist_for_each_entry(timer, &timer_list, entry) {
@@ -125,10 +125,11 @@
 /*
  * fire all timers... and remove them
  */
-void update_timers()
+int bsc_update_timers()
 {
 	struct timeval current_time;
 	struct timer_list *timer, *tmp;
+	int work = 0;
 
 	gettimeofday(&current_time, NULL);
 
@@ -157,6 +158,7 @@
 			timer->handled = 1;
 			timer->active = 0;
 			(*timer->cb)(timer->data);
+			work = 1;
 			goto restart;
 		}
 	}
@@ -164,7 +166,9 @@
 	llist_for_each_entry_safe(timer, tmp, &timer_list, entry) {
 		timer->handled = 0;
 		if (!timer->active) {
-			del_timer(timer);
+			bsc_del_timer(timer);
 		}
 	}
+
+	return work;
 }
diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c
index 3f5828b..339404e 100644
--- a/tests/timer/timer_test.c
+++ b/tests/timer/timer_test.c
@@ -45,8 +45,8 @@
     printf("Fired timer: %lu\n", data);
 
     if (data == 1) {
-        schedule_timer(&timer_one, 3, 0);
-        del_timer(&timer_two);
+        bsc_schedule_timer(&timer_one, 3, 0);
+        bsc_del_timer(&timer_two);
     } else if (data == 2) {
         printf("Should not be fired... bug in del_timer\n");
     } else if (data == 3) {
@@ -60,9 +60,9 @@
 {
     printf("Starting... timer\n");
 
-    schedule_timer(&timer_one, 3, 0);
-    schedule_timer(&timer_two, 5, 0);
-    schedule_timer(&timer_three, 4, 0);
+    bsc_schedule_timer(&timer_one, 3, 0);
+    bsc_schedule_timer(&timer_two, 5, 0);
+    bsc_schedule_timer(&timer_three, 4, 0);
 
     while (1) {
         bsc_select_main();