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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Jul 17 10:27:47 2014 +0200

cobalt/timer: assign handler identifier as default timer name

Timer name and handler name are redundant. Drop the latter, but assign
it as the timer's default name until xntimer_set_name() is called.

---

 include/cobalt/kernel/timer.h     |    7 +++----
 kernel/cobalt/clock.c             |   10 ++++------
 kernel/cobalt/trace/cobalt-core.h |    6 +++---
 3 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index 055661c..3eaca4c 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -23,6 +23,7 @@
 #include <cobalt/kernel/clock.h>
 #include <cobalt/kernel/stat.h>
 #include <cobalt/kernel/list.h>
+#include <cobalt/kernel/ancillaries.h>
 
 /**
  * @addtogroup cobalt_core_timer
@@ -215,8 +216,6 @@ struct xntimer {
 #endif
        /** Timer name to be displayed. */
        char name[XNOBJECT_NAME_LEN];
-       /** Handler name to be displayed. */
-       const char *handler_name;
        /** Timer holder in timebase. */
        struct list_head next_stat;
        /** Number of timer schedules. */
@@ -330,7 +329,7 @@ void xntimer_set_gravity(struct xntimer *timer,
 #define xntimer_init(__timer, __clock, __handler, __thread, __flags)   \
 do {                                                                   \
        __xntimer_init(__timer, __clock, __handler, __thread, __flags); \
-       (__timer)->handler_name = #__handler;                           \
+       xntimer_set_name(__timer, #__handler);                          \
 } while (0)
 
 static inline void xntimer_reset_stats(struct xntimer *timer)
@@ -351,7 +350,7 @@ static inline void xntimer_account_fired(struct xntimer 
*timer)
 
 static inline void xntimer_set_name(struct xntimer *timer, const char *name)
 {
-       strncpy(timer->name, name, sizeof(timer->name));
+       knamecpy(timer->name, name);
 }
 
 #else /* !CONFIG_XENO_OPT_STATS */
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index a552a9b..1284d66 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -355,7 +355,6 @@ struct vfile_clock_data {
        xnticks_t timeout;
        xnticks_t interval;
        unsigned long status;
-       char handler[XNOBJECT_NAME_LEN];
        char name[XNOBJECT_NAME_LEN];
 };
 
@@ -398,7 +397,6 @@ static int timerlist_next(struct xnvfile_snapshot_iterator 
*it, void *data)
        p->timeout = xntimer_get_timeout(timer);
        p->interval = xntimer_interval(timer);
        p->status = timer->status;
-       knamecpy(p->handler, timer->handler_name);
        knamecpy(p->name, timer->name);
 
        return 1;
@@ -413,9 +411,9 @@ static int timerlist_show(struct xnvfile_snapshot_iterator 
*it, void *data)
 
        if (p == NULL)
                xnvfile_printf(it,
-                              "%-3s  %-20s  %-10s  %-10s  %-16s  %s\n",
+                              "%-3s  %-20s  %-10s  %-10s  %s\n",
                               "CPU", "SCHED/SHOT", "TIMEOUT",
-                              "INTERVAL", "HANDLER", "NAME");
+                              "INTERVAL", "NAME");
        else {
                if ((p->status & XNTIMER_DEQUEUED) == 0)
                        xntimer_format_time(p->timeout, timeout_buf,
@@ -426,9 +424,9 @@ static int timerlist_show(struct xnvfile_snapshot_iterator 
*it, void *data)
                ksformat(hit_buf, sizeof(hit_buf), "%u/%u",
                         p->scheduled, p->fired);
                xnvfile_printf(it,
-                              "%-3u  %-20s  %-10s  %-10s  %-16s  %s\n",
+                              "%-3u  %-20s  %-10s  %-10s  %s\n",
                               p->cpu, hit_buf, timeout_buf,
-                              interval_buf, p->handler, p->name);
+                              interval_buf, p->name);
        }
 
        return 0;
diff --git a/kernel/cobalt/trace/cobalt-core.h 
b/kernel/cobalt/trace/cobalt-core.h
index c33c452..71001da 100644
--- a/kernel/cobalt/trace/cobalt-core.h
+++ b/kernel/cobalt/trace/cobalt-core.h
@@ -556,7 +556,7 @@ TRACE_EVENT(cobalt_timer_start,
        TP_STRUCT__entry(
                __field(struct xntimer *, timer)
 #ifdef CONFIG_XENO_OPT_STATS
-               __string(handler, timer->handler_name)
+               __string(name, timer->name)
 #endif
                __field(xnticks_t, value)
                __field(xnticks_t, interval)
@@ -566,7 +566,7 @@ TRACE_EVENT(cobalt_timer_start,
        TP_fast_assign(
                __entry->timer = timer;
 #ifdef CONFIG_XENO_OPT_STATS
-               __assign_str(handler, timer->handler_name);
+               __assign_str(name, timer->name);
 #endif
                __entry->value = value;
                __entry->interval = interval;
@@ -576,7 +576,7 @@ TRACE_EVENT(cobalt_timer_start,
        TP_printk("timer=%p(%s) value=%Lu interval=%Lu mode=%s",
                  __entry->timer,
 #ifdef CONFIG_XENO_OPT_STATS
-                 __get_str(handler),
+                 __get_str(name),
 #else
                  "(anon)",
 #endif


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

Reply via email to