diff options
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/include/asm/bitops.h | 39 | ||||
-rw-r--r-- | arch/s390/lib/find.c | 10 |
2 files changed, 39 insertions, 10 deletions
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h index c6dbd6115cc5..6e6ad0680829 100644 --- a/arch/s390/include/asm/bitops.h +++ b/arch/s390/include/asm/bitops.h @@ -300,12 +300,41 @@ static inline int test_bit(unsigned long nr, const volatile unsigned long *ptr) } /* - * ATTENTION: - * find_first_bit_left() and find_next_bit_left() use MSB0 encoding. + * Functions which use MSB0 bit numbering. + * On an s390x system the bits are numbered: + * |0..............63|64............127|128...........191|192...........255| + * and on s390: + * |0.....31|31....63|64....95|96...127|128..159|160..191|192..223|224..255| */ -unsigned long find_first_bit_left(const unsigned long *addr, unsigned long size); -unsigned long find_next_bit_left(const unsigned long *addr, unsigned long size, - unsigned long offset); +unsigned long find_first_bit_inv(const unsigned long *addr, unsigned long size); +unsigned long find_next_bit_inv(const unsigned long *addr, unsigned long size, + unsigned long offset); + +static inline void set_bit_inv(unsigned long nr, volatile unsigned long *ptr) +{ + return set_bit(nr ^ (BITS_PER_LONG - 1), ptr); +} + +static inline void clear_bit_inv(unsigned long nr, volatile unsigned long *ptr) +{ + return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr); +} + +static inline void __set_bit_inv(unsigned long nr, volatile unsigned long *ptr) +{ + return __set_bit(nr ^ (BITS_PER_LONG - 1), ptr); +} + +static inline void __clear_bit_inv(unsigned long nr, volatile unsigned long *ptr) +{ + return __clear_bit(nr ^ (BITS_PER_LONG - 1), ptr); +} + +static inline int test_bit_inv(unsigned long nr, + const volatile unsigned long *ptr) +{ + return test_bit(nr ^ (BITS_PER_LONG - 1), ptr); +} #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES diff --git a/arch/s390/lib/find.c b/arch/s390/lib/find.c index 8963929b06b9..620d34d6487e 100644 --- a/arch/s390/lib/find.c +++ b/arch/s390/lib/find.c @@ -15,7 +15,7 @@ #include <linux/bitops.h> #include <linux/export.h> -unsigned long find_first_bit_left(const unsigned long *addr, unsigned long size) +unsigned long find_first_bit_inv(const unsigned long *addr, unsigned long size) { const unsigned long *p = addr; unsigned long result = 0; @@ -35,10 +35,10 @@ unsigned long find_first_bit_left(const unsigned long *addr, unsigned long size) found: return result + (__fls(tmp) ^ (BITS_PER_LONG - 1)); } -EXPORT_SYMBOL(find_first_bit_left); +EXPORT_SYMBOL(find_first_bit_inv); -unsigned long find_next_bit_left(const unsigned long *addr, unsigned long size, - unsigned long offset) +unsigned long find_next_bit_inv(const unsigned long *addr, unsigned long size, + unsigned long offset) { const unsigned long *p = addr + (offset / BITS_PER_LONG); unsigned long result = offset & ~(BITS_PER_LONG - 1); @@ -74,4 +74,4 @@ found_first: found_middle: return result + (__fls(tmp) ^ (BITS_PER_LONG - 1)); } -EXPORT_SYMBOL(find_next_bit_left); +EXPORT_SYMBOL(find_next_bit_inv); |