Skip to content

Commit

Permalink
ARM: 8417/1: refactor bitops functions with BIT_MASK() and BIT_WORD()
Browse files Browse the repository at this point in the history
Use BIT_MASK() and BIT_WORD() rather than hard-coding the size
of the "long" type.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Masahiro Yamada authored and Russell King committed Aug 18, 2015
1 parent da4f295 commit 8901925
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions arch/arm/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
static inline void ____atomic_set_bit(unsigned int bit, volatile unsigned long *p)
{
unsigned long flags;
unsigned long mask = 1UL << (bit & 31);
unsigned long mask = BIT_MASK(bit);

p += bit >> 5;
p += BIT_WORD(bit);

raw_local_irq_save(flags);
*p |= mask;
Expand All @@ -47,9 +47,9 @@ static inline void ____atomic_set_bit(unsigned int bit, volatile unsigned long *
static inline void ____atomic_clear_bit(unsigned int bit, volatile unsigned long *p)
{
unsigned long flags;
unsigned long mask = 1UL << (bit & 31);
unsigned long mask = BIT_MASK(bit);

p += bit >> 5;
p += BIT_WORD(bit);

raw_local_irq_save(flags);
*p &= ~mask;
Expand All @@ -59,9 +59,9 @@ static inline void ____atomic_clear_bit(unsigned int bit, volatile unsigned long
static inline void ____atomic_change_bit(unsigned int bit, volatile unsigned long *p)
{
unsigned long flags;
unsigned long mask = 1UL << (bit & 31);
unsigned long mask = BIT_MASK(bit);

p += bit >> 5;
p += BIT_WORD(bit);

raw_local_irq_save(flags);
*p ^= mask;
Expand All @@ -73,9 +73,9 @@ ____atomic_test_and_set_bit(unsigned int bit, volatile unsigned long *p)
{
unsigned long flags;
unsigned int res;
unsigned long mask = 1UL << (bit & 31);
unsigned long mask = BIT_MASK(bit);

p += bit >> 5;
p += BIT_WORD(bit);

raw_local_irq_save(flags);
res = *p;
Expand All @@ -90,9 +90,9 @@ ____atomic_test_and_clear_bit(unsigned int bit, volatile unsigned long *p)
{
unsigned long flags;
unsigned int res;
unsigned long mask = 1UL << (bit & 31);
unsigned long mask = BIT_MASK(bit);

p += bit >> 5;
p += BIT_WORD(bit);

raw_local_irq_save(flags);
res = *p;
Expand All @@ -107,9 +107,9 @@ ____atomic_test_and_change_bit(unsigned int bit, volatile unsigned long *p)
{
unsigned long flags;
unsigned int res;
unsigned long mask = 1UL << (bit & 31);
unsigned long mask = BIT_MASK(bit);

p += bit >> 5;
p += BIT_WORD(bit);

raw_local_irq_save(flags);
res = *p;
Expand Down

0 comments on commit 8901925

Please sign in to comment.