Module: xenomai-3
Branch: next
Commit: 0c0d32f5d1ae9971acc5fbd4ff48cf724a09e6f4
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0c0d32f5d1ae9971acc5fbd4ff48cf724a09e6f4

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Oct 29 14:49:59 2015 +0100

cobalt/thread: allow NULL thread spec for xnthread_set_clock()

---

 include/cobalt/kernel/thread.h |    4 ++--
 kernel/cobalt/thread.c         |   11 ++++++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index df6297f..59d6027 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -435,8 +435,8 @@ void xnthread_deregister(struct xnthread *thread);
 char *xnthread_format_status(unsigned long status,
                             char *buf, int size);
 
-void xnthread_set_clock(struct xnthread *thread,
-                       struct xnclock *newclock);
+int xnthread_set_clock(struct xnthread *thread,
+                      struct xnclock *newclock);
 
 xnticks_t xnthread_get_timeout(struct xnthread *thread,
                               xnticks_t ns);
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index ab9867c..5fdf919 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -326,15 +326,24 @@ char *xnthread_format_status(unsigned long status, char 
*buf, int size)
        return buf;
 }
 
-void xnthread_set_clock(struct xnthread *thread, struct xnclock *newclock)
+int xnthread_set_clock(struct xnthread *thread, struct xnclock *newclock)
 {
        spl_t s;
 
+       if (thread == NULL) {
+               thread = xnthread_current();
+               if (thread == NULL)
+                       return -EPERM;
+       }
+       
        /* Change the clock the thread's periodic timer is paced by. */
        xnlock_get_irqsave(&nklock, s);
        xntimer_set_clock(&thread->ptimer, newclock);
        xnlock_put_irqrestore(&nklock, s);
+
+       return 0;
 }
+EXPORT_SYMBOL_GPL(xnthread_set_clock);
 
 xnticks_t xnthread_get_timeout(struct xnthread *thread, xnticks_t ns)
 {


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

Reply via email to