aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2013-09-23 06:01:44 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-10-24 11:16:56 -0400
commit7d7c7b24e416afb2637be8447e03ca4457c100fd (patch)
tree3f6df4a49ba2fdaaa01e824d77811777d745cc6d /arch
parentb1cb7e2b6c3e8758e7406422b66c54c066737977 (diff)
s390/bitops: rename find_first_bit_left() to find_first_bit_inv()
find_first_bit_left() and friends have nothing to do with the normal LSB0 bit numbering for big endian machines used in Linux (least significant bit has bit number 0). Instead they use MSB0 bit numbering, where the most signficant bit has bit number 0. So rename find_first_bit_left() and friends to find_first_bit_inv(), to avoid any confusion. Also provide inv versions of set_bit, clear_bit and test_bit. This also removes the confusing use of e.g. set_bit() in airq.c which uses a "be_to_le" bit number conversion, which could imply that instead set_bit_le() could be used. But that is entirely wrong since the _le bitops variant uses yet another bit numbering scheme. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/s390/include/asm/bitops.h39
-rw-r--r--arch/s390/lib/find.c10
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)
300} 300}
301 301
302/* 302/*
303 * ATTENTION: 303 * Functions which use MSB0 bit numbering.
304 * find_first_bit_left() and find_next_bit_left() use MSB0 encoding. 304 * On an s390x system the bits are numbered:
305 * |0..............63|64............127|128...........191|192...........255|
306 * and on s390:
307 * |0.....31|31....63|64....95|96...127|128..159|160..191|192..223|224..255|
305 */ 308 */
306unsigned long find_first_bit_left(const unsigned long *addr, unsigned long size); 309unsigned long find_first_bit_inv(const unsigned long *addr, unsigned long size);
307unsigned long find_next_bit_left(const unsigned long *addr, unsigned long size, 310unsigned long find_next_bit_inv(const unsigned long *addr, unsigned long size,
308 unsigned long offset); 311 unsigned long offset);
312
313static inline void set_bit_inv(unsigned long nr, volatile unsigned long *ptr)
314{
315 return set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
316}
317
318static inline void clear_bit_inv(unsigned long nr, volatile unsigned long *ptr)
319{
320 return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
321}
322
323static inline void __set_bit_inv(unsigned long nr, volatile unsigned long *ptr)
324{
325 return __set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
326}
327
328static inline void __clear_bit_inv(unsigned long nr, volatile unsigned long *ptr)
329{
330 return __clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
331}
332
333static inline int test_bit_inv(unsigned long nr,
334 const volatile unsigned long *ptr)
335{
336 return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
337}
309 338
310#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES 339#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
311 340
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 @@
15#include <linux/bitops.h> 15#include <linux/bitops.h>
16#include <linux/export.h> 16#include <linux/export.h>
17 17
18unsigned long find_first_bit_left(const unsigned long *addr, unsigned long size) 18unsigned long find_first_bit_inv(const unsigned long *addr, unsigned long size)
19{ 19{
20 const unsigned long *p = addr; 20 const unsigned long *p = addr;
21 unsigned long result = 0; 21 unsigned long result = 0;
@@ -35,10 +35,10 @@ unsigned long find_first_bit_left(const unsigned long *addr, unsigned long size)
35found: 35found:
36 return result + (__fls(tmp) ^ (BITS_PER_LONG - 1)); 36 return result + (__fls(tmp) ^ (BITS_PER_LONG - 1));
37} 37}
38EXPORT_SYMBOL(find_first_bit_left); 38EXPORT_SYMBOL(find_first_bit_inv);
39 39
40unsigned long find_next_bit_left(const unsigned long *addr, unsigned long size, 40unsigned long find_next_bit_inv(const unsigned long *addr, unsigned long size,
41 unsigned long offset) 41 unsigned long offset)
42{ 42{
43 const unsigned long *p = addr + (offset / BITS_PER_LONG); 43 const unsigned long *p = addr + (offset / BITS_PER_LONG);
44 unsigned long result = offset & ~(BITS_PER_LONG - 1); 44 unsigned long result = offset & ~(BITS_PER_LONG - 1);
@@ -74,4 +74,4 @@ found_first:
74found_middle: 74found_middle:
75 return result + (__fls(tmp) ^ (BITS_PER_LONG - 1)); 75 return result + (__fls(tmp) ^ (BITS_PER_LONG - 1));
76} 76}
77EXPORT_SYMBOL(find_next_bit_left); 77EXPORT_SYMBOL(find_next_bit_inv);