Module: xenomai-forge
Branch: next
Commit: 6f5d098eafbd59d2506ee9980916226d41203c16
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=6f5d098eafbd59d2506ee9980916226d41203c16

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Jun 19 19:06:33 2013 +0200

cobalt/kernel/clock: turn timerq into regular kernel list

---

 include/cobalt/kernel/clock.h |    5 +++--
 include/cobalt/kernel/timer.h |   11 ++++-------
 kernel/cobalt/clock.c         |   21 +++++++++++++++------
 kernel/cobalt/timer.c         |    7 ++++---
 4 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/include/cobalt/kernel/clock.h b/include/cobalt/kernel/clock.h
index f923510..4471e3b 100644
--- a/include/cobalt/kernel/clock.h
+++ b/include/cobalt/kernel/clock.h
@@ -28,7 +28,7 @@
 
 #ifdef __KERNEL__
 
-#include <cobalt/kernel/queue.h>
+#include <cobalt/kernel/list.h>
 #include <cobalt/kernel/vfile.h>
 #include <asm-generic/xenomai/timeconv.h>
 
@@ -40,7 +40,8 @@ struct xnclock {
 #ifdef CONFIG_XENO_OPT_STATS
        struct xnvfile_snapshot vfile;
        struct xnvfile_rev_tag revtag;
-       struct xnqueue timerq;
+       struct list_head timerq;
+       int nrtimers;
 #endif /* CONFIG_XENO_OPT_STATS */
 };
 
diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index 6755ee6..2b13870 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -23,10 +23,11 @@
 #ifndef _COBALT_KERNEL_TIMER_H
 #define _COBALT_KERNEL_TIMER_H
 
+#ifdef __KERNEL__
+
 #include <cobalt/kernel/clock.h>
 #include <cobalt/kernel/stat.h>
-
-#ifdef __KERNEL__
+#include <cobalt/kernel/queue.h>
 
 #ifndef CONFIG_XENO_OPT_DEBUG_TIMERS
 #define CONFIG_XENO_OPT_DEBUG_TIMERS  0
@@ -291,12 +292,8 @@ typedef struct xntimer {
 
 #ifdef CONFIG_XENO_OPT_STATS
        char name[XNOBJECT_NAME_LEN]; /* !< Timer name to be displayed. */
-
        const char *handler_name; /* !< Handler name to be displayed. */
-
-       xnholder_t tblink;      /* !< Timer holder in timebase. */
-
-#define tblink2timer(ln)       container_of(ln, xntimer_t, tblink)
+       struct list_head tblink; /* !< Timer holder in timebase. */
 #endif /* CONFIG_XENO_OPT_STATS */
 
        xnstat_counter_t scheduled; /* !< Number of timer schedules. */
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index a5836c0..5f98fce 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -87,7 +87,7 @@ EXPORT_SYMBOL_GPL(xnclock_read_monotonic);
 static struct xnvfile_snapshot_ops tmstat_vfile_ops;
 
 struct tmstat_vfile_priv {
-       struct xnholder *curr;
+       struct xntimer *curr;
 };
 
 struct tmstat_vfile_data {
@@ -105,9 +105,14 @@ static int tmstat_vfile_rewind(struct 
xnvfile_snapshot_iterator *it)
 {
        struct tmstat_vfile_priv *priv = xnvfile_iterator_priv(it);
 
-       priv->curr = getheadq(&nkclock.timerq);
+       if (list_empty(&nkclock.timerq)) {
+               priv->curr = NULL;
+               return 0;
+       }
+
+       priv->curr = list_first_entry(&nkclock.timerq, struct xntimer, tblink);
 
-       return countq(&nkclock.timerq);
+       return nkclock.nrtimers;
 }
 
 static int tmstat_vfile_next(struct xnvfile_snapshot_iterator *it, void *data)
@@ -119,8 +124,12 @@ static int tmstat_vfile_next(struct 
xnvfile_snapshot_iterator *it, void *data)
        if (priv->curr == NULL)
                return 0;
 
-       timer = tblink2timer(priv->curr);
-       priv->curr = nextq(&nkclock.timerq, priv->curr);
+       timer = priv->curr;
+       if (list_is_last(&timer->tblink, &nkclock.timerq))
+               priv->curr = NULL;
+       else
+               priv->curr = list_entry(timer->tblink.next,
+                                       struct xntimer, tblink);
 
        if (xnstat_counter_get(&timer->scheduled) == 0)
                return VFILE_SEQ_SKIP;
@@ -197,7 +206,7 @@ void xnclock_cleanup_proc(void)
 
 struct xnclock nkclock = {
 #ifdef CONFIG_XENO_OPT_STATS
-       .timerq = XNQUEUE_INITIALIZER(nkclock.timerq),
+       .timerq = LIST_HEAD_INIT(nkclock.timerq),
 #endif /* CONFIG_XENO_OPT_STATS */
 };
 EXPORT_SYMBOL_GPL(nkclock);
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index 69f73d7..64266de 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -616,12 +616,12 @@ void __xntimer_init(xntimer_t *timer, void (*handler) 
(xntimer_t *timer))
                xnobject_copy_name(timer->name,
                                   xnpod_current_thread()->name);
 
-       inith(&timer->tblink);
        xnstat_counter_set(&timer->scheduled, 0);
        xnstat_counter_set(&timer->fired, 0);
 
        xnlock_get_irqsave(&nklock, s);
-       appendq(&nkclock.timerq, &timer->tblink);
+       list_add_tail(&timer->tblink, &nkclock.timerq);
+       nkclock.nrtimers++;
        xnvfile_touch(&nkclock.vfile);
        xnlock_put_irqrestore(&nklock, s);
 #else
@@ -662,7 +662,8 @@ void xntimer_destroy(xntimer_t *timer)
        __setbits(timer->status, XNTIMER_KILLED);
        timer->sched = NULL;
 #ifdef CONFIG_XENO_OPT_STATS
-       removeq(&nkclock.timerq, &timer->tblink);
+       list_del(&timer->tblink);
+       nkclock.nrtimers--;
        xnvfile_touch(&nkclock.vfile);
 #endif /* CONFIG_XENO_OPT_STATS */
        xnlock_put_irqrestore(&nklock, s);


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to