]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: 8417/1: refactor bitops functions with BIT_MASK() and BIT_WORD()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 17 Aug 2015 02:59:52 +0000 (03:59 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 18 Aug 2015 13:00:30 +0000 (14:00 +0100)
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>
arch/arm/include/asm/bitops.h

index 56380995f4c38364c620c0055083c877f85dcff0..e943e6cee254503cb642bf95caa573eca03de758 100644 (file)
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;