Skip to content

Commit

Permalink
[PATCH] md: use ffz instead of find_first_set to convert multiplier t…
Browse files Browse the repository at this point in the history
…o shift

find_first_set doesn't find the least-significant bit on bigendian machines,
so it is really wrong to use it.

ffs is closer, but takes an 'int' and we have a 'unsigned long'.  So use
ffz(~X) to convert a chunksize into a chunkshift.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Paul Clements authored and Linus Torvalds committed Oct 3, 2006
1 parent 14f50b4 commit a638b2d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1444,8 +1444,7 @@ int bitmap_create(mddev_t *mddev)
if (err)
goto error;

bitmap->chunkshift = find_first_bit(&bitmap->chunksize,
sizeof(bitmap->chunksize));
bitmap->chunkshift = ffz(~bitmap->chunksize);

/* now that chunksize and chunkshift are set, we can use these macros */
chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) /
Expand Down

0 comments on commit a638b2d

Please sign in to comment.