[Devel] [PATCH 3/4] blk-cbt: Don't open-code is_power_of_2 function

Nikolay Borisov nikolay.borisov at virtuozzo.com
Fri Jan 27 14:34:40 MSK 2023


Signed-off-by: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
---
 block/blk-cbt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 269709c7589b..68c7f71ec3a0 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -17,6 +17,7 @@
 #include <linux/spinlock.h>
 #include <linux/pagemap.h>
 #include <linux/vmalloc.h>
+#include <linux/log2.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 
@@ -625,7 +626,7 @@ static int cbt_ioc_init(struct block_device *bdev, struct blk_user_cbt_info __us
 	if (copy_from_user(&ci, ucbt_ioc, sizeof(ci)))
 		return -EFAULT;
 
-	if (((ci.ci_blksize -1) & ci.ci_blksize))
+	if (!is_power_of_2(ci.ci_blksize))
 		return -EINVAL;
 
 	q = bdev_get_queue(bdev);
-- 
2.34.1



More information about the Devel mailing list