Skip to content

Commit

Permalink
asm-generic/atomic.h: add atomic_set_mask() helper
Browse files Browse the repository at this point in the history
Since arches are expected to implement this guy, add a common version for
people the same way as atomic_clear_mask is handled.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Cc: Arun Sharma <asharma@fb.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Mike Frysinger authored and Linus Torvalds committed Jul 26, 2011
1 parent f6081bd commit 00b3c28
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/asm-generic/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
raw_local_irq_restore(flags);
}

/**
* atomic_set_mask - Atomically set bits in atomic variable
* @mask: Mask of the bits to be set
* @v: pointer of type atomic_t
*
* Atomically sets the bits set in @mask in @v
*/
static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
{
unsigned long flags;

raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */
v->counter |= mask;
raw_local_irq_restore(flags);
}

/* Assume that atomic operations are already serializing */
#define smp_mb__before_atomic_dec() barrier()
#define smp_mb__after_atomic_dec() barrier()
Expand Down

0 comments on commit 00b3c28

Please sign in to comment.