diff options
Diffstat (limited to 'include/asm-s390/bitops.h')
-rw-r--r-- | include/asm-s390/bitops.h | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/include/asm-s390/bitops.h b/include/asm-s390/bitops.h index 95d93955a9bb..882db054110c 100644 --- a/include/asm-s390/bitops.h +++ b/include/asm-s390/bitops.h | |||
@@ -790,8 +790,6 @@ static inline int sched_find_first_bit(unsigned long *b) | |||
790 | test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) | 790 | test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) |
791 | #define ext2_test_bit(nr, addr) \ | 791 | #define ext2_test_bit(nr, addr) \ |
792 | test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) | 792 | test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) |
793 | #define ext2_find_next_bit(addr, size, off) \ | ||
794 | generic_find_next_le_bit((unsigned long *)(addr), (size), (off)) | ||
795 | 793 | ||
796 | static inline int ext2_find_first_zero_bit(void *vaddr, unsigned int size) | 794 | static inline int ext2_find_first_zero_bit(void *vaddr, unsigned int size) |
797 | { | 795 | { |
@@ -833,6 +831,47 @@ static inline int ext2_find_next_zero_bit(void *vaddr, unsigned long size, | |||
833 | return offset + ext2_find_first_zero_bit(p, size); | 831 | return offset + ext2_find_first_zero_bit(p, size); |
834 | } | 832 | } |
835 | 833 | ||
834 | static inline unsigned long ext2_find_first_bit(void *vaddr, | ||
835 | unsigned long size) | ||
836 | { | ||
837 | unsigned long bytes, bits; | ||
838 | |||
839 | if (!size) | ||
840 | return 0; | ||
841 | bytes = __ffs_word_loop(vaddr, size); | ||
842 | bits = __ffs_word(bytes*8, __load_ulong_le(vaddr, bytes)); | ||
843 | return (bits < size) ? bits : size; | ||
844 | } | ||
845 | |||
846 | static inline int ext2_find_next_bit(void *vaddr, unsigned long size, | ||
847 | unsigned long offset) | ||
848 | { | ||
849 | unsigned long *addr = vaddr, *p; | ||
850 | unsigned long bit, set; | ||
851 | |||
852 | if (offset >= size) | ||
853 | return size; | ||
854 | bit = offset & (__BITOPS_WORDSIZE - 1); | ||
855 | offset -= bit; | ||
856 | size -= offset; | ||
857 | p = addr + offset / __BITOPS_WORDSIZE; | ||
858 | if (bit) { | ||
859 | /* | ||
860 | * s390 version of ffz returns __BITOPS_WORDSIZE | ||
861 | * if no zero bit is present in the word. | ||
862 | */ | ||
863 | set = ffs(__load_ulong_le(p, 0) >> bit) + bit; | ||
864 | if (set >= size) | ||
865 | return size + offset; | ||
866 | if (set < __BITOPS_WORDSIZE) | ||
867 | return set + offset; | ||
868 | offset += __BITOPS_WORDSIZE; | ||
869 | size -= __BITOPS_WORDSIZE; | ||
870 | p++; | ||
871 | } | ||
872 | return offset + ext2_find_first_bit(p, size); | ||
873 | } | ||
874 | |||
836 | #include <asm-generic/bitops/minix.h> | 875 | #include <asm-generic/bitops/minix.h> |
837 | 876 | ||
838 | #endif /* __KERNEL__ */ | 877 | #endif /* __KERNEL__ */ |