Commit 553d8fe0 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon

dm verity: use __ffs and __fls

This patch changes ffs() to __ffs() and fls() to __fls() which don't add
one to the result.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 75e3a0f5
...@@ -451,7 +451,7 @@ static void verity_prefetch_io(struct work_struct *work) ...@@ -451,7 +451,7 @@ static void verity_prefetch_io(struct work_struct *work)
goto no_prefetch_cluster; goto no_prefetch_cluster;
if (unlikely(cluster & (cluster - 1))) if (unlikely(cluster & (cluster - 1)))
cluster = 1 << (fls(cluster) - 1); cluster = 1 << __fls(cluster);
hash_block_start &= ~(sector_t)(cluster - 1); hash_block_start &= ~(sector_t)(cluster - 1);
hash_block_end |= cluster - 1; hash_block_end |= cluster - 1;
...@@ -723,7 +723,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -723,7 +723,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
r = -EINVAL; r = -EINVAL;
goto bad; 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 || if (sscanf(argv[4], "%u%c", &num, &dummy) != 1 ||
!num || (num & (num - 1)) || !num || (num & (num - 1)) ||
...@@ -733,7 +733,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -733,7 +733,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
r = -EINVAL; r = -EINVAL;
goto bad; 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 || if (sscanf(argv[5], "%llu%c", &num_ll, &dummy) != 1 ||
(sector_t)(num_ll << (v->data_dev_block_bits - SECTOR_SHIFT)) (sector_t)(num_ll << (v->data_dev_block_bits - SECTOR_SHIFT))
...@@ -812,7 +812,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -812,7 +812,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
} }
v->hash_per_block_bits = 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; v->levels = 0;
if (v->data_blocks) if (v->data_blocks)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment