Skip to content

Commit

Permalink
m68k: Add ext2_find_{first,next}_bit() for ext4
Browse files Browse the repository at this point in the history
Add ext2_find_{first,next}_bit(), which are needed for ext4.  They're
derived out of the ext2_find_next_zero_bit found in the same file.
Compile tested with crosstools

[Reworked to preserve all symmetry with ext2_find_{first,next}_zero_bit()]

This fixes http://bugzilla.kernel.org/show_bug.cgi?id=10393

[[email protected]: coding-style fixes]
Signed-off-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kvaneesh authored and torvalds committed Jun 13, 2008
1 parent 2d518f8 commit 69c5ddf
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions include/asm-m68k/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,49 @@ static inline int ext2_find_next_zero_bit(const void *vaddr, unsigned size,
res = ext2_find_first_zero_bit (p, size - 32 * (p - addr));
return (p - addr) * 32 + res;
}
#define ext2_find_next_bit(addr, size, off) \
generic_find_next_le_bit((unsigned long *)(addr), (size), (off))

static inline int ext2_find_first_bit(const void *vaddr, unsigned size)
{
const unsigned long *p = vaddr, *addr = vaddr;
int res;

if (!size)
return 0;

size = (size >> 5) + ((size & 31) > 0);
while (*p++ == 0UL) {
if (--size == 0)
return (p - addr) << 5;
}

--p;
for (res = 0; res < 32; res++)
if (ext2_test_bit(res, p))
break;
return (p - addr) * 32 + res;
}

static inline int ext2_find_next_bit(const void *vaddr, unsigned size,
unsigned offset)
{
const unsigned long *addr = vaddr;
const unsigned long *p = addr + (offset >> 5);
int bit = offset & 31UL, res;

if (offset >= size)
return size;

if (bit) {
/* Look for one in first longword */
for (res = bit; res < 32; res++)
if (ext2_test_bit(res, p))
return (p - addr) * 32 + res;
p++;
}
/* No set bit yet, search remaining full bytes for a set bit */
res = ext2_find_first_bit(p, size - 32 * (p - addr));
return (p - addr) * 32 + res;
}

#endif /* __KERNEL__ */

Expand Down

0 comments on commit 69c5ddf

Please sign in to comment.