Use generic routines for xfs_next_bit
PATCH 1/2 Use generic routines for xfs_next_bit
We can use find_next_bit, which is assembly on some arches, to implement xfs_next_bit. Tested on x86.
Signed-off-by Eric Sandeen <[email protected]>
fs/xfs/xfs_bit.c +10 -26
@@ -192,32 +192,16 @@ found:*/ int xfs_next_bit (uint *map,uint size,uint start_bit) { -uint * p = ((unsigned int *) map) + (start_bit >>BIT_TO_WORD_SHIFT ); -uint result = start_bit & ~(NBWORD -1 ); -uint tmp; +int result; - size <<=BIT_TO_WORD_SHIFT ; + size <<=BIT_TO_WORD_SHIFT ; +if (start_bit >= size)/* beyond end of bitmap */ +return -1 ; -if (start_bit >= size) -return -1 ; - size -= result; - start_bit &= (NBWORD -1 ); -if (start_bit) { - tmp = *p++; -/* set to zero first offset bits prior to start */ - tmp &= (~0U << start_bit); -if (tmp !=0U ) - goto found; - result +=NBWORD ; - size -=NBWORD ; - } -while (size) { -if ((tmp = *p++) !=0U ) - goto found; - result +=NBWORD ; - size -=NBWORD ; - } -return -1 ; -found: -return result +ffs (tmp) -1 ; + result =find_next_bit ((unsigned long *)map, size, start_bit); + +if (result == size)/* no bits set */ +return -1 ; + +return result; }