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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Jun 28 20:28:11 2013 +0200

cobalt/kernel: drop __clrbits()

Same as __setbits, this macro does not bring anything useful compared
to an explict bitwise operation.

---

 include/cobalt/kernel/types.h |    1 -
 kernel/cobalt/intr.c          |   13 ++++++-------
 kernel/cobalt/map.c           |    5 ++---
 kernel/cobalt/pipe.c          |   22 +++++++++++-----------
 kernel/cobalt/pod.c           |    8 ++++----
 kernel/cobalt/sched.c         |    6 +++---
 kernel/cobalt/synch.c         |    2 +-
 kernel/cobalt/timer.c         |   11 +++++------
 8 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/include/cobalt/kernel/types.h b/include/cobalt/kernel/types.h
index 9375c2f..7289923 100644
--- a/include/cobalt/kernel/types.h
+++ b/include/cobalt/kernel/types.h
@@ -24,7 +24,6 @@
 
 #define setbits(flags,mask)  xnarch_atomic_set_mask(&(flags),mask)
 #define clrbits(flags,mask)  xnarch_atomic_clear_mask(&(flags),mask)
-#define __clrbits(flags,mask)  do { (flags) &= ~(mask); } while(0)
 
 #define XENO_INFO KERN_INFO    "[Xenomai] "
 #define XENO_WARN KERN_WARNING "[Xenomai] "
diff --git a/kernel/cobalt/intr.c b/kernel/cobalt/intr.c
index 5628f27..1c2555e 100644
--- a/kernel/cobalt/intr.c
+++ b/kernel/cobalt/intr.c
@@ -84,7 +84,7 @@ static void xnintr_irq_handler(unsigned irq, void *cookie);
 
 void xnintr_host_tick(struct xnsched *sched) /* Interrupts off. */
 {
-       __clrbits(sched->lflags, XNHTICK);
+       sched->lflags &= ~XNHTICK;
 #ifdef XNARCH_HOST_TICK_IRQ
        ipipe_post_irq_root(per_cpu(ipipe_percpu.hrtimer_irq, 
xnsched_cpu(sched)));
 #endif
@@ -115,7 +115,7 @@ void xnintr_clock_handler(void)
        xnstat_exectime_switch(sched, prev);
 
        if (--sched->inesting == 0) {
-               __clrbits(sched->lflags, XNINIRQ);
+               sched->lflags &= ~XNINIRQ;
                xnpod_schedule();
                sched = xnpod_current_sched();
        }
@@ -222,7 +222,7 @@ static void xnintr_shirq_handler(unsigned irq, void *cookie)
        xnstat_exectime_switch(sched, prev);
 
        if (--sched->inesting == 0) {
-               __clrbits(sched->lflags, XNINIRQ);
+               sched->lflags &= ~XNINIRQ;
                xnpod_schedule();
        }
 
@@ -305,7 +305,7 @@ static void xnintr_edge_shirq_handler(unsigned irq, void 
*cookie)
        xnstat_exectime_switch(sched, prev);
 
        if (--sched->inesting == 0) {
-               __clrbits(sched->lflags, XNINIRQ);
+               sched->lflags &= ~XNINIRQ;
                xnpod_schedule();
        }
 
@@ -494,7 +494,7 @@ static void xnintr_irq_handler(unsigned irq, void *cookie)
        xnstat_exectime_switch(sched, prev);
 
        if (--sched->inesting == 0) {
-               __clrbits(sched->lflags, XNINIRQ);
+               sched->lflags &= ~XNINIRQ;
                xnpod_schedule();
        }
 
@@ -786,8 +786,7 @@ int xnintr_detach(xnintr_t *intr)
                goto out;
        }
 
-       __clrbits(intr->flags, XN_ISR_ATTACHED);
-
+       intr->flags &= ~XN_ISR_ATTACHED;
        xnintr_irq_detach(intr);
        xnintr_stat_counter_dec();
  out:
diff --git a/kernel/cobalt/map.c b/kernel/cobalt/map.c
index 443da87..00a0d2e 100644
--- a/kernel/cobalt/map.c
+++ b/kernel/cobalt/map.c
@@ -203,10 +203,9 @@ int xnmap_enter(xnmap_t *map, int key, void *objaddr)
                ofkey = hi * BITS_PER_LONG + lo;
                ++map->ukeys;
 
-               __clrbits(map->lomap[hi], 1UL << lo);
-
+               map->lomap[hi] &= ~(1UL << lo);
                if (map->lomap[hi] == 0)
-                       __clrbits(map->himap, 1UL << hi);
+                       map->himap &= ~(1UL << hi);
        }
 
        map->objarray[ofkey] = objaddr;
diff --git a/kernel/cobalt/pipe.c b/kernel/cobalt/pipe.c
index 2bba2ee..a978072 100644
--- a/kernel/cobalt/pipe.c
+++ b/kernel/cobalt/pipe.c
@@ -79,8 +79,8 @@ static inline int xnpipe_minor_alloc(int minor)
 
 static inline void xnpipe_minor_free(int minor)
 {
-       __clrbits(xnpipe_bitmap[minor / BITS_PER_LONG],
-                 1UL << (minor % BITS_PER_LONG));
+       xnpipe_bitmap[minor / BITS_PER_LONG] &=
+               ~(1UL << (minor % BITS_PER_LONG));
 }
 
 static inline void xnpipe_enqueue_wait(struct xnpipe_state *state, int mask)
@@ -96,7 +96,7 @@ static inline void xnpipe_dequeue_wait(struct xnpipe_state 
*state, int mask)
        if (state->status & mask)
                if (--state->wcount == 0) {
                        list_del(&state->slink);
-                       __clrbits(state->status, mask);
+                       state->status &= ~mask;
                }
 }
 
@@ -106,7 +106,7 @@ static inline void xnpipe_dequeue_all(struct xnpipe_state 
*state, int mask)
                if (state->wcount) {
                        state->wcount = 0;
                        list_del(&state->slink);
-                       __clrbits(state->status, mask);
+                       state->status &= ~mask;
                }
        }
 }
@@ -171,7 +171,7 @@ static void xnpipe_wakeup_proc(void *cookie)
                        state = list_next_entry(state, slink);
                }
 
-               __clrbits(state->status, rbits);
+               state->status &= ~rbits;
 
                if ((rbits & XNPIPE_USER_WREAD_READY) != 0) {
                        if (waitqueue_active(&state->readq)) {
@@ -208,7 +208,7 @@ check_async:
                        state = list_next_entry(state, alink);
                }
 
-               __clrbits(state->status, XNPIPE_USER_SIGIO);
+               state->status &= ~XNPIPE_USER_SIGIO;
                xnlock_put_irqrestore(&nklock, s);
                kill_fasync(&state->asyncq, xnpipe_asyncsig, POLL_IN);
                xnlock_get_irqsave(&nklock, s);
@@ -378,7 +378,7 @@ int xnpipe_disconnect(int minor)
                return -EBADF;
        }
 
-       __clrbits(state->status, XNPIPE_KERN_CONN);
+       state->status &= ~XNPIPE_KERN_CONN;
 
        state->ionrd -= xnpipe_flushq(state, outq, free_obuf, s);
 
@@ -637,7 +637,7 @@ EXPORT_SYMBOL_GPL(xnpipe_flush);
        do {                                                            \
                xnpipe_flushq((__state), outq, free_obuf, (__s));       \
                xnpipe_flushq((__state), inq, free_ibuf, (__s));        \
-               __clrbits((__state)->status, XNPIPE_USER_CONN);         \
+               (__state)->status &= ~XNPIPE_USER_CONN;                 \
                if ((__state)->status & XNPIPE_KERN_LCLOSE) {           \
                        clrbits((__state)->status, XNPIPE_KERN_LCLOSE); \
                        xnlock_put_irqrestore(&nklock, (__s));          \
@@ -678,8 +678,8 @@ static int xnpipe_open(struct inode *inode, struct file 
*file)
        init_waitqueue_head(&state->syncq);
        state->wcount = 0;
 
-       __clrbits(state->status,
-                 XNPIPE_USER_ALL_WAIT | XNPIPE_USER_ALL_READY |
+       state->status &=
+               ~(XNPIPE_USER_ALL_WAIT | XNPIPE_USER_ALL_READY |
                  XNPIPE_USER_SIGIO);
 
        if ((state->status & XNPIPE_KERN_CONN) == 0) {
@@ -729,7 +729,7 @@ static int xnpipe_release(struct inode *inode, struct file 
*file)
 
        if (state->asyncq) {    /* Clear the async queue */
                list_del(&state->alink);
-               __clrbits(state->status, XNPIPE_USER_SIGIO);
+               state->status &= ~XNPIPE_USER_SIGIO;
                xnlock_put_irqrestore(&nklock, s);
                fasync_helper(-1, file, 0, &state->asyncq);
                xnlock_get_irqsave(&nklock, s);
diff --git a/kernel/cobalt/pod.c b/kernel/cobalt/pod.c
index fc58a8d..8a1c2cf 100644
--- a/kernel/cobalt/pod.c
+++ b/kernel/cobalt/pod.c
@@ -361,7 +361,7 @@ void xnpod_shutdown(int xtype)
 
        xnpod_schedule();
 
-       __clrbits(nkpod->status, XNPEXEC);
+       nkpod->status &= ~XNPEXEC;
 
        for_each_online_cpu(cpu) {
                sched = xnpod_sched_slot(cpu);
@@ -1105,7 +1105,7 @@ void xnpod_suspend_thread(xnthread_t *thread, int mask,
                thread->wchan = wchan;
 
        if (thread == sched->curr) {
-               __clrbits(sched->lflags, XNINLOCK);
+               sched->lflags &= ~XNINLOCK;
                /*
                 * If the current thread is being relaxed, we must
                 * have been called from xnshadow_relax(), in which
@@ -1712,7 +1712,7 @@ static inline int test_resched(struct xnsched *sched)
 #else
        resched = xnsched_resched_p(sched);
 #endif
-       __clrbits(sched->status, XNRESCHED);
+       sched->status &= ~XNRESCHED;
 
        return resched;
 }
@@ -1907,7 +1907,7 @@ void ___xnpod_unlock_sched(xnsched_t *sched)
 
        if (--xnthread_lock_count(curr) == 0) {
                xnthread_clear_state(curr, XNLOCK);
-               __clrbits(sched->lflags, XNINLOCK);
+               sched->lflags &= ~XNINLOCK;
                xnpod_schedule();
        }
 }
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 29f0ce4..cf13376 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -284,7 +284,7 @@ struct xnsched *xnsched_finish_unlocked_switch(struct 
xnsched *sched)
 #endif /* CONFIG_SMP */
 
        last = sched->last;
-       __clrbits(sched->status, XNINSW);
+       sched->status &= ~XNINSW;
 
        /* Detect a thread which called xnpod_migrate_thread */
        if (last->sched != sched) {
@@ -544,9 +544,9 @@ static void removemlq(struct xnsched_mlq *q,
        if (list_empty(head)) {
                hi = idx / BITS_PER_LONG;
                lo = idx % BITS_PER_LONG;
-               __clrbits(q->lomap[hi], 1UL << lo);
+               q->lomap[hi] &= ~(1UL << lo);
                if (q->lomap[hi] == 0)
-                       __clrbits(q->himap, 1UL << hi);
+                       q->himap &= ~(1UL << hi);
        }
 }
 
diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c
index cd9b516..02ba7f8 100644
--- a/kernel/cobalt/synch.c
+++ b/kernel/cobalt/synch.c
@@ -594,7 +594,7 @@ static void xnsynch_clear_boost(struct xnsynch *synch,
        int wprio;
 
        list_del(&synch->link);
-       __clrbits(synch->status, XNSYNCH_CLAIMED);
+       synch->status &= ~XNSYNCH_CLAIMED;
        wprio = owner->bprio + owner->sched_class->weight;
 
        if (list_empty(&owner->claimq)) {
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index 3987041..c6e0f75 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -50,7 +50,7 @@ static inline void xntimer_enqueue(xntimer_t *timer)
 {
        xntimerq_t *q = &timer->sched->timerqueue;
        xntimerq_insert(q, &timer->aplink);
-       __clrbits(timer->status, XNTIMER_DEQUEUED);
+       timer->status &= ~XNTIMER_DEQUEUED;
        xnstat_counter_inc(&timer->scheduled);
 }
 
@@ -99,7 +99,7 @@ void xntimer_next_local_shot(xnsched_t *sched)
         * __xnpod_schedule()), or a timer with an earlier timeout
         * date is scheduled, whichever comes first.
         */
-       __clrbits(sched->lflags, XNHDEFER);
+       sched->lflags &= ~XNHDEFER;
        timer = aplink2timer(h);
        if (unlikely(timer == &sched->htimer)) {
                if (xnsched_resched_p(sched) ||
@@ -290,8 +290,7 @@ int xntimer_start(xntimer_t *timer,
 
        now = xnclock_read_raw();
 
-       __clrbits(timer->status,
-                 XNTIMER_REALTIME | XNTIMER_FIRED | XNTIMER_PERIODIC);
+       timer->status &= ~(XNTIMER_REALTIME | XNTIMER_FIRED | XNTIMER_PERIODIC);
        switch (mode) {
        case XN_RELATIVE:
                if ((xnsticks_t)value < 0)
@@ -554,7 +553,7 @@ void xntimer_tick(void)
                         * precious microsecs on low-end hw.
                         */
                        sched->lflags |= XNHTICK;
-                       __clrbits(sched->lflags, XNHDEFER);
+                       sched->lflags &= ~XNHDEFER;
                        if ((timer->status & XNTIMER_PERIODIC) == 0)
                                continue;
                }
@@ -567,7 +566,7 @@ void xntimer_tick(void)
                xntimer_enqueue(timer);
        }
 
-       __clrbits(sched->status, XNINTCK);
+       sched->status &= ~XNINTCK;
 
        xntimer_next_local_shot(sched);
 }


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

Reply via email to