Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>

authored by

Mikulas Patocka and committed by
Alasdair G Kergon
553d8fe0 75e3a0f5

+4 -4
+4 -4
drivers/md/dm-verity.c
··· 451 451 goto no_prefetch_cluster; 452 452 453 453 if (unlikely(cluster & (cluster - 1))) 454 - cluster = 1 << (fls(cluster) - 1); 454 + cluster = 1 << __fls(cluster); 455 455 456 456 hash_block_start &= ~(sector_t)(cluster - 1); 457 457 hash_block_end |= cluster - 1; ··· 723 723 r = -EINVAL; 724 724 goto bad; 725 725 } 726 - v->data_dev_block_bits = ffs(num) - 1; 726 + v->data_dev_block_bits = __ffs(num); 727 727 728 728 if (sscanf(argv[4], "%u%c", &num, &dummy) != 1 || 729 729 !num || (num & (num - 1)) || ··· 733 733 r = -EINVAL; 734 734 goto bad; 735 735 } 736 - v->hash_dev_block_bits = ffs(num) - 1; 736 + v->hash_dev_block_bits = __ffs(num); 737 737 738 738 if (sscanf(argv[5], "%llu%c", &num_ll, &dummy) != 1 || 739 739 (sector_t)(num_ll << (v->data_dev_block_bits - SECTOR_SHIFT)) ··· 812 812 } 813 813 814 814 v->hash_per_block_bits = 815 - fls((1 << v->hash_dev_block_bits) / v->digest_size) - 1; 815 + __fls((1 << v->hash_dev_block_bits) / v->digest_size); 816 816 817 817 v->levels = 0; 818 818 if (v->data_blocks)