Skip to content

Commit

Permalink
dm verity: use __ffs and __fls
Browse files Browse the repository at this point in the history
This patch changes ffs() to __ffs() and fls() to __fls() which don't add
one to the result.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Jul 10, 2013
1 parent 75e3a0f commit 553d8fe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/md/dm-verity.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ static void verity_prefetch_io(struct work_struct *work)
goto no_prefetch_cluster;

if (unlikely(cluster & (cluster - 1)))
cluster = 1 << (fls(cluster) - 1);
cluster = 1 << __fls(cluster);

hash_block_start &= ~(sector_t)(cluster - 1);
hash_block_end |= cluster - 1;
Expand Down Expand Up @@ -723,7 +723,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
r = -EINVAL;
goto bad;
}
v->data_dev_block_bits = ffs(num) - 1;
v->data_dev_block_bits = __ffs(num);

if (sscanf(argv[4], "%u%c", &num, &dummy) != 1 ||
!num || (num & (num - 1)) ||
Expand All @@ -733,7 +733,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
r = -EINVAL;
goto bad;
}
v->hash_dev_block_bits = ffs(num) - 1;
v->hash_dev_block_bits = __ffs(num);

if (sscanf(argv[5], "%llu%c", &num_ll, &dummy) != 1 ||
(sector_t)(num_ll << (v->data_dev_block_bits - SECTOR_SHIFT))
Expand Down Expand Up @@ -812,7 +812,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
}

v->hash_per_block_bits =
fls((1 << v->hash_dev_block_bits) / v->digest_size) - 1;
__fls((1 << v->hash_dev_block_bits) / v->digest_size);

v->levels = 0;
if (v->data_blocks)
Expand Down

0 comments on commit 553d8fe

Please sign in to comment.