[PATCH 2/2] rearm_timer: update run-time and re-activate

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Christian Vogel vogelchr at vogel.cx
Sat Jan 28 20:41:35 UTC 2012


Instead of calling schedule_timer() inside the
callback (which causes list-reshuffling) just call
rearm_timer(self,milliseconds) to have it re-execute
after the specified time.
---
 src/target/firmware/comm/timer.c         |    6 ++++++
 src/target/firmware/include/comm/timer.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/target/firmware/comm/timer.c b/src/target/firmware/comm/timer.c
index 6a649ae..d135e24 100644
--- a/src/target/firmware/comm/timer.c
+++ b/src/target/firmware/comm/timer.c
@@ -63,6 +63,12 @@ void schedule_timer(struct osmo_timer_list *timer, int milliseconds)
 	add_timer(timer);
 }
 
+void rearm_timer(struct osmo_timer_list *timer, int milliseconds)
+{
+	timer->expires = jiffies + ((milliseconds * TIMER_HZ) / 1000);
+	timer->active = 1;
+}
+
 void del_timer(struct osmo_timer_list *timer)
 {
 	if (timer->in_list) {
diff --git a/src/target/firmware/include/comm/timer.h b/src/target/firmware/include/comm/timer.h
index db7d1a5..6ca51b5 100644
--- a/src/target/firmware/include/comm/timer.h
+++ b/src/target/firmware/include/comm/timer.h
@@ -60,6 +60,7 @@ extern unsigned long volatile jiffies;
  */
 void add_timer(struct osmo_timer_list *timer);
 void schedule_timer(struct osmo_timer_list *timer, int miliseconds);
+void rearm_timer(struct osmo_timer_list *timer, int milliseconds);
 void del_timer(struct osmo_timer_list *timer);
 int timer_pending(struct osmo_timer_list *timer);
 
-- 
1.7.0.4





More information about the baseband-devel mailing list